Dual Groovy project compilation for indy and without indy

I am trying to come up with a solution to simultaneously (not necessarily in parallel) compile my Groovy project with invokedynamic (indy) enabled and without it enabled. The goal is that I can automatically have the jar without invokedynamic support created with a classifier (noindy). I currently have a build that creates the indy-compatible jar, but I am stuck trying to cleanly create the noindy jar from the same build (it’s super easy to clone and run them separately, but I would prefer to not do that) so that the jar can be deployed when I publish it.

I assume that I need a new configuration that partially depends on the default configuration, with the exception of the compile phase (where I have to specify the default Groovy jar rather than the Groovy-indy jar), but from there I am stuck. How do I link the configuration with a second jar being created, and therefore take control of its Groovy compilation and build its jar?

It would be ideal to also be able to run tests against the noindy version of the compilation (the exact same tests).

Maybe it’s simpler to just create a subproject that the main project kicks off to build the noindy jar, then adds that jar to its own artifact list? I don’t plan on maintaining the noindy jar forever, so that would make it the easiest to remove.

I have gone the route of creating a subproject, which seemed like a much lower bar to jump and it has the added benefit that it’s significantly easier to remove.

I am only currently stuck on how to get the archive(s) from the subproject as part of the root project. I’m probably missing something obvious here.

‘’’ /**

  • Extra artifacts to publish along side the client jar.

*/ artifacts {

archives sourcesJar

archives project(’:noindy’).archives } ‘’’

Ah, it was sleepiness. I only needed to reference the jar task after evaluating the subproject.

evaluationDependsOn(’:noindy’)

/**

  • Extra artifacts to publish along side the client jar.

*/

artifacts {

archives sourcesJar

archives project(’:noindy’).tasks[‘jar’]

}

This works well!

For anyone interested, you can find my build files that make this happen here: