Additional jars per task?


(Wujek Srujek) #1

It is possible to define additional jars for the build script (and the init script, for that matter). However, I couldn’t find the option to define jars per task - is that possible? The use case is: suppose one has two tasks that both require some library (say, asm, in my case) but in different versions. If they are defined for the whole script, this wouldn’t work, right? Is there a solution to that?

As a side question - how did you implement the functionality to import additional jars within the buildScript closure, but import the classes outside of it? How does that work, what magic are you using to compile that?

wujek


(Wujek Srujek) #2

Bump.


(Peter Niederwieser) #3

Using different versions of a library might work when they are used from different build scripts or script plugins (you’d have to try). Gradle doesn’t have a generic feature that allows to have a separate class path per task, but you could implement your own solution based on class loaders or forking a new process.

The buildscript magic is not something you can leverage for your own needs.


(Wujek Srujek) #4

I will try, thanks.

Can you just sketch the concept? I don’t want to reuse it, I would just like to know so that I am smarter ;d