SCM URL relative to source SCM URL in POM

I have a Maven project consisting of several modules and submodules. I use SVN for the version of the source files.

Story

How to specify the URL in the scm properties of the POM file that are related to the parents.

Long story

Some modules and their auxiliary modules have a common version / release number, and some use independent ones. For a module with an independent version number, I configured the layout of the branches / trunk / tags so that the release plugin is happy.

For this, I have two SVN layouts in my repository. One of them holds all the messes of the connecting lines / branches / tags, and the other contains a clean working directory, ready to be checked, with svn: external links to the connecting lines.

It looks like this: You have a real-world SVN layout, with a mess in the trunk / branches / tags:

  • pom.xml (primary parent)
  • Utils
    • branches
    • tags
    • Trunk
      • pom.xml, src, target, etc.
  • data model (released)
    • branches
    • tags
    • Trunk
      • pom.xml
      • Lib
        • pom.xml, src, target, etc.
      • server
        • pom.xml, src, target, etc.
      • client
        • pom.xml, src, target, etc.
  • bin modules
    • bin-module-1 (released)
      • branches
      • tags
      • Trunk
        • pom.xml, src, target, etc.
    • bin-module-2 (released)
      • branches
      • tags
      • Trunk
        • pom.xml, src, target, etc.

And a clean working code layout separating branches / trunk with tags "svn: externals":

  • pom.xml (primary parent)
  • utils (-> utils / trunk)
    • pom.xml, src, target, etc.
  • data model (-> data model / trunk)
    • pom.xml
      • Lib
        • pom.xml, src, target, etc.
      • server
        • pom.xml, src, target, etc.
      • client
        • pom.xml, src, target, etc.
  • bin modules
    • pom.xml
    • bin-module-1 (-> bin-module-1 / trunk)
      • pom.xml, src, target, etc.
    • bin-module-2 (-> bin-module-2 / trunk)
      • pom.xml, src, target, etc.

So far so good. I set the SCM root URLs in my parent POM, and Maven correctly specifies the URLs for the submodules. I checked it with mvn help:effective-pom

I have the following scm urls:

  • root : [root-url]
  • utils : [root-url] / utils
  • data model : [root-url] / data-model /
  • data-model / lib : [root-url] / data-model / lib
  • data-model / client : [root-url] / data-model / client
  • data-model / server : [root-url] / data-model / server
  • bin-module-1 : [root-url] / bin-module-1 /
  • bin-module-2 : [root-url] / bin-module-2 /

But Maven is not aware of the actual layout of SVN. I would like him to see:

  • root : [root-url]
  • utils : [root-url] / utils / trunk
  • data model : [root-url] / data-model / trunk
  • data-model / lib : [root-url] / data-model / trunk / lib
  • data-model / client : [root-url] / data-model / trunk / client
  • data model / server : [root-url] / data-model / trunk / server
  • bin-module-1 : [root-url] / bin-module-1 / trunk
  • bin-module-2 : [root-url] / bin-module-2 / trunk

To do this, I need to add the scm section to the pom.xml data model, bin-module-1 and bin-module-2.

I tried something like (for a data model):

 <scm> <connection>./data-model/trunk</connection> <developerConnection>./sdr/trunk</developerConnection> <url>./sdr/trunk</url </scm> 

Or

 <scm> <connection>${project.parent.scm.connection}/data-model/trunk</connection> <developerConnection>${project.parent.scm.developerConnection}/data-model/trunk</developerConnection> <url>${project.parent.scm.url}/data-model/trunk</url> </scm> 

But nobody is working. The properties of $ {...} are not even replaced. So, how do I redefine the SCM path in relation to its SCM parent URL?

Any help, advice would be greatly appreciated.

Thanks in advance, Raphael

+6
version-control maven maven-2
source share
1 answer

I would think this works:

 <scm> <connection>${project.parent.scm.connection}/data-model/trunk</connection> <developerConnection>${project.parent.scm.developerConnection}/data-model/trunk</developerConnection> <url>${project.parent.scm.url}/data-model/trunk</url> </scm> 

If this is not the case, you can programmatically assign these values ​​(I will use GMaven to do this, but you can also use the antrun plugin or write your own plugin)

First set the property

 <properties> <relativeScmPath>data-model/trunk</relativeScmPath> </properties> 

Then assign the relative offset to all SCM properties:

 <plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>gmaven-plugin</artifactId> <version>1.3</version> <executions> <execution> <id>assign-scm</id> <phase>validate</phase> <goals> <goal>execute</goal> </goals> <configuration> <source> <![CDATA[ def parentScm = project.parent.scm; def thisScm = project.scm; def relPath = project.properties['relativeScmPath']; ['connection','developerConnection','url'].each{ thisScm[it] = parentScm[it] + relPath; } ]]> </source> </configuration> </execution> </executions> </plugin> 

You can add this to the root pump and change it so that it runs only if it finds a property, and then you can automatically set the value for n auxiliary modules by simply adding a property to them.

+5
source share

All Articles