Reputation: 12061
I am trying zip the contents in the module, exclude the builds folder but it is not running. I do println
outside the task and that works but nothing will print inside the task.
task fullZip(type: Zip) {
baseName = 'client' //name of the module
from 'client' //name of the module
exclude 'build'
into '../docker/client'
doFirst { println 'before zip' }
doLast { println 'after zip' }
}
This is a multi module project and I have ran gradle clean build
and gradle build
The other modules work just fine but their task is to copy a jar and I use assemble.dependsOn
at the end of those tasks. That will not work in this case.
I just want to zip up the module and move it to a different directory where I will unzip it.
Upvotes: 0
Views: 1179
Reputation: 14523
Summary from chat discussion:
task fullZip(type: Zip) {
baseName = 'client'
from projectDir
exclude 'build'
destinationDir = file('../docker/client')
}
build.dependsOn fullZip
The main problem was the relative path in the from
parameter, which did work because is is interpreted relative to the project directory.
Also, according to the docs, the into
method ...
Specifies the destination directory inside the archive for the files. The destination is evaluated as per
Project.file(java.lang.Object)
. Don't mix it up withAbstractArchiveTask.getDestinationDir()
which specifies the output directory for the archive.
Those two methods were mixed up. Finally, the task was added to the build lifecycle via a task dependency registration.
Upvotes: 1