开发者

Is it possible to exclude classes/packages when depending on a JAR?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