在gradle中使用Application和Distribution插件

时间:2015-01-26 14:50:25

标签: gradle build.gradle

使用distributions插件时,我有以下代码,以便在分发输出中设置文件夹结构。

但是现在我必须使用'application'插件 1.这两个插件可以一起使用吗? (抱怨名字相同的任务)
2.如果没有,如何为应用程序插件实现以下代码?

distributions {
    main {
        baseName = appName
        contents {
            into('bin') { from jar.archivePath }
            into('lib') { from configurations.runtime }
            into('etc') { from project(':server').file('src/main/other') }
        }
    }
}

1 个答案:

答案 0 :(得分:1)

在评论中讨论后,以下代码应该有所帮助:

applicationDistribution.from(jar.archivePath) {
    into "bin"
}
applicationDistribution.from(configurations.runtime ) {
    into "lib"
}
applicationDistribution.from(project(':server').file('src/main/other')) {
    into "etc"
}

或(可能)较短的形式(无法验证)

with(applicationDistribution) {
   from(jar.archivePath) { into "bin" }
   from(configurations.runtime ) { into "lib" }
   from(project(':server').file('src/main/other')) { into "etc" }
}

正如已经提到的:不知道究竟是什么是baseName,但是假设它也可以设置。

相关问题