我的根项目 build.gradle
文件中有以下 allprojects 指令:
allprojects {
dependencies {
testCompile("junit:junit:${junitVersion}")
}
jar {
baseName = project.archivesBaseName
from files(project.subprojects.sourceSets.main.output)
manifest {
attributes(
"Created-By": vendor,
"Specification-Title": jar.archiveName,
"Specification-Version": version,
"Specification-Vendor": vendor,
"Implementation-Title": jar.baseName,
"Implementation-Version" : version,
"Implementation-Vendor": vendor,
)
}
}
}
在每个子项目中,我都会在其 build.gradle
中重新定义 archiveBaseName
,但我所有的 JAR 存档都是使用该项目的 baseName
生成的。根项目的 archiveBaseName
。
有没有办法根据我对 archiveBaseName
的覆盖来动态创建我的文件名称?
最佳答案
在评估 allprojects
闭包时,尚未评估子项目构建脚本,因此您看不到覆盖的值,而是看到原始值。
您必须延迟使用 afterEvaluate
执行的 Jar
任务的配置。
关于java - Gradle 3.5 如何在 allproject 中从 archiveBaseName 设置 jar baseName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44512438/