Is it possible to compile project with softened Exceptions (e.g.: declare soft: Exception : execution(* *.*());
) aspects in it using only aspectj-maven-plugin ? I can't handle it... I am still getting compilation error
unreported exception Exception; must be caught or declared to be thrown
So it is compiled without taking aspects in account.
I am using this command to compile:
mvn clean aspectj:compile
and my pom.xml is:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>pl.group.id</groupId>
<artifactId>aop</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<complianceLevel>1.7</complianceLevel>
<source>1.7</source>
<target>1.7</target>
<aspectDirectory>src/main/aspect</aspectDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
What am I doing wrong?
Actually I think there is a bug in Maven Compiler Plugin 3.0 and 3.1 because for me it works with plugin version 2.5.1. It seems that incremental compilation is broken or the corresponding switch
useIncrementalCompilation
is somehow accidentally reversed in its meaning since it was introduced in 3.1. Funnily, setting its value tofalse
fixes the situation for me. Downgrading to 2.5.1 also does. In both cases I need to change the phase for the AspectJ Maven Plugin toprocess-sources
as described in the question linked to by user @Gus.Solution A:
Solution B: