我有两个配置 - 编译和存根 - 编译正如您所期望的那样,存根与编译完全相同,但它将替换编译中的依赖项(我隐藏了大多数依赖项):
configurations {
stub
stub.extendsFrom compile
stub.exclude module: "thelibrary"
}
dependencies {
compile(name: "thelibrary")
compile project(":lib:project")
stub files('./libs/thelibrary.jar')
}
当我执行'gradle build'时,会拉出所有依赖项并正确构建jar(大约需要25秒)。
问题是当我'gradle buildstub'(使用配置构建)时 - 没有依赖性被拉动,没有构建任何东西,就像它忽略了'stub.extendsFrom compile'(需要~3秒)。
我做错了什么?
更新1:
创建存根jar的任务(“thelibrary.jar”):
task StubJar(type: Jar){
manifest {
attributes 'Main-Class': 'com.XXXXXX.stub'
}
baseName = 'thelibrary'
from 'src/main/java/com/XXXXXX/stub'
}
Gradle buildstub的Gradle输出:
:lib:xxxxxxx:buildstub UP-TO-DATE
BUILD SUCCESSFUL
Total time: 6.741 secs