title: Maven + AspectJ weaving for Java8
body: <p>I Cannot <strong>mvn package</strong> with the minimal sample below. Eclipse (Mars.2 Release 4.5.2) compiles and weaves without a problem.</p>
  
  <p>What do I have to do to make it work?</p>
  
  <p>The output:</p>
  
  <pre><code>[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()
  </code></pre>
  
  <p>A sample class:</p>
  
  <pre><code>package test;
  
  public class Foo {
      public void bar() {
          this.doSomethingInjected();
      }
  }
  </code></pre>
  
  <p>Sample interface:</p>
  
  <pre><code>package test;
  
  public interface Injectable { }
  </code></pre>
  
  <p>aspect:</p>
  
  <pre><code>package test;
  
  public aspect Injection {
  
      declare parents : test..* implements Injectable;
  
      public void Injectable.doSomethingInjected() {
          System.out.println("done");
      }
  }
  </code></pre>
  
  <p>pom.xml (relevant parts as per  <a href="http://www.mojohaus.org/aspectj-maven-plugin/usage.html" rel="nofollow noreferrer">aspectj-maven-plugin usage doc</a>)</p>
  
  <pre><code>&lt;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"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;test&lt;/groupId&gt;
      &lt;artifactId&gt;test&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
              &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
              &lt;version&gt;1.8.9&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.9&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;compile&lt;/goal&gt;
                              &lt;goal&gt;test-compile&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>