"Aspectj" Profile for AOP Weaving
The profile is activated automatically when you have a src/main/aspect
directory in the project. Otherwise, you can activate it explicitly:
$ mvn clean install -Paspectj
The profile runs jcabi-maven-plugin:ajc
plugin and adds these dependencies to the classpath:
com.jcabi:jcabi-aspects
: JSR-303 and other AOP aspects;org.aspectj:aspectjrt
(inruntime
scope): runtime AOP engine;javax.validation:validation-api
: JSR-303 API;
Don't forget to add JSR-303 validator implementation to your classpath, as explained in jcabi-aspects.
Pay attention that these dependencies are there only when profile is activated. After the artifact installation the profile won't be activated and you should add runtime dependencies explicitly to the project:
<dependencies> <dependency> <groupId>com.jcabi</groupId> <artifactId>jcabi-aspects</artifactId> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <scope>runtime</scope> </dependency> </dependencies>
This profile doesn't conflict with APT, because AspectJ weaving is happening outside of the main directory and its results are applied on top of APT-processed classes. The solution is borrowed from Sean Patrick Floyd.