gradle:跳过任务':因为它没有源文件。并且不生成zip文件

时间:2015-08-04 17:06:22

标签: gradle build.gradle

我使用的是Gradle 1.4版本。我有以下任务。 'createWar'工作正常并生成所需的'war文件。 但'createServerPackage'不会生成我'zip'文件。 以下是我的build.gradle文件。有人可以帮我这个吗?

task createWar(type: War, dependsOn: syncConfiguration){
}
task createServerPackage(type: Zip) {
    description = "Creates the full server.zip package for distribution."
    dependsOn createWar

    String filesDirectory = 'upgradeFiles'

    from("${rootDir.absolutePath}/server/build/libs/adapter.war") {
        into(filesDirectory)
    }

    archiveName 'server.zip'
    destinationDir file(buildDir)
}

以下是编译gradle的片段。

 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':createWar'
 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :createWar UP-TO-DATE
 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :createServerPackage
 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':createServerPackage'
 [INFO] [org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter] Skipping task ':createServerPackage' as it has no source files.
 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':createServerPackage'
 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :createServerPackage UP-TO-DATE

1 个答案:

答案 0 :(得分:1)

没有必要自己构建war路径。以下是应该如何做的:

apply plugin: 'war'

task createWar(type: War)

task createServerPackage(type: Zip) {
    description = "Creates the full server.zip package for distribution."
    dependsOn createWar

    String filesDirectory = 'upgradeFiles'

    from(createWar.outputs) {
        into(filesDirectory)
    }

    archiveName 'server.zip'
    destinationDir file(buildDir)
}

可以找到演示here