Note that there are some explanatory texts on larger screens.

plurals
  1. POMaven naming conventions for hierarchical multiple module projects
    primarykey
    data
    text
    <p>I've got a question on Maven naming conventions (groupId, artifactId and directory names) in a multiple module project with a hierarchical directory structrure.</p> <h1>Research</h1> <p>Before asking, I went through other the web on this topic and what I cleared out for myself:</p> <ol> <li><p><a href="https://stackoverflow.com/questions/3150003/naming-convention-for-maven-artifacts">Possible duplication for my question, but it does not cover multiple-hierarchy levels.</a></p></li> <li><p><a href="https://stackoverflow.com/a/3725917/685962">Project directory name should match artificatId</a>.</p></li> <li><p><a href="http://maven.apache.org/guides/mini/guide-naming-conventions.html" rel="nofollow noreferrer">Guide to Naming Conventions</a> provide examples:</p> <ul> <li><p><strong>groupId</strong> will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules (eg. org.apache.maven, org.apache.commons, org.apache.maven.plugins)</p></li> <li><p><strong>artifactId</strong> If you created it then you can choose whatever name you want with lowercase letters and no strange symbols. (eg. maven, commons-math)</p></li> </ul></li> </ol> <p>This is quite straightforward and I understand it, but there are few things that are still unclear.</p> <p><strong>artifactId</strong> examples mentioned in conventions can be applied only to one-level hierarchy module. </p> <h1>Examples</h1> <p>I went through maven repositories and extracted some examples:</p> <p><a href="http://mvnrepository.com/artifact/org.springframework" rel="nofollow noreferrer">Spring</a> mostly uses names: spring-core, spring-context, spring-context-support. All standalone modules are one-level hierarchy and spring- prefix for search efficiency. There are no problems, since hierarchy is not that deep.</p> <p><a href="http://mvnrepository.com/artifact/org.apache.cxf" rel="nofollow noreferrer">Apache CXF</a> namings are quite unconventional for Apache. Artifacts are standalone modules with up to 5 possible different artifacts in names eg. cxf-tools-wsdlto-databinding-jaxb. </p> <p>There are lots of artifacts (cxf-rt-databinding-jaxb, cxf-rt-databinding-aegis, cxf-rt-databinding-xmlbeans, cxf-rt-databinding-sdo) which could be grouped in multiple module project (cxf-rt-databindings), but they didn't and so the names became spaghetti.</p> <p>Finally, <a href="http://mvnrepository.com/artifact/org.apache.maven.plugins" rel="nofollow noreferrer">Maven Plugins</a> is first a multiple module project (after org.apache.maven) which has artifacts like: maven-compiler-plugin, maven-enforcer-plugin.</p> <p>There are quite a lot of examples and the all follow different <em>conventions</em> on naming artifactIds (consequently project directories).</p> <h1>Outcome</h1> <p>Taking best practices from the examples let us review hierarchy levels.</p> <p>One-level hierarchy naming would be (</p> <pre><code>groupId: org.organization.project artifactId: project-portal ---. | project-portal-service | project-portal-plugins (continued on next diagram) | project-portal-util </code></pre> <p>(continued) two-level hierarchy would be:</p> <pre><code>groupId: org.organization.project.plugins artifactId: project-portal-plugins ---. | project-sample-plugin | project-another-great-plugin | ???? (multiple module project) </code></pre> <p>You see question marks? Thats where the</p> <h1>Questions</h1> <p>I followed conventions from examples (ignoring spaghetti Apache CXF example):</p> <ul> <li>Root - project-portal (eg. spring-core, maven-core) </li> <li>First-level hierarchy names inherit from root - project-portal-plugins (eg. spring-context-support).</li> <li>Second-level hierarchy names - project-sample-plugin (eg. maven-compiler-plugin).</li> </ul> <p>And now we are stuck on third-level, like in old games without saves and checkpoints.</p> <ol> <li>Is this the right directory naming path taken from Maven examples for deeper hierarchy levels?</li> <li>Are there any conventions or rules you follow to support simple directory and artifact names avoiding spaghetti names on deeper levels?</li> <li>If there are simple names, will groupId save duplicated artifact names (which will occur due to simplicity) from collisions in repository?</li> <li>What about searching and finding artifacts on web/repositories with duplicated names (due to simplicity)?</li> </ol> <p>I don't want to see in my project structure a module like project-portal-liferay-plugins-themes for parent or even worse project-portal-liferay-plugins-themes-white-puppy-wtf-name for children.</p> <p>If you could provide your opinion and practice for any of mentioned questions and possible problems, that would be a great help not only for me, but and for everyone using maven. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload