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?
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.