使用exec时,为什么没有gradle任务显示组或描述?

时间:2016-11-08 09:38:07

标签: android shell android-gradle build.gradle

我的Gradle任务已停止在group中显示description./gradlew tasks,因为我已在根exec {}中添加了build.gradle

发生了什么,我该如何取回?

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

其他一切都有效。

1 个答案:

答案 0 :(得分:2)

您无法在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'
        }
    }
}