跳过任务,因为它没有源文件

时间:2016-06-02 07:55:14

标签: gradle groovy

我有一个创建源代码zip的任务:

import org.gradle.api.tasks.bundling.Zip
import org.gradle.api.tasks.TaskAction

class MakeJavadocZipTask extends Zip{
@TaskAction
def makeJavadocZip(){

     doFirst {
     baseName = project.componentUtils.getComponentName()
     version = project.componentUtils.getComponentVersion()
     classifier = 'javadocs'
 }

 from "${project.buildDir}/docs/javadoc"
 include '**/*'
 destinationDir project.file("${project.tmpDistLoc}/javadocs")  
}

}

我跑步时的这个任务说明了日期。我也尝试使用project.afterEvaluate闭包,不起作用。任何解决方案

1 个答案:

答案 0 :(得分:1)

是的,这有效

class MakeJavadocZipTask extends Zip{
MakeJavadocZipTask(){
    doFirst {
        archiveName = project.componentUtils.getDistName('javadocs')
    }

    from "${project.buildDir}/docs/javadoc"
    include '**/*'
    destinationDir project.file("${project.tmpDistLoc}/javadocs")

}

}