gpt4 book ai didi

gradle - 如何在 buildFinished 中使用 commandLine()

转载 作者:行者123 更新时间:2023-12-03 05:26:24 27 4
gpt4 key购买 nike

$HOME/.gradle/init.gradle我有:

gradle.buildFinished { buildResult ->
commandLine 'bash', "blah blah blah"
}

gradle build构建成功,但成功后出现错误:

Could not find method commandLine() for arguments [bash, blah blah blah] on build 'FooBar' of type org.gradle.invocation.DefaultGradle.



问题的答案 Could not find method commandLine()也无济于事 (type: Exec)gradle.buildFinished 之后或将整个内容包裹在 exec { } 中导致 Gradle 从一开始就失败,而不是构建成功,然后我的构建后 Hook 失败。

我正在使用 Gradle 6.3 版

最佳答案

您配置错误 commandLine .与以下build.gradle :

task lol {
doLast {
println "lol"
}
}

~/.gradle/init.gradle :
gradle.buildFinished { buildResult ->
exec {
commandLine 'bash', '-c', 'echo lol2'
}
}

它按预期工作。

关于gradle - 如何在 buildFinished 中使用 commandLine(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61112034/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com