Author: brett
Date: Thu Jun 2 21:24:19 2005
New Revision: 179721
URL: http://svn.apache.org/viewcvs?rev=179721&view=rev
Log:
PR: MNG-443
inherited URLs should always append the artifact ID, regardless of trailing
slash
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java?rev=179721&r1=179720&r2=179721&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
Thu Jun 2 21:24:19 2005
@@ -72,9 +72,9 @@
// url
if ( child.getUrl() == null )
{
- if ( parent.getUrl() != null && parent.getUrl().endsWith( "/" ) )
+ if ( parent.getUrl() != null )
{
- child.setUrl( parent.getUrl() + child.getArtifactId() + "/" );
+ child.setUrl( appendPath( parent.getUrl(),
child.getArtifactId() ) );
}
else
{
@@ -333,39 +333,18 @@
if ( StringUtils.isEmpty( childScm.getConnection() ) &&
!StringUtils.isEmpty( parentScm.getConnection() ) )
{
- if ( parentScm.getConnection().endsWith( "/" ) )
- {
- childScm.setConnection( parentScm.getConnection() +
child.getArtifactId() + "/" );
- }
- else
- {
- childScm.setConnection( parentScm.getConnection() );
- }
+ childScm.setConnection( appendPath( parentScm.getConnection(),
child.getArtifactId() ) );
}
if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) &&
!StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
{
- if ( parentScm.getDeveloperConnection().endsWith( "/" ) )
- {
- childScm.setDeveloperConnection(
parentScm.getDeveloperConnection() + child.getArtifactId() + "/" );
- }
- else
- {
- childScm.setDeveloperConnection(
parentScm.getDeveloperConnection() );
- }
+ childScm.setDeveloperConnection( appendPath(
parentScm.getDeveloperConnection(), child.getArtifactId() ) );
}
if ( StringUtils.isEmpty( childScm.getUrl() ) &&
!StringUtils.isEmpty( parentScm.getUrl() ) )
{
- if ( parentScm.getUrl().endsWith( "/" ) )
- {
- childScm.setUrl( parentScm.getUrl() +
child.getArtifactId() + "/" );
- }
- else
- {
- childScm.setUrl( parentScm.getUrl() );
- }
+ childScm.setUrl( appendPath( parentScm.getUrl(),
child.getArtifactId() ) );
}
}
}
@@ -399,9 +378,9 @@
site.setUrl( parentDistMgmt.getSite().getUrl() );
- if ( site.getUrl() != null && site.getUrl().endsWith( "/"
) )
+ if ( site.getUrl() != null )
{
- site.setUrl( site.getUrl() + child.getArtifactId() +
"/" );
+ site.setUrl( appendPath( site.getUrl(),
child.getArtifactId() ) );
}
}
}
@@ -424,5 +403,15 @@
}
}
-
+ private static String appendPath( String url, String path )
+ {
+ if ( url.endsWith( "/" ) )
+ {
+ return url + path;
+ }
+ else
+ {
+ return url + "/" + path;
+ }
+ }
}
Modified:
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java?rev=179721&r1=179720&r2=179721&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java
(original)
+++
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java
Thu Jun 2 21:24:19 2005
@@ -127,14 +127,14 @@
throws Exception
{
// Make the models
- Model root = makeScmModel( "root", "scm:foo:/scm-root/",
"scm:foo:/scm-dev-root/", null );
+ Model root = makeScmModel( "root", "scm:foo:/scm-root",
"scm:foo:/scm-dev-root", null );
Model artifact1 = makeScmModel( "artifact1" );
Model artifact1_1 = makeScmModel( "artifact1-1" );
- Model artifact2 = makeScmModel( "artifact2",
"scm:foo:/scm-root/yay-artifact2/",
-
"scm:foo:/scm-dev-root/yay-artifact2/", null );
+ Model artifact2 = makeScmModel( "artifact2",
"scm:foo:/scm-root/yay-artifact2",
+ "scm:foo:/scm-dev-root/yay-artifact2",
null );
Model artifact2_1 = makeScmModel( "artifact2-1" );
@@ -149,70 +149,70 @@
// --- -- -
- assertConnection( "scm:foo:/scm-root/artifact1/",
"scm:foo:/scm-dev-root/artifact1/", artifact1 );
+ assertConnection( "scm:foo:/scm-root/artifact1",
"scm:foo:/scm-dev-root/artifact1", artifact1 );
- assertConnection( "scm:foo:/scm-root/artifact1/artifact1-1/",
"scm:foo:/scm-dev-root/artifact1/artifact1-1/",
+ assertConnection( "scm:foo:/scm-root/artifact1/artifact1-1",
"scm:foo:/scm-dev-root/artifact1/artifact1-1",
artifact1_1 );
- assertConnection( "scm:foo:/scm-root/yay-artifact2/",
"scm:foo:/scm-dev-root/yay-artifact2/", artifact2 );
+ assertConnection( "scm:foo:/scm-root/yay-artifact2",
"scm:foo:/scm-dev-root/yay-artifact2", artifact2 );
- assertConnection( "scm:foo:/scm-root/yay-artifact2/artifact2-1/",
- "scm:foo:/scm-dev-root/yay-artifact2/artifact2-1/",
artifact2_1 );
+ assertConnection( "scm:foo:/scm-root/yay-artifact2/artifact2-1",
+ "scm:foo:/scm-dev-root/yay-artifact2/artifact2-1",
artifact2_1 );
}
public void testScmInheritanceWhereParentHasConnectionAndTheChildDoesnt()
{
- Model parent = makeScmModel( "parent", "scm:foo:bar:/scm-root/", null,
null );
+ Model parent = makeScmModel( "parent", "scm:foo:bar:/scm-root", null,
null );
Model child = makeScmModel( "child" );
assembler.assembleModelInheritance( child, parent );
- assertScm( "scm:foo:bar:/scm-root/child/", null, null, child.getScm()
);
+ assertScm( "scm:foo:bar:/scm-root/child", null, null, child.getScm() );
}
public void testScmInheritanceWhereParentHasConnectionAndTheChildDoes()
{
- Model parent = makeScmModel( "parent", "scm:foo:bar:/scm-root/", null,
null );
+ Model parent = makeScmModel( "parent", "scm:foo:bar:/scm-root", null,
null );
- Model child = makeScmModel( "child", "scm:foo:bar:/another-root/",
null, null );
+ Model child = makeScmModel( "child", "scm:foo:bar:/another-root",
null, null );
assembler.assembleModelInheritance( child, parent );
- assertScm( "scm:foo:bar:/another-root/", null, null, child.getScm() );
+ assertScm( "scm:foo:bar:/another-root", null, null, child.getScm() );
}
public void
testScmInheritanceWhereParentHasDeveloperConnectionAndTheChildDoesnt()
{
- Model parent = makeScmModel( "parent", null,
"scm:foo:bar:/scm-dev-root/", null );
+ Model parent = makeScmModel( "parent", null,
"scm:foo:bar:/scm-dev-root", null );
Model child = makeScmModel( "child" );
assembler.assembleModelInheritance( child, parent );
- assertScm( null, "scm:foo:bar:/scm-dev-root/child/", null,
child.getScm() );
+ assertScm( null, "scm:foo:bar:/scm-dev-root/child", null,
child.getScm() );
}
public void
testScmInheritanceWhereParentHasDeveloperConnectionAndTheChildDoes()
{
- Model parent = makeScmModel( "parent", null,
"scm:foo:bar:/scm-dev-root/", null );
+ Model parent = makeScmModel( "parent", null,
"scm:foo:bar:/scm-dev-root", null );
- Model child = makeScmModel( "child", null,
"scm:foo:bar:/another-dev-root/", null );
+ Model child = makeScmModel( "child", null,
"scm:foo:bar:/another-dev-root", null );
assembler.assembleModelInheritance( child, parent );
- assertScm( null, "scm:foo:bar:/another-dev-root/", null,
child.getScm() );
+ assertScm( null, "scm:foo:bar:/another-dev-root", null, child.getScm()
);
}
public void testScmInheritanceWhereParentHasUrlAndTheChildDoesnt()
{
- Model parent = makeScmModel( "parent", null, null, "http://foo/bar/" );
+ Model parent = makeScmModel( "parent", null, null, "http://foo/bar" );
Model child = makeScmModel( "child" );
assembler.assembleModelInheritance( child, parent );
- assertScm( null, null, "http://foo/bar/child/", child.getScm() );
+ assertScm( null, null, "http://foo/bar/child", child.getScm() );
}
public void testScmInheritanceWhereParentHasUrlAndTheChildDoes()
Modified:
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java?rev=179721&r1=179720&r2=179721&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
(original)
+++
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
Thu Jun 2 21:24:19 2005
@@ -72,7 +72,7 @@
// Value taken from p1
//
----------------------------------------------------------------------
- assertEquals( "scm-url", p4.getScm().getUrl() );
+ assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() );
//
----------------------------------------------------------------------
// Value taken from p4
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]