Reputation: 2931
I'm trying to convert a Grails 2 plugin to Grails 3 and I have trouble excluding a couple of domain classes that are used in tests only from the resulting jar.
The documentation states:
in your build.gradle you should exclude the compiled classes from the JAR file:
jar {
exclude "com/demo/**/**"
}
...but if I try this I get the following error from Gradle:
Could not find method jar() for arguments [build_64zizslf5a7zfo329yz5tdsoi$_run_closure1@566c53c] on root project '...'
I can post the entire stack trace but it doesn't look very helpful. I'm using Gradle 2.3, provided by the default Gradle wrapper that the create-plugin
command generates. I also haven't made any other changes to build.gradle
because my plugin doesn't require any external dependencies.
Upvotes: 2
Views: 1576
Reputation: 27255
See the project at https://github.com/jeffbrown/excludesdemo. That includes 2 domain classes under https://github.com/jeffbrown/excludesdemo/tree/master/grails-app/domain.
The top level build.gradle
file at https://github.com/jeffbrown/excludesdemo/blob/72896a3f88f617d530bbdde8976d5bfe8d1e820a/build.gradle#L73 contains the following:
jar {
exclude 'package1/**'
}
When you run ./gradlew jar
you should see that the jar file generated at build/libs/excludesdemo-0.1-SNAPSHOT.jar
does contain package2/Author.class
and does not contain package1/Person.class
.
Upvotes: 2