简体   繁体   English

使用Gradle将所有创建的和第三方jar复制到一个文件夹中

[英]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.

相关问题 Gradle Compile &amp; Execute the Single Java Class with third-party jar dependencies using Gradle `buildscript` - Gradle Compile & Execute the Single Java Class with third-party jar dependencies using Gradle `buildscript` 如何调试第三方Gradle插件? - How to debug a third-party Gradle plugin? 如何使用配置类中的第三方实现来管理JAR? - How to manage JARs with third-party implementations in configuration classes? 在哪里可以找到Spring导入的第三方jar代码 - Where to find the third-party jars imported by spring source code 从单个源文件夹中抓取多个罐子 - Gradle multiple jars from single source folder Maven 在构建我们自己的 custom.jar 时发布和使用第三方运行时 jar - Maven publish & consume the third-party runtime jars while building our own custom.jar 如何防止classpath上的第三方JAR覆盖我的类依赖关系? - How to prevent third-party JARs on the classpath from overriding my class dependencies? 如何报告JVM中的所有异常,无论是自己的代码还是第三方代码? - How to report all exceptions in JVM, be it own or third-party code? Java - 如何减小第三方jar的大小以减小应用程序的大小 - Java - How to reduce the size of third-party jars to reduce the size of your application 无法在 build.gradle 以外的 gradle 文件中导入第三方类 - Could not import third-party class in gradle file other than build.gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM