'Compiling with maven-compiler-plugin and aspectj-maven-plugin

When i use maven-apsectj-plugin and maven-compiler-plugin compile phase will execute both plugins compile goal. This results in compilation with javac first and then full recompilation with ajc.

Is this double compilation necessary? It seems like i can just turn maven-compiler-plugin off and everything works just fine.

I'm using "default" configuration as stated in the usage of maven-compiler-plugin:

<project>
  ...
  <dependencies>
    ...
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>1.8.13</version>
    </dependency>
    ...
  </dependencies>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.11</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>       <!-- use this goal to weave all your main classes -->
              <goal>test-compile</goal>  <!-- use this goal to weave all your test classes -->
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  <build>
  ...
</project>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source