I'm running into a strange problem with aspectj-maven-plugin and Eclipse Juno. I have the following plugin defn in the build section of my pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>1.7</source>
<target>1.7</target>
<Xlint>ignore</Xlint>
<complianceLevel>1.7</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>true</verbose>
<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>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
I have an @Aspect
declared in my src/test/java/... folder.
If I build from the command line (ie: mvn clean package), my classes are built properly/as expected.
However, when I build from within Eclipse, the aspect declared in my test folder is woven into my output classes folder .class file as opposed to the test-classes folder (as confirmed by using a decompiler).
Is my configuration incorrect? Is there a setup I am missing in my Eclipse project to indicate to ignore the aspects when compiling? If I check my Java Build path config in Eclipse, I see that src/main/java -> target/classes whereas src/test/java-> target/test-classes.
Might this have something to do with the Lifecycle Mapping that is configured? I've got:
Plugin Extension Mapping Source
aspectj:compile configurator extension
aspectj:test-compile configurator extension
I have AJDT 1.7.3 (org.aspectj) and 2.2.3 (org.eclipse.ajdt) installed (I'm not sure why it installed both versions).
Update 2
I updated my Aspectj-maven-plugin configuration to be the following and overrode the m2e connector settings and it seems to work, but I would love to have 3rd party validation if this works for someone else since it seems that it is editor/configuration dependant.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sources>
<source>
<basedir>${project.build.sourceDirectory}</basedir>
<includes>
<include>**/*.aj</include>
<include>**/*.java</include>
</includes>
</source>
</sources>
</configuration>
</execution>
<execution>
<id>test compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sources>
<source>
<basedir>${project.build.testSourceDirectory}</basedir>
<includes>
<include>**/*.aj</include>
<include>**/*.java</include>
</includes>
</source>
</sources>
<weaveDirectories>
<param>${project.build.outputDirectory}</param>
</weaveDirectories>
</configuration>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<outxml>true</outxml>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>${java.version}</source>
<target>${java.version}</target>
<complianceLevel>${java.version}</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
</configuration>
</plugin>
With the following m2e configuration to override the m2e connector settings that is shipped with the AJDT/m2e 0.14 framework: org.eclipse.m2e lifecycle-mapping 1.0.0 org.codehaus.mojo aspectj-maven-plugin [1.7,) compile org.codehaus.mojo aspectj-maven-plugin [1.7,) test-compile
If this does work for others, the next step is to try and understand how/why the m2e connector fails, and where it needs to be fixed.
I uploaded my test code (including @kriegaex test project) to my github sample project: github.com/benze/aspectj-maven-plugin-defect-example.git . As per the readme, to enable/disable overriding the m2e-connector, enable the override-m2e-lifecycle profile.