Maven 2 & 3

Module SCM URL is resolved as [...]/parent/module regardless of relativePath

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 2.0.2
  • Fix Version/s: 2.0.3
  • Labels:
    None
  • Environment:
    Maven 2.0.2
    Continuum 1.0.2 with maven-scm-*-1.0-beta-3-20060115.041342-*.jar
  • Complexity:
    Intermediate
  • Number of attachments :
    0

Description

Quoting Emmanuel Venisse from user list :
Ok, it's a bug in
http://svn.apache.org/viewcvs.cgi/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java?rev=306518&view=markup
in assembleScmInheritance method.
This method append parent scm connection url and artifactId without look at relativePath.

For detailed description see http://www.nabble.com/-m2-Multiprojects-and-inherited-SCM-URLs-t951105.html

Project structure :
PROJECT
PROJECT/parent
PROJECT/parent/pom.xml
PROJECT/module
PROJECT/module/pom.xml

parent/pom.xml :
<connection>scm:svn:svn://host/PROJECT/parent/</connection>
<module>../module</module>

module/pom.xml :
<relativePath>../parent/pom.xml</relativePath>

When I add module in Continuum, its url is resolved as :
scm:svn:svn://host/PROJECT/parent/module

Issue Links

Activity

Hide
Emmanuel Venisse added a comment -

It's required for Continuum

Show
Emmanuel Venisse added a comment - It's required for Continuum
Hide
Emmanuel Venisse added a comment -

The fix must be done for scm connection url, scm developer connection url, scm url and site url in distributionManagement.

For fixing it, we need to access to the absolute path of parent and child, so we need to access to Project instead of Model in DefaultModelInheritanceAssembler.
New urls must be calculated with child artifactId, relativePath of parent, parent url and module path used for the child

Show
Emmanuel Venisse added a comment - The fix must be done for scm connection url, scm developer connection url, scm url and site url in distributionManagement. For fixing it, we need to access to the absolute path of parent and child, so we need to access to Project instead of Model in DefaultModelInheritanceAssembler. New urls must be calculated with child artifactId, relativePath of parent, parent url and module path used for the child
Hide
John Casey added a comment -

added getModulePathAdjustment( MavenProject ) to MavenProject, so we can pull the module definition of an associated child project instance from a parent project instance. This enables us to then pass in the child path adjustment (from the parent pom's directory) to the model inheritance assembler, so we can adjust URLs for the child, rather than simply appending them.

Show
John Casey added a comment - added getModulePathAdjustment( MavenProject ) to MavenProject, so we can pull the module definition of an associated child project instance from a parent project instance. This enables us to then pass in the child path adjustment (from the parent pom's directory) to the model inheritance assembler, so we can adjust URLs for the child, rather than simply appending them.
Hide
Emmanuel Venisse added a comment -

patch doesn't work

Show
Emmanuel Venisse added a comment - patch doesn't work
Hide
John Casey added a comment -

Implemented the following strategy for determining module path adjustments for URLs:

1. look for module-project file, and parent-project file, and compute directory shift from parent-project <modules/> section based on that.

2. look for module-project artifactId, and parent-project <modules/> section, and match where the artifactid is the last path part for a given module in the parent.

Using <relativePath/> is difficult, since the pom files are not always going to be populated for this method, particularly when computing model inheritance.

This should work in most normal cases. Where it doesn't, it's still possible to override the value in the child pom.

Show
John Casey added a comment - Implemented the following strategy for determining module path adjustments for URLs: 1. look for module-project file, and parent-project file, and compute directory shift from parent-project <modules/> section based on that. 2. look for module-project artifactId, and parent-project <modules/> section, and match where the artifactid is the last path part for a given module in the parent. Using <relativePath/> is difficult, since the pom files are not always going to be populated for this method, particularly when computing model inheritance. This should work in most normal cases. Where it doesn't, it's still possible to override the value in the child pom.
Hide
Michael Semb Wever added a comment -

MCHANGELOG-75 seems to be a duplicate of this. But it still does not work.
And i don't see how in DefaultModelInheritanceAssembler.assembleScmInheritance

if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) )
            {
                childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), appendPaths ) );
            }

could possibly work in such situations.

Show
Michael Semb Wever added a comment - MCHANGELOG-75 seems to be a duplicate of this. But it still does not work. And i don't see how in DefaultModelInheritanceAssembler.assembleScmInheritance
if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) )
            {
                childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), appendPaths ) );
            }
