aspectj-maven-plugin 1.11 : missing tools.jar issue with jdk 11

Viewed 4930

I have aspectj-maven-plugin:1.11 in my pom and jdk 11 installed on my system. Jdk 11 doesn't have tools.jar in lib directory. This is causing maven build to fail with error:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile (default) on project groundtruth-storage-writer: Execution default of goal org.codehaus.mojo:aspectj- maven-plugin:1.11:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.11 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:11.0.7 at specified path ...\Java\jdk-11.0.7/../lib/tools.jar

How to solve this issue?

There is an answer here, but that is more than 2 years old.

1 Answers

Update:

The official aspectj-maven-plugin has been resurrected, version 1.14.0 supports JDK up to 16.

Original answer:

Unfortunately, (as of July 2020) the currect version of the "official" aspectj-maven-plugin runs only on Java 8. There are two outstanding issues for it here and here and several PRs fixing them, but the maintainers haven't responded to any of them.

You can try switching to a different fork of the plugin, for example, Nick Wong's version:

<dependency>
  <groupId>com.nickwongdev</groupId>
  <artifactId>aspectj-maven-plugin</artifactId>
  <version>1.12.6</version>
</dependency>
Related