• 0.17.0

Weave Binaries with AspectJ Aspects after APT Processing

This goal weaves Java .class binary files with AspectJ aspects. Comparing to AspectJ compiling of .java files, this approach guarantees that APT processor modifications stay untouched. To use the plugin add this configuration to your pom.xml:

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>com.jcabi</groupId>
        <artifactId>jcabi-maven-plugin</artifactId>
        <version>0.17.0</version>
        <executions>
          <execution>
            <goals>
              <goal>ajc</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

The plugin will find all AspectJ aspects available in the project compile classpath and plugin class and weave .class files using them. By default, the plugin finds binary .class files in target/classes and replaces them with woven versions. It is possible to change the location of them using classesDirectory parameter. For example, if you need to weave test classes:

<execution>
  <configuration>
    <classesDirectory>target/test-classes</classesDirectory>
  </configuration>
  [...]
</execution>

It is also possible to tell the plugin to use additional not yet compiled AspectJ aspects in source .java or .aj format. Add the list of directories where these aspects are located to the plugin configuration:

<execution>
  <configuration>
    <aspectsDirectories>
      <directory>src/main/aspect</directory>
    </aspectsDirectories>
  </configuration>
  [...]
</execution>

Another alternative is aspectj-maven-plugin, but it can't weave binaries, as explained here.

Cutting Edge Version

If you want to use current version of the plugin, you can do it with this configuration in your pom.xml:

<pluginRepositories>
  <pluginRepository>
    <id>oss.sonatype.org</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  </pluginRepository>
</pluginRepositories>
<project>
  <build>
    <plugins>
      <plugin>
        <groupId>com.jcabi</groupId>
        <artifactId>jcabi-maven-plugin</artifactId>
        <version>1.0-SNAPSHOT</version>
        [...]
      </plugin>
    </plugins>
  </build>
</project>