maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r720292 - in /maven/components/trunk: maven-mercury/src/main/java/org/apache/maven/mercury/ maven-project-builder/src/main/java/org/apache/maven/project/builder/ maven-project/src/main/java/org/apache/maven/project/builder/
Date Mon, 24 Nov 2008 21:08:36 GMT
Author: sisbell
Date: Mon Nov 24 13:08:35 2008
New Revision: 720292

URL: http://svn.apache.org/viewvc?rev=720292&view=rev
Log:
Reduced duplicate code between PomTransformer and PomClassicTransformer. The PomTrasnformer
is now a concrete base class. The PomClassicTransformer extends it, overriding how interpolation
is done, to handle interpolation of values related to project directories.

Modified:
    maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
    maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java

Modified: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java?rev=720292&r1=720291&r2=720292&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
(original)
+++ maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
Mon Nov 24 13:08:35 2008
@@ -164,7 +164,7 @@
         this.eventHistory = eventHistory;
     }
 
-    public List<ModelProperty> getModelProperties() {
+    public List<ModelProperty> getModelProperties() throws IOException {
         return new ArrayList<ModelProperty>(modelProperties);
     }
 

Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java?rev=720292&r1=720291&r2=720292&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
(original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java
Mon Nov 24 13:08:35 2008
@@ -99,12 +99,10 @@
 
                                                                           ProjectUri.Repositories.xUri)
));
 
-    private static Map<String, List<ModelProperty>> cache = new HashMap<String,
List<ModelProperty>>();
-
     /**
      * @see ModelTransformer#transformToDomainModel(java.util.List, java.util.List)
      */
-    public DomainModel transformToDomainModel( List<ModelProperty> properties,  List<ModelEventListener>
eventListeners )
+    public final DomainModel transformToDomainModel( List<ModelProperty> properties,
 List<ModelEventListener> eventListeners )
         throws IOException
     {
         if ( properties == null )
@@ -234,9 +232,10 @@
     }
 
     /**
-     * @see ModelTransformer#transformToModelProperties(java.util.List
+     * @see ModelTransformer#transformToModelProperties(java.util.List)
      */
