We have a Java webstart application and want to deploy/copy all third-party libraries into lib/ext/ and all of our project jar files into lib/ after the project has been built with Gradle.
Using this answer to a previous question I was able to almost accomplish this, except that my shared project libraries are copied both to lib/ and lib/ext/. However, they should only be copied to lib/.
Now I am looking for a way to exclude all shared project libraries from this task:
task copyDeps(type: Copy) {
from(subprojects.configurations.runtime)
into project.file('lib/ext')
}
I was trying to add something like exclude(subprojects.jar), but I don't know how I can get all subproject jars in a parameter which I could pass to exclude().
How can I accomplish this? I am also open to other suggestions on how to accomlish the main goal of copying the libraries to the above mentioned folders.
I have now solved my problem by remembering the names of the project jar files in copyJars
and then excluding them in copyDeps
:
List<String> projectLibs = new ArrayList<String>()
task copyJars(type: Copy, dependsOn: subprojects.jar) {
eachFile { fileCopyDetails ->
projectLibs.add(fileCopyDetails.name)
}
from(subprojects.jar)
into file('lib')
}
task copyDeps(type: Copy, dependsOn: copyJars) {
eachFile { fileCopyDetails ->
if (fileCopyDetails.name in projectLibs){
fileCopyDetails.exclude()
}
}
from (subprojects.configurations.runtime)
into file('lib/ext')
}
If somebody has a nicer solution I would be really happy to hear it :-)
Here is a shorter solution:
task copyDeps (type: Copy, dependsOn: subprojects.jar) {
from (subprojects.configurations.runtime) {
subprojects.jar.each { it.outputs.files.each { exclude it.getName() } }
}
into project.file('lib/ext')
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.