Multiple sub projects with the same name should be fine so long as their path is unique. However, in this case if you are building a war, you can’t obviously have multiple files in your ‘lib’ directory with the same name. If the naming scheme of your JARs is simply name-version.jar then clearly you will be trying to put two common-version.jar files in your ‘lib’ dir.
yeah so the 2 common subs do indeed have unique fully qualified gradle paths.
And both of the commons sub-projects actually make jars with really different names (i.e. i have unique ‘archivesBaseName’ set in both)
Having said this, running ‘gradle dependencies’ in the war the resulting output comes right out says it is subing one common for the other.
It even prints the FQ gradle path while stating that it is substituting.
So even if there was an assembly time collision of files going into WEB-INF/lib, I would have expected gradle to not perform a substitution evaluating the dependency.
As soon as the ics/demand/jar gets renamed into ics/demand/common-jar the build goes through.
Please also note in the directory structure above we had to use savingscommon-jar instead of plain jar because of similar dependency issue (and compilation error) with a project in the ics/savings folder
And, of course settings.gradle file lists all the projects needed in the absolute format (e.g., :ics:demand:war)
So the problem is there – but during the forum exchange we had earlier – I began to wonder if the group value was part of the ingredients used during dependency evaluation.
We publish to a private nexus and our artifacts belong to the same group (or so was the plan).
You’ll see our sample root build, sets that group for all subs.
Comment this line out, everything is OK; leave it in – that is when the chaos begins.
As you see, each build does make a distinct artifact jar file.
So maybe the inferred sub-project name (at leaf) + the group name is not unique and that is cause the substitution issue???
Not clear if this is the right or wrong thing for gradle to do, but it is unexpected.
Fred, is correct. This is indeed what seems to be happening. Internally Gradle is using group + name to determine that a particular module is unique. In this case, if all your subproject share a group then you will have to give them a unique name, simply making the jar name unique is not sufficient.
I’m not sure it is necessarily either of those things. The main motivation behind this is for compatibility when publishing. Since project dependencies get converted to module dependencies in generated pom files, we internally key off group:name since that will be the value in the pom.