Fork me on GitHub

Using aspect libraries

Applying already compiled aspect JARs

In order to apply already compiled aspects to your own sources, you need do set up all the aspect JARs wish to use for weaving in the plugin configuration as shown below.

Note: The artifacts you reference must exist as regular dependencies in your project.

<project>
  <!-- ... -->
  <dependencies>
    <!-- ... -->
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>${aspectjVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.agroup</groupId>
      <artifactId>to-weave</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>org.anothergroup</groupId>
      <artifactId>gen</artifactId>
      <version>1.0</version>
    </dependency>
    <!-- ... -->
  </dependencies>
  <!-- ... -->
  <build>
    <plugins>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>${project.version}</version>
        <configuration>
          <aspectLibraries>
            <aspectLibrary>
              <groupId>org.agroup</groupId>
              <artifactId>to-weave</artifactId>
            </aspectLibrary>
            <aspectLibrary>
              <groupId>org.anothergroup</groupId>
              <artifactId>gen</artifactId>
            </aspectLibrary>
          </aspectLibraries>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- ... -->
    </plugins>
  </build>
  <!-- ... -->
</project>