我正在使用Gradle 4.6,它允许我使用以下命令运行build scans
--scan
选项,而无需显式应用或下载 额外的插件,很棒。但是,这迫使我添加buildScan
已在我的build.gradle文件中接受服务条款。
像这样:
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
随后我在没有
gradle build
选项的情况下运行--scan
时, 收到以下错误消息:> Could not find method buildScan() for arguments…
我不想每次都不必修改build.gradle文件 想要/不想扫描。我不想明确地应用插件 (防火墙问题),而我没有机会接受以下条款: 我也看到了在命令行上的服务记录。
有人可以告诉我我在做什么错吗?
此问题的格式类似于引号,因为已经在Gradle Forums上提出了此问题。但这没有答案。我正在使用Gradle 4.10.2,问题仍然存在。我决定在这里提请更多关注此问题。
答案 0 :(得分:7)
只需测试buildScan
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
答案 1 :(得分:0)
这可能不是一个好的解决方案,但这是一种解决方法:使用try
/ catch
吞下该错误,例如:
try {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
} catch (MissingMethodException e){
// This isn't the exception you're looking for
}
答案 2 :(得分:0)