Aspectj compilation works in maven, fails in intellij
Answered
When building the project in maven, the aspects got woven correctly - but in intellij they fail with the following warnings like:
Warning:ajc: this affected type is not exposed to the weaver: ...User [Xlint:typeNotExposedToWeaver]
Warning:ajc: advice defined in ...SecurityAspect has not been applied [Xlint:adviceDidNotMatch]
It fails on both complete project rebuild and per-file recompilations.
* File > Preferences > Build > Compiler > Use compiler is set to ajc and the path to ajc compiler works (validated with test button).
* Un-applied aspects are in .aj form and part of the current project.
Relevant plugins in maven POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<configuration>
<complianceLevel>${java.version}</complianceLevel>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/generated-web-resources</directory>
</resource>
</webResources>
</configuration>
</plugin>
Am I missing something?
Please sign in to leave a comment.
Please report at https://youtrack.jetbrains.com/issues/IDEA with the sample project to reproduce attached. Thanks!
Serge, I am trying to create a sample event where I can reproduce this but it is easier said than done. Apparently there is some combination of things in my project that is causing this. Something is causing some classes not to be included in the ajc compilation (I have disabled propagation to javac). Is there any way I can find out more why, using some debug log or something?
You can enable debug logging for build.log per https://intellij-support.jetbrains.com/hc/articles/207241085.
It appears that the project-aspects are weaved in when rebuilding the whole project, but not when recompiling a single file. I checked the byte code:
As you can see the spring transaction aspects are weaved in in both cases but the local aspects are not. Is this a known issue and possible to do anything about?
https://youtrack.jetbrains.com/issue/IDEA-135483 may be related.
Serge: yes it seems to be the same bug unfortunately. And sadly it seems like it´s not being worked on either?
The bug has been active in the bug tracker for around 3 years already. Is there any hope of it being adressed or should we aspectj users look for other options?