How to override the default artifactId when the subproject has a "/" in the directory path

(N5NX) #1

I ran into the issue described in “”. I found that the “Unable to initialize POM pom-default.xml: Failed to validate POM for project” was because my directory structure is:


So, I have a settings.gradle file like this: = ‘e2am-parent’ include “mbean-common”, “webapps/e2am”, “assembly”

And the pom-default.xml that was generated by gradle when I do “gradle clean install” by default creates an artifactId of “webapps/e2am”:


and the ‘/’ is apparently not allowed (because if I remove it and do mvn help:effective-pom on the file, it croaks when the ‘/’ is there and succeeds when I remove the ‘/’)

How do I tell gradle to NOT use ‘webapps/e2am’ for the artifactId, i.e. how do I override the default artifactId name? I googled for “gradle override artifactId” but I can’t seem to find the right recipe…

I’m using the java plugin and the maven plugin so gradle ‘knows’ what “clean install” should do, and at this point I’m not uploading to an archive so the solutions that I found that related to uploading to an archive seem irrelevant.

Just seems odd that in a maven pom file I can specify groupId, ArtifactID, and version, but in a build.gradle I can’t control the artifactId name, just the group and version.

(N5NX) #2

I also asked over on Stack Overflow, this is the answer provided, I tested it, it works:

The section on Maven POM generation (52.6.4) at suggests that you should be able to solve the problem by setting project.archivesBaseName to the desired value, because the artifact id defaults to that.

(Peter Niederwieser) #3

Your ‘settings.gradle’ effectively declares a project name with a slash in it, which can cause problems in places where the project name is used as a default value (such as the Maven artifact ID). Instead, you should either use ‘include webapps:e2am’ (this gives an intermediary ‘webapps’ project), or use ‘include e2am’ and then further configure the project dir for that project.