成绩:如何从公共存储库中的jar中排除某些java类?
例如,存储库中的foo.jar取决于bar1.jar,bar2.jar
foo.jar
bar1.jar
bar2.jar
从foo.jar中删除“javax / **”,将其添加到runtimeOnly配置中
dependencies {
runtimeOnly foo-changed.jar, bar1.jar, bar2.jar
}
尝试
configurations {
changeFoo
}
dependencies {
changeFoo "group:foo:1.0" // contains foo.jar, bar1.jar, bar2.jar
}
task changeFoo(type: Jar) {
def jarFile = configurations.changeFoo.singleFile // error: more than one file
from zipTree(jarFile) {
exclude 'javax/**'
}
destinationDir project.libsDir
archiveName "foo-changed.jar"
}
如何获取单个文件(foo.jar)? 如何使用foo-changed.jar替换configurations.changeFoo中的foo.jar?
dependencies {
runtimeOnly.extendsFrom changeFoo
}
答案 0 :(得分:0)
尝试这样的事情。
configurations.changeFoo.asFileTree.each {
from(zipTree(it))
exclude ''
}
destinationDir project.libsDir
archiveName "foo-changed.jar"