[英]Copy all created & third-party jars into a single folder with Gradle
we have a multi-project gradle setup with one Java jar for each subproject: 我们有一个多项目gradle设置,每个子项目有一个Java jar:
- root-project
|-sub-project-a
|-sub-project-b
|-sub-project-c
Now, because we are creating a Java webstart application, we need to sign all project jars as well as all third-party libraries (dependencies). 现在,因为我们正在创建Java webstart应用程序,所以我们需要签署所有项目jar以及所有第三方库(依赖项)。
My approach was now to copy all built subproject jars and all third-party libraries into a seperate folder and execute a task for signing them. 我现在的方法是将所有已构建的子项目jar和所有第三方库复制到一个单独的文件夹中,并执行签名任务。 However I am not able to copy the jars. 但是我无法复制罐子。
This was my approach in the root build.gradle: 这是我在root build.gradle中的方法:
task copyFiles(type: Copy, dependsOn: subprojects.jar) {
from configurations.runtime
from("build/libs")
into("webstart/lib")
include('*.jar')
}
together with: 和...一起:
task signAll(dependsOn: [copyFiles]) << {
new File('webstart/signed').mkdirs()
def libFiles = files { file('webstart/lib').listFiles() }
...
}
Then I tried to execute gradle signAll. 然后我尝试执行gradle signAll。 However, I can only find an empty jar with the name of the root project in the webstart/lib folder. 但是,我只能在webstart / lib文件夹中找到一个带有根项目名称的空jar。
Maybe my approach is completely wrong. 也许我的方法是完全错误的。 What do I have to do to copy all created & thrid-party jars into a single folder? 如何将所有创建的和第三方派对复制到一个文件夹中?
Add this piece of code to root build.gradle and it should work fine: 将这段代码添加到root build.gradle中它应该可以正常工作:
allprojects {
apply plugin: 'java'
repositories {
mavenCentral()
}
}
task copyJars(type: Copy, dependsOn: subprojects.jar) {
from(subprojects.jar)
into project.file('dest')
}
task copyDeps(type: Copy) {
from(subprojects.configurations.runtime)
into project.file('dest/lib')
}
task copyFiles(dependsOn: [copyJars, copyDeps])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.