我的根项目 build.gradle文件中有以下指令:
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档案都是用根项目的archiveBaseName的baseName生成的。
是否有一种方法可以基于对archiveBaseName的重写来动态创建我的档案名称?
发布于 2017-06-13 07:06:16
在计算allprojects闭包时,尚未对子项目构建脚本进行评估,因此您不会看到覆盖的值而是原始值。
您必须延迟正在使用Jar进行的afterEvaluate任务的配置。
https://stackoverflow.com/questions/44512438
复制相似问题