如何在gradle中为jar任务添加多个jar?

时间:2016-05-26 00:01:33

标签: java gradle

目前我有以下内容在project_name / build / libs

下生成jar
#Project A (build.gradle)
jar {
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    from sourceSets.test.output
    baseName = 'SDK'
    exclude 'META-INF/.RSA', 'META-INF/.SF','META-INF/*.DSA'
}

build.dependsOn(linkToBin)

这个Jar将由以下超类函数

收集
#MetaProject (build.gradle)
task linkToBin(dependsOn: jar) {
    doLast{
        File installDir = new File(rootProject.projectDir.getPath() + "/bin")
        installDir.mkdirs()
        configurations.testRuntime.allArtifacts.files.forEach {
            Path targetPath = Paths.get(installDir.getPath() + '/' + it.getName())
            if(new File(targetPath.toString()).exists())
               Files.delete(targetPath)
            Files.createSymbolicLink(targetPath, Paths.get(it.getPath()))
        }
    }
}

Driectory Structure如下

MetaProject(具有自己的build.gradle的目录) - >项目A(具有自己的build.gradle的子目录)

我希望能够在项目A中创建多个罐子,我希望所有罐子都像上面那样在MetaProject / bin中结束?

0 个答案:

没有答案