title: Weaving production aspect into test class with Gradle AspectJ
body: <p>I am using the Gradle AspectJ plugin to weave some production aspect into test Java code. I would have expected this to work out of the box with the plugin, but apparently that's not the case as demoed here:
  <a href="https://github.com/sedubois/gradle-aspectj-poc/tree/dc44f529831a485fcff8f4889dba8098784dddb4" rel="nofollow">https://github.com/sedubois/gradle-aspectj-poc/tree/dc44f529831a485fcff8f4889dba8098784dddb4</a></p>
  
  <p>The weaving of <code>UnsupportedOperationAspect</code> into <code>MainSevice</code> (both under <code>src/main/java</code>) works, but the weaving of this same aspect into <code>TestService</code> (under <code>src/test/java</code>) doesn't.</p>
  
  <p>I am new to Groovy, Gradle and AspectJ and didn't figure out if I should add some <code>testAspectpath</code> configuration or similar?</p>
  
  <p>EDIT1: seems unrelated, but iajc gives a warning:</p>
  
  <p><code>...
  :compileTestAspect
  [ant:iajc] [warning] incorrect classpath: [...]\gradle-aspectj-poc\build\resources\main
  ...
  </code></p>
  
  <p>EDIT2: I naively added this code to the Gradle dependencies:</p>
  
  <pre><code>ajInpath fileTree(dir: "src/test/java")
  aspectpath fileTree(dir: "src/test/java")
  testAjInpath fileTree(dir: "src/test/java")
  testAspectpath fileTree(dir: "src/test/java")
  </code></pre>
  
  <p>It doesn't help, the first test works and the second one fails as usual, with these new messages:</p>
  
  <p><code>...
  :compileAspect
  [ant:iajc] [warning] build config error: skipping missing, empty or corrupt aspectpath entry: [...]\gradle-aspectj-poc\src\test\java\com\hello\aop\TestService.java
  [ant:iajc] [warning] build config error: skipping missing, empty or corrupt inpath entry: [...]\gradle-aspectj-poc\src\test\java\com\hello\aop\TestService.java
  ...
  :compileTestAspect
  [ant:iajc] [warning] build config error: skipping missing, empty or corrupt aspectpath entry: [...]\gradle-aspectj-poc\src\test\java\com\hello\aop\TestService.java
  [ant:iajc] [warning] build config error: skipping missing, empty or corrupt inpath entry: [...]\gradle-aspectj-poc\src\test\java\com\hello\aop\TestService.java
  [ant:iajc] [warning] incorrect classpath: [...]\gradle-aspectj-poc\build\resources\main
  ...
  </code></p>