I have a custom security framwork based on annotations.I use the aspectj maven plugin to weave the aspect when it comes across the security annotation for the method.
I use jenkins to build the project and the aspectj maven plugin goals are set for compile as given below.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<complianceLevel>1.6</complianceLevel>
<!-- <weaveDirectories> <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories> -->
</configuration>
<executions>
<execution>
<!-- Compile and weave aspects after all classes compiled by javac -->
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
The problem comes when the junit runs.Since it had already weaved the security related annotations in the methods,the unit test fails.
Is there a way where I can have the junits work and then do the aspectj weaving? Since I use a .aj file separately I am not sure how load time weaving can be set.
Any help on this is appreciated.
Regards
I reorganised my maven goals into
clean compile test aspectj:compile
so after testing the aspectj weaving is done which is all I wanted.