Maven AspectJ plugin fails to build with Java 9 due to missing tools.jar

MrkK picture MrkK · Jan 9, 2018 · Viewed 7.9k times · Source

I switched my JDK version from 8 to 9 and the AspectJ plugin no longer works due to missing tools.jar:

Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.10:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.10 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:9.0.1 at specified path C:\Program Files\Java\jdk-9.0.1/../lib/tools.jar

I understand that tools.jar (and rt.jar) were removed from Java 9 JDK. I am wondering if there a way to get Maven AspectJ plugin to work with Java 9 without tools.jar?

Here is my plugin definition with version info:

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>aspectj-maven-plugin</artifactId>
      <version>1.10</version>
      <configuration>       
      <encoding>${project.build.sourceEncoding}</encoding>
      <complianceLevel>1.9</complianceLevel>
      <showWeaveInfo>true</showWeaveInfo>
      <XnoInline>true</XnoInline>         
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>compile</goal>
              <goal>test-compile</goal>
          </goals>
        </execution>
      </executions>     
      <dependencies>
       <dependency>
       <groupId>org.aspectj</groupId>
       <artifactId>aspectjrt</artifactId>
       <version>1.9.0.RC2</version>
      </dependency> 
      <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjtools</artifactId>
        <version>1.9.0.RC2</version>
       </dependency>          
      </dependencies>
    </plugin>

Answer

izogfif picture izogfif · Sep 11, 2018

Until version 1.11.1 is released into Maven Central by org.codehaus.mojo use the snapshot build instead:

<groupId>com.github.m50d</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11.1</version>