-    public List<ModelProperty> transformToModelProperties(List<DomainModel> domainModels
)
+    public final List<ModelProperty> transformToModelProperties(List<DomainModel>
domainModels
+    )
         throws IOException
     {
         if ( domainModels == null || domainModels.isEmpty() )
@@ -255,13 +254,26 @@
         boolean containsBuildResources = false;
         boolean containsTestResources = false;
         boolean containsPluginRepositories = false;
+        boolean containsLicenses = false;
+        boolean containsDevelopers = false;
+        boolean containsContributors = false;
+        boolean containsMailingLists = false;
+        boolean containsOrganization = false;
+        boolean containsIssueManagement = false;
+        boolean containsCiManagement = false;
+        boolean containsDistRepo = false;
+        boolean containsDistSnapRepo = false;
+        boolean containsDistSite = false;
+
+        int domainModelIndex = -1;
 
         for ( DomainModel domainModel : domainModels )
         {
-            List<ModelProperty> tmp =
-                domainModel.getModelProperties();
+            domainModelIndex++;
 
-            List<ModelProperty> clearedProperties = new ArrayList<ModelProperty>();
+            List<ModelProperty> tmp = domainModel.getModelProperties();
+
+            List clearedProperties = new ArrayList<ModelProperty>();
 
             //Missing Version Rule
             if ( getPropertyFor( ProjectUri.version, tmp ) == null )
@@ -274,7 +286,7 @@
             }
 
             //Modules Not Inherited Rule
-            if ( domainModels.indexOf( domainModel ) != 0 )
+            if ( domainModelIndex > 0 )
             {
                 ModelProperty modulesProperty = getPropertyFor( ProjectUri.Modules.xUri,
tmp );
                 if ( modulesProperty != null )
@@ -296,7 +308,7 @@
             }
 
             //Not inherited plugin execution rule
-            if ( domainModels.indexOf( domainModel ) > 0 )
+            if ( domainModelIndex > 0 )
             {
                 List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
                 ModelDataSource source = new DefaultModelDataSource();
@@ -326,7 +338,7 @@
                 tmp.removeAll( removeProperties );
             }
             //Not inherited plugin rule
-            if ( domainModels.indexOf( domainModel ) > 0 )
+            if ( domainModelIndex > 0 )
             {
                 List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
                 ModelDataSource source = new DefaultModelDataSource();
@@ -366,63 +378,74 @@
             // SCM Developer Rule
             adjustUrl( scmDeveloperUrl, tmp, ProjectUri.Scm.developerConnection, projectNames
);
 
-            //Project Name Inheritance Rule
-            //Packaging Inheritance Rule
-            //Profiles not inherited rule
-            //parent.relativePath not inherited rule
-            for ( ModelProperty mp : tmp )
+            // Project Name Rule: not inherited
+            // Packaging Rule: not inherited
+            // Profiles Rule: not inherited
+            // Parent.relativePath Rule: not inherited
+            // Prerequisites Rule: not inherited
+            // DistributionManagent.Relocation Rule: not inherited
+            if ( domainModelIndex > 0 )
             {
-                String uri = mp.getUri();
-                if ( domainModels.indexOf( domainModel ) > 0 && ( uri.equals(
ProjectUri.name ) ||
-                    uri.equals( ProjectUri.packaging ) || uri.startsWith( ProjectUri.Profiles.xUri
) )
-                        || uri.startsWith( ProjectUri.Parent.relativePath ))
+                for ( ModelProperty mp : tmp )
                 {
-                    clearedProperties.add( mp );
+                    String uri = mp.getUri();
+                    if ( uri.equals( ProjectUri.name ) || uri.equals( ProjectUri.packaging
)
+                        || uri.startsWith( ProjectUri.Profiles.xUri )
+                        || uri.startsWith( ProjectUri.Parent.relativePath )
+                        || uri.startsWith( ProjectUri.Prerequisites.xUri )
+                        || uri.startsWith( ProjectUri.DistributionManagement.Relocation.xUri
) )
+                    {
+                        clearedProperties.add( mp );
+                    }
                 }
             }
 
-            //Remove Plugin Repository Inheritance Rule
-            //Build Resources Inheritence Rule
-            //Build Test Resources Inheritance Rule
-            //Only inherit IF: the above is contained in super pom (domainModels.size() -1)
&& the child doesn't has it's own respective field
-            if ( domainModels.indexOf( domainModel ) == 0 )
-            {
-                containsBuildResources = hasProjectUri( ProjectUri.Build.Resources.xUri,
tmp );
-                containsTestResources = hasProjectUri( ProjectUri.Build.TestResources.xUri,
tmp );
-                containsPluginRepositories = hasProjectUri( ProjectUri.PluginRepositories.xUri,
tmp );
-            }
+            // Remove Plugin Repository Inheritance Rule
+            // License Rule: only inherited if not specified in child
+            // Organization Rule: only inherited if not specified in child
+            // Developers Rule: only inherited if not specified in child
+            // Contributors Rule: only inherited if not specified in child
+            // Mailing Lists Rule: only inherited if not specified in child
+            // Build Resources Rule: only inherited if not specified in child
+            // Build Test Resources Rule: only inherited if not specified in child
+            // CI Management Rule: only inherited if not specified in child
+            // Issue Management Rule: only inherited if not specified in child
+            // Distribution Management Repository Rule: only inherited if not specified in
child
+            // Distribution Management Snapshot Repository Rule: only inherited if not specified
in child
+            // Distribution Management Site Rule: only inherited if not specified in child
             for ( ModelProperty mp : tmp )
             {
-                if ( domainModels.indexOf( domainModel ) > 0 )
+                String uri = mp.getUri();
+                if ( ( containsBuildResources && uri.startsWith( ProjectUri.Build.Resources.xUri
) )
+                    || ( containsTestResources && uri.startsWith( ProjectUri.Build.TestResources.xUri
) )
+                    || ( containsPluginRepositories && uri.startsWith( ProjectUri.PluginRepositories.xUri
) )
+                    || ( containsOrganization && uri.startsWith( ProjectUri.Organization.xUri
) )
+                    || ( containsLicenses && uri.startsWith( ProjectUri.Licenses.xUri
) )
+                    || ( containsDevelopers && uri.startsWith( ProjectUri.Developers.xUri
) )
+                    || ( containsContributors && uri.startsWith( ProjectUri.Contributors.xUri
) )
+                    || ( containsMailingLists && uri.startsWith( ProjectUri.MailingLists.xUri
) )
+                    || ( containsCiManagement && uri.startsWith( ProjectUri.CiManagement.xUri
) )
+                    || ( containsIssueManagement && uri.startsWith( ProjectUri.IssueManagement.xUri
) )
+                    || ( containsDistRepo && uri.startsWith( ProjectUri.DistributionManagement.Repository.xUri
) )
+                    || ( containsDistSnapRepo && uri.startsWith( ProjectUri.DistributionManagement.SnapshotRepository.xUri
) )
+                    || ( containsDistSite && uri.startsWith( ProjectUri.DistributionManagement.Site.xUri
) ) )
                 {
-                    String uri = mp.getUri();
-                    boolean isNotSuperPom = domainModels.indexOf( domainModel ) != ( domainModels.size()
- 1 );
-                    if ( isNotSuperPom )
-                    {
-                        if ( uri.startsWith( ProjectUri.Build.Resources.xUri ) ||
-                            uri.startsWith( ProjectUri.Build.TestResources.xUri ) ||
-                            uri.startsWith( ProjectUri.PluginRepositories.xUri ) )
-                        {
-                            clearedProperties.add( mp );
-                        }
-                    }
-                    else
-                    {
-                        if ( containsBuildResources && uri.startsWith( ProjectUri.Build.Resources.xUri
) )
-                        {
-                            clearedProperties.add( mp );
-                        }
-                        else if ( containsTestResources && uri.startsWith( ProjectUri.Build.TestResources.xUri
) )
-                        {
-                            clearedProperties.add( mp );
-                        }
-                        else if ( containsPluginRepositories && uri.startsWith( ProjectUri.PluginRepositories.xUri
) )
-                        {
-                            clearedProperties.add( mp );
-                        }
-                    }
+                    clearedProperties.add( mp );
                 }
             }
+            containsBuildResources |= hasProjectUri( ProjectUri.Build.Resources.xUri, tmp
);
+            containsTestResources |= hasProjectUri( ProjectUri.Build.TestResources.xUri,
tmp );
+            containsPluginRepositories |= hasProjectUri( ProjectUri.PluginRepositories.xUri,
tmp );
+            containsOrganization |= hasProjectUri( ProjectUri.Organization.xUri, tmp );
+            containsLicenses |= hasProjectUri( ProjectUri.Licenses.xUri, tmp );
+            containsDevelopers |= hasProjectUri( ProjectUri.Developers.xUri, tmp );
+            containsContributors |= hasProjectUri( ProjectUri.Contributors.xUri, tmp );
+            containsMailingLists |= hasProjectUri( ProjectUri.MailingLists.xUri, tmp );
+            containsCiManagement |= hasProjectUri( ProjectUri.CiManagement.xUri, tmp );
+            containsIssueManagement |= hasProjectUri( ProjectUri.IssueManagement.xUri, tmp
);
+            containsDistRepo |= hasProjectUri( ProjectUri.DistributionManagement.Repository.xUri,
tmp );
+            containsDistSnapRepo |= hasProjectUri( ProjectUri.DistributionManagement.SnapshotRepository.xUri,
tmp );
+            containsDistSite |= hasProjectUri( ProjectUri.DistributionManagement.Site.xUri,
tmp );
 
             ModelProperty artifactId = getPropertyFor( ProjectUri.artifactId, tmp );
             if ( artifactId != null )
@@ -460,36 +483,13 @@
     }
 
     /**
-     * Adjusts an inherited URL to compensate for a child's relation/distance to the parent
that defines the URL.
+     * Overide this method to change the way interpolation is handled.
      *
-     * @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}.
+     * @param modelProperties
+     * @param interpolatorProperties
+     * @param domainModel
+     * @throws IOException
      */
-    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)
@@ -552,6 +552,58 @@
         ModelTransformerContext.interpolateModelProperties( modelProperties, ips1 );
     }
 
