I'm working through the exercises in Beginning Java EE 7 except I'm trying to adapt them to use Gradle instead of Maven. For the chapter 2 interceptor exercise, I wrote this build.gradle:
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.5', 'org.jboss.weld.se:weld-se-core:2.2.10.Final'
testCompile "junit:junit:4.11"
}
jar {
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest {
attributes 'Main-Class': 'org.agoncal.book.javaee7.chapter02.Main'
}
}
I'm just using the src dir directly from the author's GitHub. ./gradlew -x test build
succeeds and then java -jar build/libs/gradleTest.jar
gives the expected output (although it also spits out a lot of unexpected warnings). ./gradlew test
however fails with this error:
org.jboss.weld.exceptions.DeploymentException: WELD-001417: Enabled interceptor class <class>org.agoncal.book.javaee7.chapter02.LoggingInterceptor</class> in file:/home/allen/gradleTest/build/resources/main/META-INF/beans.xml@7 does not match an interceptor bean: the class is not found, or not annotated with @Interceptor and still not registered through a portable extension, or not annotated with @Dependent inside an implicit bean archive
The beans.xml and all the class files are straight from the author's repo on GitHub and appear to be exactly as the above error says they're not. The beans.xml declares the interceptor, and the interceptor class is annotated with @Interceptor.
My guess is that the problem lies with my gradle build. Does anyone see what the problem is?