build.gradle中是否可以有多个war任务来生成具有不同依赖关系的多个war

时间:2015-08-09 07:21:58

标签: gradle

我正在尝试做类似的事情:Create multiple .WAR files with different dependencies in Gradle

但是这篇文章中给出的解决方案不起作用。我正在使用gradle 2.5来实现这一目标。

期望是生成3个不同的战争作为脚本的输出。我创建了一个具有最小依赖性的最简单项目。当我执行build.gradle时,它只给我一个名为:Test-1.0.war的战争。 Test是我创建的示例项目的名称。

这是build.gradle:

apply plugin: 'java'
apply plugin: 'war'

sourceCompatibility = 1.5
version = '1.0'

task createStandardWar(type: War, dependsOn: classes) {
    baseName = 'standard'
    destinationDir = file("$buildDir/libs")
    classifier = 'Functional'
}

task createStandardWarQasOnly(type: War, dependsOn: classes) {
    baseName = 'standard-qas-only'
    destinationDir = file("$buildDir/libs")
    classifier = 'Functional2'
}

task createStandardWarQasAndLog4J(type: War, dependsOn: classes) {
    baseName = 'standard-qas-log4j'
    destinationDir = file("$buildDir/libs")
    classifier = 'Functional3'
}

task createDists(dependsOn: [createStandardWar, createStandardWarQasOnly, createStandardWarQasAndLog4J])

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

test {
    systemProperties 'property': 'value'
}

0 个答案:

没有答案