How can I get IDEA to retain 'Ajc' as the project compiler?

Answered

When I select 'Ajc' as the project compiler and then hit Reload All Maven Projects, IntelliJ switches back to 'Javac' automatically. I think there is some way IDEA can autodetect that 'Ajc' is the correct choice but I don't know what the criteria for that are. I'm using the Maven plugin com.nickwongdev:aspectj-maven-plugin. I'd like the IDE to at least retain my setting of compiler whenever i have to update the project dependencies.

1
3 comments

IDE uses the Maven configuration for compiler when you have Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | Detect compiler automatically option enabled.

Please make sure to use latest IDE versions as the com.nickwongdev:aspectj-maven-plugin support has been added in later versions: https://youtrack.jetbrains.com/issue/IDEA-230356

 

if problem remains can you provide a sample project that would show the Maven configuration you use?

0
Avatar
Permanently deleted user

Disabling "detect compiler automatically" works. Thanks! But the plugin didn't help, I have it configured as such:
   

<pluginManagement>
<plugins>
<plugin>
<groupId>com.nickwongdev</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.12.6</version>
<configuration>
<complianceLevel>11</complianceLevel>
<source>11</source>
<target>11</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.nickwongdev</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
</plugin>
</plugins>

 

0

Are you sure the aspectj compiler is effectively used for the project when you compile from command line?

Try explicitly specifying the compiler using compilerId configuration properly of maven-compiler-plugin. Since the default compiler is always javac. The aspectj value will set it to aspectj compiler.

0

Please sign in to leave a comment.