You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/11/15 23:35:14 UTC
svn commit: r717941 -
/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
Author: bentmann
Date: Sat Nov 15 14:35:14 2008
New Revision: 717941
URL: http://svn.apache.org/viewvc?rev=717941&view=rev
Log:
[MNG-3846] Inherited URLs are not automatically extended with the child's artifactId
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java?rev=717941&r1=717940&r2=717941&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java Sat Nov 15 14:35:14 2008
@@ -258,7 +258,7 @@
}
/**
- * @see ModelTransformer#transformToModelProperties(java.util.List
+ * @see ModelTransformer#transformToModelProperties(java.util.List)
*/
public List<ModelProperty> transformToModelProperties(List<DomainModel> domainModels
)
@@ -271,10 +271,11 @@
List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
List<String> projectNames = new ArrayList<String>();
- StringBuffer siteUrl = new StringBuffer();
- StringBuffer scmUrl = new StringBuffer();
- StringBuffer scmConnectionUrl = new StringBuffer();
- StringBuffer scmDeveloperUrl = new StringBuffer();
+ StringBuilder projectUrl = new StringBuilder( 128 );
+ StringBuilder siteUrl = new StringBuilder( 128 );
+ StringBuilder scmUrl = new StringBuilder( 128 );
+ StringBuilder scmConnectionUrl = new StringBuilder( 128 );
+ StringBuilder scmDeveloperUrl = new StringBuilder( 128 );
boolean containsBuildResources = false;
boolean containsTestResources = false;
@@ -392,64 +393,16 @@
tmp.removeAll( removeProperties );
}
- //Site Rule
-
- ModelProperty siteUrlProperty = getPropertyFor( ProjectUri.DistributionManagement.Site.url, tmp );
- if ( siteUrl.length() == 0 && siteUrlProperty != null )
- {
- siteUrl.append( siteUrlProperty.getResolvedValue());//.substring(0, siteUrlProperty.getResolvedValue().lastIndexOf("/")) );
- for ( String projectName : projectNames )
- {
- if(!siteUrl.toString().endsWith( "/")) {
- siteUrl.append( "/" );
- }
- siteUrl.append( projectName );
- }
- int index = tmp.indexOf( siteUrlProperty );
- tmp.remove( index );
- tmp.add( index, new ModelProperty( ProjectUri.DistributionManagement.Site.url, siteUrl.toString() ) );
- }
- //If DistributionManagement site URL is property,
- //SCM Rule
- ModelProperty scmUrlProperty = getPropertyFor( ProjectUri.Scm.url, tmp );
- if ( scmUrl.length() == 0 && scmUrlProperty != null )
- {
- scmUrl.append( scmUrlProperty.getResolvedValue() );
- for ( String projectName : projectNames )
- {
- scmUrl.append( "/" ).append( projectName );
- }
- int index = tmp.indexOf( scmUrlProperty );
- tmp.remove( index );
- tmp.add( index, new ModelProperty( ProjectUri.Scm.url, scmUrl.toString() ) );
- }
-
- //SCM Connection Rule
- scmUrlProperty = getPropertyFor( ProjectUri.Scm.connection, tmp );
- if ( scmConnectionUrl.length() == 0 && scmUrlProperty != null )
- {
- scmConnectionUrl.append( scmUrlProperty.getResolvedValue() );
- for ( String projectName : projectNames )
- {
- scmConnectionUrl.append( "/" ).append( projectName );
- }
- int index = tmp.indexOf( scmUrlProperty );
- tmp.remove( index );
- tmp.add( index, new ModelProperty( ProjectUri.Scm.connection, scmConnectionUrl.toString() ) );
- }
- //SCM Developer Rule
- scmUrlProperty = getPropertyFor( ProjectUri.Scm.developerConnection, tmp );
- if ( scmDeveloperUrl.length() == 0 && scmUrlProperty != null )
- {
- scmDeveloperUrl.append( scmUrlProperty.getResolvedValue() );
- for ( String projectName : projectNames )
- {
- scmDeveloperUrl.append( "/" ).append( projectName );
- }
- int index = tmp.indexOf( scmUrlProperty );
- tmp.remove( index );
- tmp.add( index, new ModelProperty( ProjectUri.Scm.developerConnection, scmDeveloperUrl.toString() ) );
- }
+ // Project URL Rule
+ adjustUrl( projectUrl, tmp, ProjectUri.url, projectNames );
+ // Site Rule
+ adjustUrl( siteUrl, tmp, ProjectUri.DistributionManagement.Site.url, projectNames );
+ // SCM Rule
+ adjustUrl( scmUrl, tmp, ProjectUri.Scm.url, projectNames );
+ // SCM Connection Rule
+ adjustUrl( scmConnectionUrl, tmp, ProjectUri.Scm.connection, projectNames );
+ // SCM Developer Rule
+ adjustUrl( scmDeveloperUrl, tmp, ProjectUri.Scm.developerConnection, projectNames );
//Project Name Inheritance Rule
//Packaging Inheritance Rule
@@ -542,6 +495,37 @@
return modelProperties;
}
+ /**
+ * Adjusts an inherited URL to compensate for a child's relation/distance to the parent that defines the URL.
+ *
+ * @param url The buffer for the adjusted URL, must not be {@code null}.
+ * @param properties The model properties to update, must not be {@code null}.
+ * @param uri The URI of the model property defining the URL to adjust, must not be {@code null}.
+ * @param ids The artifact identifiers of the parent projects, starting with the least significant parent, must not
+ * be {@code null}.
+ */
+ private void adjustUrl( StringBuilder url, List<ModelProperty> properties, String uri, List<String> ids )
+ {
+ if ( url.length() == 0 )
+ {
+ ModelProperty property = getPropertyFor( uri, properties );
+ if ( property != null )
+ {
+ url.append( property.getResolvedValue() );
+ for ( String id : ids )
+ {
+ if ( url.length() > 0 && url.charAt( url.length() - 1 ) != '/' )
+ {
+ url.append( '/' );
+ }
+ url.append( id );
+ }
+ int index = properties.indexOf( property );
+ properties.set( index, new ModelProperty( uri, url.toString() ) );
+ }
+ }
+ }
+
public void interpolateModelProperties(List<ModelProperty> modelProperties,
List<InterpolatorProperty> interpolatorProperties,
DomainModel domainModel)