6

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.

Naman
  • 27,789
  • 26
  • 218
  • 353
Mandroid
  • 6,200
  • 12
  • 64
  • 134
  • The issue is pretty much the same, right? Did the solutions suggest there not work for you? – Naman Jul 19 '20 at 05:30
  • It didn't work. – Mandroid Jul 19 '20 at 05:37
  • You have tried both [this](https://stackoverflow.com/a/52277056/1746118) and [this](https://stackoverflow.com/a/49474325/1746118)? Since the version that you are using is itself 2 years old. – Naman Jul 19 '20 at 06:09

1 Answers1

9

Update II (2023-03): The MojoHaus aspectj-maven-plugin's development seems to have stalled again. Instead, the AspectJ developers recommend switching to a different fork of the AspectJ Maven plugin, which is kept up to date with AspectJ itself. The fork's coordinates are:

<dependency>
  <groupId>dev.aspectj</groupId>
  <artifactId>aspectj-maven-plugin</artifactId>
  <version>1.13.1</version>
</dependency>

Update I:

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>
kidney
  • 2,663
  • 17
  • 23
  • 2
    Yes, this is kind of the "official unofficial" version. Nick is trying to become the maintainer of the Mojohaus plugin, but everything is super slow there. His fork is even supported by IntelliJ IDEA now and automatically recognised in the latest few 2020.x versions. In Eclipse the situation is not so nice yet. See also my answer [here](https://stackoverflow.com/a/62213003/1082681). – kriegaex Jul 20 '20 at 02:07
  • Issues are closed since may 30 2021 : https://github.com/mojohaus/aspectj-maven-plugin/issues/41#issuecomment-851062721 – Mariano LEANCE Sep 14 '21 at 20:28