Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven SCM URL relative to the parent

Tags:

svn

maven

We have the following project structure in SVN with a parent (not aggregator) project defining common configuration. The parent is individually managed and released.

trunk
    +parent
        pom.xml
    +project1
        pom.xml
        +project1_1
            pom.xml
        +project1_2
            pom.xml
    +project2
        pom.xml

So basically each real project (project1, project2) is used as an aggregator for its sub-projects. Common configuration settings (Java Compiler version, other plugins) are kept in the parent, which is used as the Maven parent in all of the projects (project1, project2).

One of the settings I would like to define in the parent is the SCM URL for Subversion, e.g. http://svnhost/base/trunk/parent in the parent pom.xml.

When I do this, the individual projects inherit this setting, but of course don't reflect the relative nature of the path. In project1, this is resolved to http://svnhost/base/trunk/parent/ - I've checked this with mvn help:effective-pom.

Is there a way to specify the SCM connection so that is resolved relative to the parent? Or do I have to provide the SCM URL in each individual project?

like image 864
nwinkler Avatar asked Oct 30 '12 16:10

nwinkler


People also ask

What is SCM connection in POM XML?

Assuming that SCM has been configured in the pom. xml and the project directory is managed by a SCM, invoking the checkin goal in the scm will start the commit process for all configured sources in your pom. xml. The files should be added beforehand by an external scm client.

What is SCMs in Maven?

Maven SCM supports Maven plugins (for example maven-release-plugin) and other tools by providing them with a common API for source code management operations. You can look at the list of SCMs for more information on using Maven SCM with your favorite SCM tool.

What is SCM tag in Maven POM XML?

scm:tag - command for tagging a certain revision. scm:unedit - command to stop editing the working copy. scm:update - command for updating the working copy with the latest changes. scm:update-subprojects - command for updating all projects in a multi project build.

How does maven release plugin work?

The plugin will extract file revisions associated with the current release. Maven will compile, test and package the versioned project source code into an artifact. The final deliverable will then be released into an appropriate maven repository.


1 Answers

It should be possible if you use properties like ${svn.host} and ${svn.path} to build the scm.url. The release plugin had a bug where properties where replaced during a release: http://jira.codehaus.org/browse/MRELEASE-128 but since version 2.3 that seems to be fixed. So your child poms only define the properties but no longer the scm url.

I don't know if that helps. You don't save much lines in the pom.xml and you introduce the danger people don't change the properties.

If you define a property of the parent.scm.url in the parent and then use that property in the child adding a relative url (<scm.url>${parent.scm.url}/../myproject</scm.url>) If you do relative path in scm.url based on that property you still don't save much of the configuration?

I think to exactly do want you want to you need to write a plugin that reads the parent-url, then reads the url from the current working copy (as maven does not know where else to find that project url, since it is not configured) and then calculate the relative path from it. I think thats a but weird compared to just repeat the scm.url configuration in every pom.

like image 160
wemu Avatar answered Oct 14 '22 10:10

wemu