Reputation: 29507
Currently my Gradle build produces a fat JAR (via ShadowJar Plugin) under build/distributions
via the following build invocation:
gradle clean build shadowJar
I now need that same exact build invocation to copy src/main/resources/myconfig.json
to build/distributions
as well. I followed the Gradle docs and added the following to my build:
task copyConfig(type: Copy) {
into 'build/distributions'
from('src/main/resources') {
include '**/*.json'
}
}
However running gradle clean build shadowJar
doesn't produce a build/distributions/myconfig.json
as expected. What can I do to keep the build invocation exactly the same, but to invoke the copyConfig
task (also, I'm not even 100% sure that task is error-free)?
Upvotes: 1
Views: 822
Reputation: 691745
You have created a task, but you never execute it. In order for this task to be invoked when executing build or shadowJar, one of these tasks needs to depend on the task you created:
build.dependsOn copyConfig
or
shadowJar.dependsOn copyConfig
Upvotes: 2