Dependend on an alternate configuration of another project, while excluding the primary configuration


(Kyle Mahan) #1

Hi all,

gist.github.com/kylewm/6298171 illustrates the problem I am having.

I’m attempting to create a project that has artifacts representing a primary and an alternate configuration (a trial version). The trial jar contains almost all the same code as the primary jar with only a few classes modified… and the two should carry the same transitive dependencies.

The problem is that when I depend on the alternateArchives configuration from another project in the same build, it actually grabs both jars: the primary and the alternate. So that is to say, I would like the command at the bottom of my example to return only ‘core-alternate.jar’ rather than ‘core.jar’ and ‘core-alternate.jar’

I am pretty sure this is because the primary jar is actually associated with the ‘runtime’ configuration which alternateRuntime extendsFrom, but I could not figure out to get all of the primary’s runtime dependencies without getting the primary’s artifact too.

Thanks! Kyle


(Peter Niederwieser) #2

If you need “common” compile/runtime/etc. configurations, you can declare ‘commonCompile’/‘commonRuntime’/etc. and make the configurations for the main and alternate source sets extend the common ones.

Always try to only pull in what’s needed, rather than trying to get rid of the unneeded later (which can be difficult).


(Kyle Mahan) #3

Thanks Peter! That makes sense and works great.