+    /**
+     * Override this method for different preprocessing of model properties.
+     *
+     * @param modelProperties
+     * @return
+     */
+    public List<ModelProperty> preprocessModelProperties(List<ModelProperty>
modelProperties)
+    {
+        return new ArrayList<ModelProperty>(modelProperties);
+    }
+
+    /**
+     * Returns the base uri of all model properties: http://apache.org/maven/project/
+     *
+     * @return Returns the base uri of all model properties: http://apache.org/maven/project/
+     */
+    public final String getBaseUri()
+    {
+        return ProjectUri.baseUri;
+    }
+
+    /**
+     * 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() ) );
+            }
+        }
+    }
+
     private static boolean containsProjectVersion( List<InterpolatorProperty> interpolatorProperties
)
     {
         InterpolatorProperty versionInterpolatorProperty =
@@ -578,21 +630,6 @@
         return false;
     }
 
-    public List<ModelProperty> preprocessModelProperties(List<ModelProperty>
modelProperties)
-    {
-        return new ArrayList<ModelProperty>(modelProperties);
-    }
-
-    /**
-     * Returns the base uri of all model properties: http://apache.org/maven/project/
-     *
-     * @return Returns the base uri of all model properties: http://apache.org/maven/project/
-     */
-    public String getBaseUri()
-    {
-        return ProjectUri.baseUri;
-    }
-
     private static boolean hasProjectUri( String projectUri, List<ModelProperty> modelProperties
)
     {
         for ( ModelProperty mp : modelProperties )

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java?rev=720292&r1=720291&r2=720292&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java
Mon Nov 24 13:08:35 2008
@@ -25,6 +25,7 @@
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.shared.model.InputStreamDomainModel;
 import org.apache.maven.shared.model.ModelProperty;
+import org.apache.maven.shared.model.ModelMarshaller;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.WriterFactory;
@@ -38,6 +39,7 @@
 import java.io.InputStream;
 import java.io.Writer;
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * Provides a wrapper for the maven model.
@@ -69,6 +71,8 @@
 
     private File projectDirectory;
 
+    private List<ModelProperty> modelProperties;
+
     /**
      * Constructor
      *
@@ -275,9 +279,14 @@
         return file;
     }
 
-    public List<ModelProperty> getModelProperties()
+    public List<ModelProperty> getModelProperties() throws IOException
     {
-        return null;
+        if(modelProperties == null)
+        {
+            modelProperties = ModelMarshaller.marshallXmlToModelProperties(
+                getInputStream(), ProjectUri.baseUri, PomTransformer.URIS );
+        }
+        return new ArrayList<ModelProperty>(modelProperties);
     }
 
     /**

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=720292&r1=720291&r2=720292&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
Mon Nov 24 13:08:35 2008
@@ -19,13 +19,9 @@
  * under the License.
  */
 
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.shared.model.*;
-import org.apache.maven.shared.model.impl.DefaultModelDataSource;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.IOException;
-import java.io.StringReader;
 import java.util.*;
 
 /**
@@ -40,304 +36,6 @@
         super(factory);
     }
 
-    private static Map<String, List<ModelProperty>> cache = new HashMap<String,
List<ModelProperty>>();
-
-    /**
-     * @see ModelTransformer#transformToModelProperties(java.util.List)
-     */
-    public List<ModelProperty> transformToModelProperties(List<DomainModel> domainModels
-    )
-        throws IOException
-    {
-        if ( domainModels == null || domainModels.isEmpty() )
-        {
-            throw new IllegalArgumentException( "domainModels: null or empty" );
-        }
-
-        List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
-        List<String> projectNames = new ArrayList<String>();
-        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;
-        boolean containsPluginRepositories = false;
-        boolean containsLicenses = false;
-        boolean containsDevelopers = false;
-        boolean containsContributors = false;
-        boolean containsMailingLists = false;
-        boolean containsOrganization = false;
-        boolean containsIssueManagement = false;
-        boolean containsCiManagement = false;
-        boolean containsDistRepo = false;
-        boolean containsDistSnapRepo = false;
-        boolean containsDistSite = false;
-
-        int domainModelIndex = -1;
-
-        for ( DomainModel domainModel : domainModels )
-        {
-            domainModelIndex++;
-
-            if ( !( domainModel instanceof PomClassicDomainModel ) )
-            {
-                throw new IllegalArgumentException( "domainModels: Invalid domain model"
);
-            }
-
-            PomClassicDomainModel pomDomainModel = (PomClassicDomainModel) domainModel;
-            if ( cache.containsKey( pomDomainModel.getId() ) )
-            {
-                System.out.println( "Found in cache: ID = " + pomDomainModel.getId() );
-                modelProperties.addAll( cache.get( pomDomainModel.getId() ) );
-                continue;
-            }
-
-            List<ModelProperty> tmp = ModelMarshaller.marshallXmlToModelProperties(
-                ( (PomClassicDomainModel) domainModel ).getInputStream(), ProjectUri.baseUri,
PomTransformer.URIS );
-
-            List clearedProperties = new ArrayList<ModelProperty>();
-
-            //Missing Version Rule
-            if ( getPropertyFor( ProjectUri.version, tmp ) == null )
-            {
-                ModelProperty parentVersion = getPropertyFor( ProjectUri.Parent.version,
tmp );
-                if ( parentVersion != null )
-                {
-                    tmp.add( new ModelProperty( ProjectUri.version, parentVersion.getResolvedValue()
) );
-                }
-            }
-
-            //Modules Not Inherited Rule
-            if ( domainModelIndex > 0 )
-            {
-                ModelProperty modulesProperty = getPropertyFor( ProjectUri.Modules.xUri,
tmp );
-                if ( modulesProperty != null )
-                {
-                    tmp.remove( modulesProperty );
-                    tmp.removeAll( getPropertiesFor( ProjectUri.Modules.module, tmp ) );
-                }
-            }
-
-            //Missing groupId, use parent one Rule
-            if ( getPropertyFor( ProjectUri.groupId, tmp ) == null )
-            {
-                ModelProperty parentGroupId = getPropertyFor( ProjectUri.Parent.groupId,
tmp );
-                if ( parentGroupId != null )
-                {
-                    tmp.add( new ModelProperty( ProjectUri.groupId, parentGroupId.getResolvedValue()
) );
-                }
-
-            }
-
-            //Not inherited plugin execution rule
-            if ( domainModelIndex > 0 )
-            {
-                List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
-                ModelDataSource source = new DefaultModelDataSource();
-                source.init( tmp, Arrays.asList( new ArtifactModelContainerFactory(), new
PluginExecutionIdModelContainerFactory() ) );
-                List<ModelContainer> containers =
-                    source.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri
);
-                for ( ModelContainer container : containers )
-                {
-                    for ( ModelProperty mp : container.getProperties() )
-                    {
-                        if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.Execution.inherited
) &&
-                            mp.getResolvedValue() != null && mp.getResolvedValue().equals(
"false" ) )
-                        {
-                            removeProperties.addAll( container.getProperties() );
-                            for ( int j = tmp.indexOf( mp ); j >= 0; j-- )
-                            {
-                                if ( tmp.get( j ).getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.xUri
) )
-                                {
-                                    removeProperties.add( tmp.get( j ) );
-                                    break;
-                                }
-                            }
-                            break;
-                        }
-                    }
-                }
-                tmp.removeAll( removeProperties );
-            }
-            //Not inherited plugin rule
-            if ( domainModelIndex > 0 )
-            {
-                List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
-                ModelDataSource source = new DefaultModelDataSource();
-                source.init( tmp, Arrays.asList( new ArtifactModelContainerFactory(), new
IdModelContainerFactory() ) );
-                List<ModelContainer> containers = source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri
);
-                for ( ModelContainer container : containers )
-                {
-                    for ( ModelProperty mp : container.getProperties() )
-                    {
-                        if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.inherited
) && mp.getResolvedValue() != null &&
-                            mp.getResolvedValue().equals( "false" ) )
-                        {
-                            removeProperties.addAll( container.getProperties() );
-                            for ( int j = tmp.indexOf( mp ); j >= 0; j-- )
-                            {
-                                if ( tmp.get( j ).getUri().equals( ProjectUri.Build.Plugins.Plugin.xUri
) )
-                                {
-                                    removeProperties.add( tmp.get( j ) );
-                                    break;
-                                }
-                            }
-                            break;
-                        }
-                    }
-                }
-                tmp.removeAll( removeProperties );
-            }
-
-            // 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 Rule: not inherited
-            // Packaging Rule: not inherited
-            // Profiles Rule: not inherited
-            // Parent.relativePath Rule: not inherited
-            // Prerequisites Rule: not inherited
-            // DistributionManagent.Relocation Rule: not inherited
-            if ( domainModelIndex > 0 )
-            {
-                for ( ModelProperty mp : tmp )
-                {
-                    String uri = mp.getUri();
-                    if ( uri.equals( ProjectUri.name ) || uri.equals( ProjectUri.packaging
)
-                        || uri.startsWith( ProjectUri.Profiles.xUri )
-                        || uri.startsWith( ProjectUri.Parent.relativePath )
-                        || uri.startsWith( ProjectUri.Prerequisites.xUri )
-                        || uri.startsWith( ProjectUri.DistributionManagement.Relocation.xUri
) )
-                    {
-                        clearedProperties.add( mp );
-                    }
-                }
-            }
-
-            // Remove Plugin Repository Inheritance Rule
-            // License Rule: only inherited if not specified in child
-            // Organization Rule: only inherited if not specified in child
-            // Developers Rule: only inherited if not specified in child
-            // Contributors Rule: only inherited if not specified in child
-            // Mailing Lists Rule: only inherited if not specified in child
-            // Build Resources Rule: only inherited if not specified in child
-            // Build Test Resources Rule: only inherited if not specified in child
-            // CI Management Rule: only inherited if not specified in child
-            // Issue Management Rule: only inherited if not specified in child
-            // Distribution Management Repository Rule: only inherited if not specified in
child
-            // Distribution Management Snapshot Repository Rule: only inherited if not specified
in child
-            // Distribution Management Site Rule: only inherited if not specified in child
-            for ( ModelProperty mp : tmp )
-            {
-                String uri = mp.getUri();
-                if ( ( containsBuildResources && uri.startsWith( ProjectUri.Build.Resources.xUri
) )
-                    || ( containsTestResources && uri.startsWith( ProjectUri.Build.TestResources.xUri
) )
-                    || ( containsPluginRepositories && uri.startsWith( ProjectUri.PluginRepositories.xUri
) )
-                    || ( containsOrganization && uri.startsWith( ProjectUri.Organization.xUri
) )
-                    || ( containsLicenses && uri.startsWith( ProjectUri.Licenses.xUri
) )
-                    || ( containsDevelopers && uri.startsWith( ProjectUri.Developers.xUri
) )
-                    || ( containsContributors && uri.startsWith( ProjectUri.Contributors.xUri
) )
-                    || ( containsMailingLists && uri.startsWith( ProjectUri.MailingLists.xUri
) ) 
-                    || ( containsCiManagement && uri.startsWith( ProjectUri.CiManagement.xUri
) )
-                    || ( containsIssueManagement && uri.startsWith( ProjectUri.IssueManagement.xUri
) )
-                    || ( containsDistRepo && uri.startsWith( ProjectUri.DistributionManagement.Repository.xUri
) )
-                    || ( containsDistSnapRepo && uri.startsWith( ProjectUri.DistributionManagement.SnapshotRepository.xUri
) )
-                    || ( containsDistSite && uri.startsWith( ProjectUri.DistributionManagement.Site.xUri
) ) )
-                {
-                    clearedProperties.add( mp );
-                }
-            }
-            containsBuildResources |= hasProjectUri( ProjectUri.Build.Resources.xUri, tmp
);
-            containsTestResources |= hasProjectUri( ProjectUri.Build.TestResources.xUri,
tmp );
-            containsPluginRepositories |= hasProjectUri( ProjectUri.PluginRepositories.xUri,
tmp );
-            containsOrganization |= hasProjectUri( ProjectUri.Organization.xUri, tmp );
-            containsLicenses |= hasProjectUri( ProjectUri.Licenses.xUri, tmp );
-            containsDevelopers |= hasProjectUri( ProjectUri.Developers.xUri, tmp );
-            containsContributors |= hasProjectUri( ProjectUri.Contributors.xUri, tmp );
-            containsMailingLists |= hasProjectUri( ProjectUri.MailingLists.xUri, tmp );
-            containsCiManagement |= hasProjectUri( ProjectUri.CiManagement.xUri, tmp );
-            containsIssueManagement |= hasProjectUri( ProjectUri.IssueManagement.xUri, tmp
);
-            containsDistRepo |= hasProjectUri( ProjectUri.DistributionManagement.Repository.xUri,
tmp );
-            containsDistSnapRepo |= hasProjectUri( ProjectUri.DistributionManagement.SnapshotRepository.xUri,
tmp );
-            containsDistSite |= hasProjectUri( ProjectUri.DistributionManagement.Site.xUri,
tmp );
-
-            ModelProperty artifactId = getPropertyFor( ProjectUri.artifactId, tmp );
-            if ( artifactId != null )
-            {
-                projectNames.add( 0, artifactId.getResolvedValue() );
-            }
-
-            tmp.removeAll( clearedProperties );
-            modelProperties.addAll( tmp );
-            modelProperties.removeAll( clearedProperties );
-        }
-
-        //Rule: Build plugin config overrides reporting plugin config
-        ModelDataSource source = new DefaultModelDataSource();
-        source.init( modelProperties, Arrays.asList( new ArtifactModelContainerFactory(),
new IdModelContainerFactory() ) );
-
-        List<ModelContainer> reportContainers = source.queryFor( ProjectUri.Reporting.Plugins.Plugin.xUri
);
-        for ( ModelContainer pluginContainer : source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri
) )
-        {
-            ModelContainer transformedReportContainer = new ArtifactModelContainerFactory().create(
-                    transformPlugin( pluginContainer.getProperties() ) );
-
-            for(ModelContainer reportContainer : reportContainers) {
-                ModelContainerAction action = transformedReportContainer.containerAction(
reportContainer );
-                if ( action.equals( ModelContainerAction.JOIN ) )
-                {
-                    source.join( transformedReportContainer, reportContainer );
-                    break;
-                }
-            }
-        }
-
-        modelProperties = source.getModelProperties();
-        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)
@@ -346,93 +44,5 @@
         ProjectBuilder.Interpolator.interpolateModelProperties( modelProperties, interpolatorProperties,
(PomClassicDomainModel) domainModel);
     }
 
