Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

AspectJMaven/forceVersion

You can override the version of AspectJ the Maven ApsectJ Plugin is using (this technique is standard Maven dependency management configuration, can be used in every Maven build and is not specific to AspectJ or the AspectJ plugin).

You can force the dependency in the aspectj-maven-plugin configuration in you POM. In the following example we are forcing the aspectj-maven-plugin to use version 1.6.5 of AspectJ :


    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>aspectj-maven-plugin</artifactId>
      <dependencies>
        <dependency>
          <groupId>org.aspectj</groupId>
          <artifactId>aspectjrt</artifactId>
          <version>1.6.5</version>
        </dependency>
        <dependency>
          <groupId>org.aspectj</groupId>
          <artifactId>aspectjtools</artifactId>
          <version>1.6.5</version>
        </dependency>
      </dependencies>
      <executions>
        ....
      </executions>
      <configuration>
        ....
      </configuration>
    </plugin> 

This system works for using an updated ApsectJ version that fixes AspectJ internal bug, or that offer new features in AspectJ. Unfortunately, if the new version of AspectJ contains a new command line option, forcing the plugin to use a new version of AspectJ will not enable that command line option, because the plugin has no knowledge of that option and does not support a way of forcing it.

You can also force the plugin to use a patched/devel version of AspectJ, provided that you give such version a specific version number and deploy it to your Maven repository (either you local machine one, or your internal company one).

To do so, download the developer version of AspectJ.

Unzip it, and you'll find the four AspectJ jars in the "lib" folder inside it.

Then you need to deploy them on Maven repository :

mvn deploy:deploy-file -Dfile=path-to/aspectjrt.jar -DgroupId=org.aspectj -DartifactId=aspectjrt -Dversion=1.6.7-DEV -Dpackaging=jar
mvn deploy:deploy-file -Dfile=path-to/aspectjtools.jar -DgroupId=org.aspectj -DartifactId=aspectjtools -Dversion=1.6.7-DEV -Dpackaging=jar

In this case, we are deploying a 1.6.7 developer version, so I used 1.6.7-DEV as a version.

Then, in your POM, you can force this version :

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>aspectj-maven-plugin</artifactId>
      <dependencies>
        <dependency>
          <groupId>org.aspectj</groupId>
          <artifactId>aspectjrt</artifactId>
          <version>1.6.7-DEV</version>
        </dependency>
        <dependency>
          <groupId>org.aspectj</groupId>
          <artifactId>aspectjtools</artifactId>
          <version>1.6.7-DEV</version>
        </dependency>


Using the same technique you can use a patched version of AspectJ inside your maven build. Simply, instead of downloading and unzipping the developer version, build your own version and use the jars produced by the AspectJ build to deploy them to the maven repo.

Back to the top