I Cannot mvn package with the minimal sample below. Eclipse (Mars.2 Release 4.5.2) compiles and weaves without a problem.
What do I have to do to make it work?
The output:
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 2 source files to ...\workspace\test\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] .../workspace/test/src/main/java/test/Foo.java:[6,21] cannot find symbol
symbol: method doSomethingInjected()
A sample class:
package test;
public class Foo {
public void bar() {
this.doSomethingInjected();
}
}
Sample interface:
package test;
public interface Injectable { }
aspect:
package test;
public aspect Injection {
declare parents : test..* implements Injectable;
public void Injectable.doSomethingInjected() {
System.out.println("done");
}
}
pom.xml (relevant parts as per aspectj-maven-plugin usage doc)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>