-    public List<ModelProperty> preprocessModelProperties(List<ModelProperty>
modelProperties)
-    {
-        return new ArrayList<ModelProperty>(modelProperties);        
-    }
-
-    /**
-     * Returns the base uri of all model properties: http://apache.org/maven/project/
-     *
-     * @return Returns the base uri of all model properties: http://apache.org/maven/project/
-     */
-    public String getBaseUri()
-    {
-        return ProjectUri.baseUri;
-    }
-
-    private static boolean hasProjectUri( String projectUri, List<ModelProperty> modelProperties
)
-    {
-        for ( ModelProperty mp : modelProperties )
-        {
-            if ( mp.getUri().equals( projectUri ) )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Returns all model properties containing the specified uri from the specified properties
list.
-     *
-     * @param uri        the uri to use in finding the returned model properties
-     * @param properties the model properties list to search
-     * @return all model properties containing the specified uri from the specified properties
list
-     */
-    private static List<ModelProperty> getPropertiesFor( String uri, List<ModelProperty>
properties )
-    {
-        List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
-        for ( ModelProperty mp : properties )
-        {
-            if ( uri.equals( mp.getUri() ) )
-            {
-                modelProperties.add( mp );
-            }
-        }
-        return modelProperties;
-    }
-
-
-    /**
-     * Returns the first model property containing the specified uri from the specified properties
list.
-     *
-     * @param uri        the uri to use in finding the returned model property
-     * @param properties the model properties list to search
-     * @return the first model property containing the specified uri from the specified properties
list.
-     */
-    private static ModelProperty getPropertyFor( String uri, List<ModelProperty> properties
)
-    {
-        for ( ModelProperty mp : properties )
-        {
-            if ( uri.equals( mp.getUri() ) )
-            {
-                return mp;
-            }
-        }
-        return null;
-    }
-
-    private static List<ModelProperty> transformPlugin( List<ModelProperty> modelProperties
)
-    {
-        List<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();
-        for ( ModelProperty mp : modelProperties )
-        {
-            if ( mp.getUri().startsWith( ProjectUri.Build.Plugins.xUri ) )
-            {   if(mp.getUri().startsWith(ProjectUri.Build.Plugins.Plugin.configuration)
-                    || mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.groupId)
-                    || mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.artifactId)
-                    || mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.version)
-                    || mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.xUri ) )
-                {
-                transformedProperties.add( new ModelProperty(
-                    mp.getUri().replace( ProjectUri.Build.Plugins.xUri, ProjectUri.Reporting.Plugins.xUri
),
-                    mp.getResolvedValue() ) );
-                }
-
-            }
-        }
-        return transformedProperties;
-    }
 }
 



Mime
View raw message