10
votes

I have a single Git repository that contains several Maven modules, using Maven inheritance and Maven aggregation. That is, in the root directory, there is a parent POM, that defines some modules, each of which use that root POM as their parent.

<project>
  …
  <groupId>io.example</groupId>
  <artifactId>parent</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <packaging>pom</packaging>
  …
  <scm>
    <connection>scm:git:https://bitbucket.org/example/foobar.git</connection>
    <developerConnection>scm:git:https://bitbucket.org/example/foobar.git</developerConnection>
    <url>https://bitbucket.org/example/foobar</url>
  </scm>
  …
  <modules>
    <module>foo</module>
    <module>bar</module>
  </modules>
  …

I recently found out that Maven will append the module path to the <scm><url> value for each module (foo and bar above). For example, the foo submodule would get an SCM URL of https://bitbucket.org/example/foobar/foo.

So should each of my modules redeclare the <scm> section, so that the submodule POMs have the same SCM URL as the parent POM? How does the Nexus Staging Maven Plugin use this SCM information, anyway?

I have also cross-posted this at Sonatype.

1
Simple answer: Only define the scm information in the root module of your modules. Furthermore as far as I know the nexus-stating-maven-plugin does not use the scm information for deployment cause each artifact in your build has it's own groupId/artifactId/versions ... - khmarbaise
"Only define the scm information in the root module of your modules." Great! Can you provide an authoritative reference on that, or any indication others agree with you? "[A]s far as I know..." The purpose of this ticket was to get something more definitive. :) If you find some documentation or something, let me know, thanks. - Garret Wilson
You can check the "Performing a Release Deployment" section of the SonaType documentation at central.sonatype.org/pages/… which says "...This process is completely independent from your workflow with your SCM system. If you want to ensure that a specific version in the Central Repository corresponds to a specific revisions in your SCM system, which is a good practice, you can either perform the commits manually in a flow similar to...or you can automate it with a script...or you can use the Maven release plugin" - brunocrt
I found some related discussion at stackoverflow.com/q/20513744/421049 . See answers such as stackoverflow.com/a/48492290/421049 . - Garret Wilson
"Only define the scm information in the root module of your modules." @khmarbaise Please explain this. If each subproject is published to Maven Central as a separate JAR, it will have erroneous SCM information information in its POM. And if " the nexus-stating-maven-plugin does not use the scm information for deployment", then why does Sonatype require the SCM information to be present? - Garret Wilson

1 Answers

0
votes

Regarding your initial question in the title: It does not use it given the code provided at github. When you search for 'scm' in all .java files you have zero hits. Of course they could do some weird tricks like building the String like "s" + "c" + "m" or it is hidden in some third party dependency or... Still I think besides an offical answer, this is the best any outsider can tell.