3

Lets say I have an Android Studio project and JAR x.jar which I include in my build.gradle:

compile files('libs/x.jar')

How can I tell Gradle to not include the package xyz in the x.jar? Is there something like:

compile files('libs/x.jar'){
    exclude: "xyz"
}

Or is this not possible for a jar which I can't build myself (and exclude the sources while building the jar)?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Simon
  • 13,173
  • 14
  • 66
  • 90
  • I think you should be able to unjar it and rebuild ? (jar -xvf lib.jar ) – Shivam Verma Feb 24 '15 at 14:14
  • Or : http://stackoverflow.com/a/19581593/1239966 – Shivam Verma Feb 24 '15 at 14:15
  • 1
    @ShivamVerma doesn't this solution only work for code you created yourself? So before you compile the code as a jar you exclude parts of it but that does not work in the case of an already existing jar – Simon Feb 24 '15 at 14:44
  • `jar -xvf` lets you unjar, then you can select the parts of code that you want to create and then `jar cfm jar-file manifest-addition input-file(s)` – Shivam Verma Feb 24 '15 at 14:50

1 Answers1

1

Gradle does not directly support a feature like this. Your only solution would be to create a task that generates a new jar and add this to your compile configuration.

cmcginty
  • 113,384
  • 42
  • 163
  • 163