2016-11-08 98 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

相關問題