I need to depend on a JAR file that contains the entire JUnit 3 package, but I bundle JUnit 4 separately with my project. Hence, my test break because they are executed using the JUnit 3 runner, when they should instead be run using the JUnit 4 runner.
The question is: can I tell Gradle to not include certain classes or entire packages from a JAR when depending on it?
UPDATE It worked using the suggested zipTree/copy solution:
task processAndroidJar(type: Copy) {
from zipTree("$androidHome/platforms/android-8/android.jar")
into "$buildDir/android"
exclude "junit/**"
}
compileJava.dependsOn processAndroidJar
dependencies {
comp开发者_开发问答ile files("$buildDir/android")
}
Works beautifully.
You can try to depend on jar file as a ZipTree
ZipTree
allows you to include/exclude different paths within archive in your dependency
精彩评论