我有包含多个组件/JAR 的多项目脚本。 每个子脚本/项目定义组件标题:
ext {
componentTitle = 'Application1'
}
apply from: '../war/gradle/component.gradle'
共享代码在component.gradle中:
apply plugin: 'java'
jar {
manifest {
attributes 'Implementation-Title': componentTitle }
}
我收到错误:
评估脚本时出现问题。
The value of a manifest attribute must not be null.
这意味着在评估子脚本时尚未定义 componentTitle。 componentTitle 定义位于“apply from”语句之前。
最佳答案
应用的脚本在 apply from: ...
处准确评估(通过添加一些 println
即可轻松确认)。一定还有其他问题。您可以尝试的一件事是将 'Implementation-Title': componentTitle
替换为 'Implementation-Title': project.componentTitle
,尽管它应该没有什么区别。
关于Gradle: "apply from"在脚本的其余部分之前被评估?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20764748/