Maven vs. AspectJ - Example?

My aspect works fine with Eclipse with the AspectJ plugin, however, if I try to use it with Maven, I get ... nothing.

I tried this http://mojo.codehaus.org/aspectj-maven-plugin/includeExclude.html

I add loggin to my aspect and I try to test it with the junit test, but when I run

mvn clean mvn test 

I get...

 [INFO] [aspectj:compile {execution: default}] 

But I do not see the entrance to the test

If I compile in Eclipse it works find, but Id as if it is an Independent IDE (so I could use it with Hudson)

PS I am using the .aj file for Aspect

I tried Google, but I can not find any working example.

+7
java eclipse maven-2 aop aspectj
source share
1 answer

Without seeing that your POM is hard to say, you need to check that Maven expects your aspects to be under src / main / aspect, and not src / main / java by default.

You also need to ensure that the agej runtime library is in your class path (in Eclipse it is included in the AJDT path container.

For example (from the plugin documentation):

 <project> ... <dependencies> ... <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.6.2</version> </dependency> ... </dependencies> ... <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</artifactId> <version>1.2</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> 

If none of them work, can you post your pom content? This can help identify the problem.

+8
source share

All Articles