Best practice to call own generators in gradle build


(Markus Oley) #1

Hi to all,

we have migrated our ant build to gradle, building with gradle for quite some time.
We are calling own generator tasks, which was realized by creating a new classloader with all urls from compile classpath and call the generator via reflection. This leads to some classloader leaks (log4j, guava, guice to name only some). We are now re-thinking how we should do this in the future to get the daemon running…

Solution 1: Move the generator to the buildscript classpath (We also have deps to guava, jaxb, xtext, guice…which can interact with gradle’s own classpath?)
Solution 2: Fork a new java process with project.javaExec() per generator call (classpath length on windows might be too long?)

So my question is, what is from gradle and gradleware point of view the way to go (the way to expect least problems and to be most standards-compliant.

Would be nice if you can give me a direction.
Cheers
Markus


(Schalk Cronjé) #2

Solution 2 is safe, but possibly not ideal. An alternative is to use the worker API.

(Apologies for being terse. I am on mobile so do not have ability for elaborate example).


(Markus Oley) #3

@Schalk_Cronje
Thanks for your answer, I think I will take a look at it…