MY aspect works great from Eclipse with 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 in my aspect and I try to test it with junit test, but when I run
mvn clean
mvn test
I get...
[INFO] [aspectj:compile {execution: default}]
But i dont see logging in test
If I do compiling in Eclipse it works find, but Id like it to be IDE Independent(so I could use it with Hudson)
P.S. I use .aj file for Aspect
I tried to Google it, but I cant find any working example.
This plugin weaves AspectJ aspects into your classes using the AspectJ compiler ("ajc"). Typically, aspects are used in one of two ways within your Maven reactors: As part of a Single Project, implying aspects and code are defined within the same Maven project.
AspectJ Leads to Clean Code AOP tries to reduce code scattering and code tangling. Code is tangled when its crosscutting concern code is intermixed with code that implements other concerns, and code is scattered when crosscutting code is spread out over multiple modules.
A study done showed that the AspectJ compiler ajc is about 34% slower than the Sun Microsystems Java 1.3 compiler and about 62% slower than the Java 1.4 compiler.
Without seeing your POM it's hard to say, one thing to check is that Maven expects your aspects to be under src/main/aspect rather than src/main/java by default.
You also need to ensure the aspectj runtime library is on your classpath (in Eclipse it is included by the AJDT classpath 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 neither of these work, can you post your pom contents? It might help to identify the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With