Search code examples
javamavenintellij-ideaaspectjaspectj-maven-plugin

IntelliJ ajc: how to make exclusions from aspectj-maven-plugin work?


I'm using the ajc compiler in IntelliJ, as well as the aspectj-maven-plugin, where I declare the following exclusions:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <excludes>
                    <exclude>**/EmployeeAccessAspect.java</exclude>
                </excludes>
                <complianceLevel>1.8</complianceLevel>
                <showWeaveInfo>true</showWeaveInfo>
                <verbose>true</verbose>
            </configuration>
        </plugin>

When I compile using mvn compile, everything is fine and the EmployeeAccessAspect aspect is correctly ignored.

However, if I Make the project in IntelliJ, it will just weave all the aspects that it finds (and totally ignore the maven exclusions).

I can always hack the ajc compiler options or aspect path to achieve what I want, but it would make me change two places if I have to exclude an aspect for some reason.

Is there any way to make the maven plugin and the ajc compilation in sync? I am using IntelliJ 15.


Solution

  • I can confirm that

    • it does not work in IDEA,
    • JetBrains knows about it at least since 2013,
    • I have commented on this issue,
    • what you want does work in Eclipse (AspectJ is an Eclipse project, so the IDE support there is considerably better).

    There is not much more I can say about it other than it is a known issue which is not considered a bug, but a new feature by JetBrains (see the ticket type there).