2016-11-08 65 views
0

我的Gradle任务停止显示groupdescription in ./gradlew tasks,因为我在根build.gradle中添加了exec {}使用exec时,为什么gradle任务不显示组或描述?

怎么回事,我该如何恢复?

task doSomething << { 
    group 'yourGroupName' 
    description 'Runs your bash script' 
    exec { 
     workingDir "$projectDir/../pathto/" 
     commandLine 'bash', '-c', './bashscript.sh' 
    } 
} 

其他一切作品。

回答

1

您不能配置组和说明在doLast()封闭

这个代码

task doSomething << { 
    exec { 
     workingDir "$projectDir/../pathto/" 
     commandLine 'bash', '-c', './bashscript.sh' 
    } 
} 

task doSomething { 
    doLast { 
     exec { 
      workingDir "$projectDir/../pathto/" 
      commandLine 'bash', '-c', './bashscript.sh' 
     } 
    } 
} 

在同一以下groupdescription不考虑

task doSomething { 
    doLast { 
     group 'yourGroupName' 
     description 'Runs your bash script' 
     exec { 
      workingDir "$projectDir/../pathto/" 
      commandLine 'bash', '-c', './bashscript.sh' 
     } 
    } 
} 

但是在这里:

task doSomething { 
    group 'yourGroupName' 
    description 'Runs your bash script' 

    doLast { 
     exec { 
      workingDir "$projectDir/../pathto/" 
      commandLine 'bash', '-c', './bashscript.sh' 
     } 
    } 
} 
+0

哎呀,这些Gradle'isms ......这做到了。 – not2qubit

相关问题