could possibly work in such situations.
Hide
Dmitry Katsubo added a comment -

I also don't see how the fix with child.getArtifactId() actually solves the problem.I agree that SCM resolution mechanism should use module information, so if in parent has <connection>>scm:svn:svn://host/PROJECT/parent/</connection> and refers to module as <module>../module</module>, then the module should have <connection>scm:svn:svn://host/PROJECT/module/</connection> and not <connection>scm:svn:svn://host/PROJECT/parent/modile-artifact-id</connection>.

Show
Dmitry Katsubo added a comment - I also don't see how the fix with child.getArtifactId() actually solves the problem.I agree that SCM resolution mechanism should use module information, so if in parent has <connection>>scm:svn:svn://host/PROJECT/parent/</connection> and refers to module as <module>../module</module>, then the module should have <connection>scm:svn:svn://host/PROJECT/module/</connection> and not <connection>scm:svn:svn://host/PROJECT/parent/modile-artifact-id</connection>.
Hide
wayne liu added a comment -

I think the assumption this fix is wrong. It is not necessary for a project to be a module of it's parent. I'm using the parent to inherit a number of common settings only, not to build the child projects. One setting I would like to be able to put into the parent is
<scm>
<connection>scm:svn:http://.../trunk/${project.artifactId}</connection>
<developerConnection>scm:svn:http://.../trunk/${project.artifactId}</developerConnection>
</scm>
This would avoid having to specify scm information in the children even though they are not submodules.

Please reconsider a fix for this case.

Thanks,

Wayne Liu

Show
wayne liu added a comment - I think the assumption this fix is wrong. It is not necessary for a project to be a module of it's parent. I'm using the parent to inherit a number of common settings only, not to build the child projects. One setting I would like to be able to put into the parent is <scm> <connection>scm:svn:http://.../trunk/${project.artifactId}</connection> <developerConnection>scm:svn:http://.../trunk/${project.artifactId}</developerConnection> </scm> This would avoid having to specify scm information in the children even though they are not submodules. Please reconsider a fix for this case. Thanks, Wayne Liu
Hide
Dmitry Katsubo added a comment -

Wayne, ASAIK variable substitution works OK. What behaves wrong and what do you expect? I suppose, you do not expect that for children projects SCM will be actually scm:svn:http://.../trunk/${project.artifactId}/${project.artifactId}?

Show
Dmitry Katsubo added a comment - Wayne, ASAIK variable substitution works OK. What behaves wrong and what do you expect? I suppose, you do not expect that for children projects SCM will be actually scm:svn:http://.../trunk/${project.artifactId}/${project.artifactId}?
Hide
wayne liu added a comment -

Yes, you are correct about my expectations. I'm not a long-time Maven user, but my understanding is for all other elements, the parent's settings is inherited. But for this element, the parent's setting is inherited and appended to. That seems confusing and unnecessary, since there is no submodule relationship between parent and children.

Show
wayne liu added a comment - Yes, you are correct about my expectations. I'm not a long-time Maven user, but my understanding is for all other elements, the parent's settings is inherited. But for this element, the parent's setting is inherited and appended to. That seems confusing and unnecessary, since there is no submodule relationship between parent and children.
Hide
Florian Brunner added a comment -

I have similar issues. My project layout looks like this:
PROJECT
PROJECT/pom.xml (multi module project)
PROJECT/parent
PROJECT/parent/pom.xml
PROJECT/module
PROJECT/module/pom.xml

This layout allows to build the parent POM without building its children and still support:
cd PROJECT
mvn clean install

to build everything.

PROJECT/parent/pom.xml is the parent of PROJECT/pom.xml and PROJECT/module/pom.xml

Show
Florian Brunner added a comment - I have similar issues. My project layout looks like this: PROJECT PROJECT/pom.xml (multi module project) PROJECT/parent PROJECT/parent/pom.xml PROJECT/module PROJECT/module/pom.xml This layout allows to build the parent POM without building its children and still support: cd PROJECT mvn clean install to build everything. PROJECT/parent/pom.xml is the parent of PROJECT/pom.xml and PROJECT/module/pom.xml

People

Vote (3)
Watch (7)

Dates

  • Created:
    Updated:
    Resolved: