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: https://github.com/sedubois/gradle-aspectj-poc/tree/dc44f529831a485fcff8f4889dba8098784dddb4
The weaving of UnsupportedOperationAspect
into MainSevice
(both under src/main/java
) works, but the weaving of this same aspect into TestService
(under src/test/java
) doesn't.
I am new to Groovy, Gradle and AspectJ and didn't figure out if I should add some testAspectpath
configuration or similar?
EDIT1: seems unrelated, but iajc gives a warning:
...
:compileTestAspect
[ant:iajc] [warning] incorrect classpath: [...]\gradle-aspectj-poc\build\resources\main
...
EDIT2: I naively added this code to the Gradle dependencies:
ajInpath fileTree(dir: "src/test/java")
aspectpath fileTree(dir: "src/test/java")
testAjInpath fileTree(dir: "src/test/java")
testAspectpath fileTree(dir: "src/test/java")
It doesn't help, the first test works and the second one fails as usual, with these new messages:
...
: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
...