maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r719724 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/plugin/ maven-mercury/ maven-project/src/main/java/org/apache/maven/project/ maven-project/src/main/java/org/apache/maven/project/builder/
Date Fri, 21 Nov 2008 21:50:31 GMT
Author: sisbell
Date: Fri Nov 21 13:50:31 2008
New Revision: 719724

URL: http://svn.apache.org/viewvc?rev=719724&view=rev
Log:
Moved out specialized methods from PomClassicTransformer to ProjectBuilder. Did this refactoring
to make it easier to merge PomTransformer and PomClassicTransfomer.

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-mercury/maven-mercury.iml
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=719724&r1=719723&r2=719724&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Fri Nov 21 13:50:31 2008
@@ -59,8 +59,8 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.project.builder.PomClassicTransformer;
 import org.apache.maven.project.builder.PomInterpolatorTag;
+import org.apache.maven.project.builder.ProjectBuilder;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
 import org.apache.maven.realm.MavenRealmManager;
@@ -563,7 +563,7 @@
                 interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties(
session.getProjectBuilderConfiguration().getUserProperties(),
                         PomInterpolatorTag.USER_PROPERTIES.name()));
                 String interpolatedDom  =
-                        PomClassicTransformer.interpolateXmlString( String.valueOf( dom ),
interpolatorProperties );
+                        ProjectBuilder.Interpolator.interpolateXmlString( String.valueOf(
dom ), interpolatorProperties );
                 dom = Xpp3DomBuilder.build( new StringReader( interpolatedDom ) );
             }
             catch ( XmlPullParserException e )

Modified: maven/components/trunk/maven-mercury/maven-mercury.iml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/maven-mercury.iml?rev=719724&r1=719723&r2=719724&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/maven-mercury.iml (original)
+++ maven/components/trunk/maven-mercury/maven-mercury.iml Fri Nov 21 13:50:31 2008
@@ -6,28 +6,205 @@
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false"
/>
+      <excludeFolder url="file://$MODULE_DIR$/target/maven-shared-archive-resources" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntry type="module" module-name="maven-shared-model" />
-    <orderEntry type="module" module-name="maven-project-builder" />
     <orderEntry type="module-library">
-      <library>
+      <library name="junit:junit:4.4">
         <CLASSES>
-          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/mercury/mercury-external/1.0.0-alpha-2-SNAPSHOT/mercury-external-1.0.0-alpha-2-SNAPSHOT.jar!/"
/>
+          <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.4/junit-4.4.jar!/" />
         </CLASSES>
-        <JAVADOC />
-        <SOURCES />
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.4/junit-4.4-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.4/junit-4.4-sources.jar!/"
/>
+        </SOURCES>
       </library>
     </orderEntry>
-    <orderEntry type="module-library">
-      <library>
+    <orderEntry type="module-library" exported="">
+      <library name="org.apache.maven.mercury:mercury-artifact:1.0.0-alpha-2-SNAPSHOT">
         <CLASSES>
           <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/mercury/mercury-artifact/1.0.0-alpha-2-SNAPSHOT/mercury-artifact-1.0.0-alpha-2-SNAPSHOT.jar!/"
/>
         </CLASSES>
-        <JAVADOC />
-        <SOURCES />
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/mercury/mercury-artifact/1.0.0-alpha-2-SNAPSHOT/mercury-artifact-1.0.0-alpha-2-SNAPSHOT-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/mercury/mercury-artifact/1.0.0-alpha-2-SNAPSHOT/mercury-artifact-1.0.0-alpha-2-SNAPSHOT-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="org.codehaus.plexus:plexus-container-default:1.0-beta-2-SNAPSHOT">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-container-default/1.0-beta-2-SNAPSHOT/plexus-container-default-1.0-beta-2-SNAPSHOT.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-container-default/1.0-beta-2-SNAPSHOT/plexus-container-default-1.0-beta-2-SNAPSHOT-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-container-default/1.0-beta-2-SNAPSHOT/plexus-container-default-1.0-beta-2-SNAPSHOT-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="org.codehaus.plexus:plexus-utils:1.5.5">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-utils/1.5.5/plexus-utils-1.5.5-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="org.codehaus.plexus:plexus-classworlds:1.2">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-classworlds/1.2/plexus-classworlds-1.2.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-classworlds/1.2/plexus-classworlds-1.2-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-classworlds/1.2/plexus-classworlds-1.2-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="org.apache.xbean:xbean-reflect:3.4">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="log4j:log4j:1.2.12">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.12/log4j-1.2.12.jar!/" />
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.12/log4j-1.2.12-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.12/log4j-1.2.12-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="commons-logging:commons-logging-api:1.1">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="com.google.code.google-collections:google-collect:snapshot-20080530">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/com/google/code/google-collections/google-collect/snapshot-20080530/google-collect-snapshot-20080530.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/com/google/code/google-collections/google-collect/snapshot-20080530/google-collect-snapshot-20080530-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/com/google/code/google-collections/google-collect/snapshot-20080530/google-collect-snapshot-20080530-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="org.codehaus.plexus:plexus-lang:1.0">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-lang/1.0/plexus-lang-1.0.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-lang/1.0/plexus-lang-1.0-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-lang/1.0/plexus-lang-1.0-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="org.codehaus.plexus:plexus-component-api:1.0-alpha-20">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-component-api/1.0-alpha-20/plexus-component-api-1.0-alpha-20.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-component-api/1.0-alpha-20/plexus-component-api-1.0-alpha-20-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/plexus/plexus-component-api/1.0-alpha-20/plexus-component-api-1.0-alpha-20-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="org.apache.maven.mercury:mercury-external:1.0.0-alpha-2-SNAPSHOT">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/mercury/mercury-external/1.0.0-alpha-2-SNAPSHOT/mercury-external-1.0.0-alpha-2-SNAPSHOT.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/mercury/mercury-external/1.0.0-alpha-2-SNAPSHOT/mercury-external-1.0.0-alpha-2-SNAPSHOT-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/mercury/mercury-external/1.0.0-alpha-2-SNAPSHOT/mercury-external-1.0.0-alpha-2-SNAPSHOT-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module" module-name="maven-project-builder" exported="" />
+    <orderEntry type="module-library" exported="">
+      <library name="org.apache.maven.shared:maven-shared-model:1.0-SNAPSHOT">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/shared/maven-shared-model/1.0-SNAPSHOT/maven-shared-model-1.0-SNAPSHOT.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/shared/maven-shared-model/1.0-SNAPSHOT/maven-shared-model-1.0-SNAPSHOT-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/apache/maven/shared/maven-shared-model/1.0-SNAPSHOT/maven-shared-model-1.0-SNAPSHOT-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="org.codehaus.woodstox:wstx-asl:3.2.6">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/woodstox/wstx-asl/3.2.6/wstx-asl-3.2.6.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/woodstox/wstx-asl/3.2.6/wstx-asl-3.2.6-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/org/codehaus/woodstox/wstx-asl/3.2.6/wstx-asl-3.2.6-sources.jar!/"
/>
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library" exported="">
+      <library name="stax:stax-api:1.0.1">
+        <CLASSES>
+          <root url="jar://$MAVEN_REPOSITORY$/stax/stax-api/1.0.1/stax-api-1.0.1.jar!/"
/>
+        </CLASSES>
+        <JAVADOC>
+          <root url="jar://$MAVEN_REPOSITORY$/stax/stax-api/1.0.1/stax-api-1.0.1-javadoc.jar!/"
/>
+        </JAVADOC>
+        <SOURCES>
+          <root url="jar://$MAVEN_REPOSITORY$/stax/stax-api/1.0.1/stax-api-1.0.1-sources.jar!/"
/>
+        </SOURCES>
       </library>
     </orderEntry>
   </component>

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=719724&r1=719723&r2=719724&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Fri Nov 21 13:50:31 2008
@@ -264,7 +264,7 @@
 
         try
         {
-            superModel = PomClassicTransformer.interpolateModel(superModel, interpolatorProperties,
basedir);
+            superModel = ProjectBuilder.Interpolator.interpolateModel(superModel, interpolatorProperties,
basedir);
         }
         catch (IOException e)
         {

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=719724&r1=719723&r2=719724&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
Fri Nov 21 13:50:31 2008
@@ -20,15 +20,12 @@
  */
 
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.model.Model;
 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.io.File;
-import java.io.ByteArrayInputStream;
 import java.util.*;
 
 /**
@@ -38,68 +35,6 @@
     implements ModelTransformer
 {
 
-    /**
-     * The URIs this tranformer supports
-     */
-    private static Set<String> uris = new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri,
-                                                                          ProjectUri.Build.PluginManagement.Plugins.xUri,
-                                                                          ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
-                                                                          ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
-                                                                          ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
-
-                                                                          ProjectUri.Build.Plugins.xUri,
-                                                                          ProjectUri.Build.Plugins.Plugin.configuration,
-                                                                          ProjectUri.Reporting.Plugins.xUri,
-                                                                          ProjectUri.Reporting.Plugins.Plugin.configuration,
-                                                                          ProjectUri.Build.Plugins.Plugin.Dependencies.xUri,
-                                                                          ProjectUri.Build.Resources.xUri,
-                                                                          ProjectUri.Build.Resources.Resource.includes,
-                                                                          ProjectUri.Build.Resources.Resource.excludes,
-                                                                          ProjectUri.Build.TestResources.xUri,
-
-                                                                          ProjectUri.CiManagement.Notifiers.xUri,
-
-                                                                          ProjectUri.Contributors.xUri,
-
-                                                                          ProjectUri.Dependencies.xUri,
-                                                                          ProjectUri.Dependencies.Dependency.Exclusions.xUri,
-
-                                                                          ProjectUri.DependencyManagement.Dependencies.xUri,
-                                                                          ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.xUri,
-
-                                                                          ProjectUri.Developers.xUri,
-                                                                          ProjectUri.Developers.Developer.roles,
-                                                                          ProjectUri.Licenses.xUri,
-                                                                          ProjectUri.MailingLists.xUri,
-                                                                          ProjectUri.Modules.xUri,
-                                                                          ProjectUri.PluginRepositories.xUri,
-
-                                                                          ProjectUri.Profiles.xUri,
-                                                                          ProjectUri.Profiles.Profile.Build.Plugins.xUri,
-                                                                          ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Dependencies.xUri,
-                                                                          ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.xUri,
-                                                                          ProjectUri.Profiles.Profile.Build.Resources.xUri,
-                                                                          ProjectUri.Profiles.Profile.Build.TestResources.xUri,
-                                                                          ProjectUri.Profiles.Profile.Dependencies.xUri,
-                                                                          ProjectUri.Profiles.Profile.Dependencies.Dependency.Exclusions.xUri,
-                                                                          ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.xUri,
-                                                                          ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.Dependency.Exclusions.xUri,
-                                                                          ProjectUri.Profiles.Profile.PluginRepositories.xUri,
-                                                                          ProjectUri.Profiles.Profile.Reporting.Plugins.xUri,
-                                                                          ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.ReportSets.xUri,
-                                                                          ProjectUri.Profiles.Profile.Repositories.xUri,
-
-                                                                          ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.xUri,
-                                                                          ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
-                                                                          ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
-                                                                          ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
-
-                                                                          ProjectUri.Reporting.Plugins.xUri,
-                                                                          ProjectUri.Reporting.Plugins.Plugin.ReportSets.xUri,
-
-                                                                          ProjectUri.Repositories.xUri
-                                                                           ) );
-
     private static Map<String, List<ModelProperty>> cache = new HashMap<String,
List<ModelProperty>>();
 
     /**
@@ -285,7 +220,7 @@
             }
 
             List<ModelProperty> tmp = ModelMarshaller.marshallXmlToModelProperties(
-                ( (PomClassicDomainModel) domainModel ).getInputStream(), ProjectUri.baseUri,
uris );
+                ( (PomClassicDomainModel) domainModel ).getInputStream(), ProjectUri.baseUri,
PomTransformer.URIS );
 
             List clearedProperties = new ArrayList<ModelProperty>();
 
@@ -521,205 +456,7 @@
                                            DomainModel domainModel)
             throws IOException
     {
-        interpolateModelProperties( modelProperties, interpolatorProperties, (PomClassicDomainModel)
domainModel);
-    }
-
-    public static String interpolateXmlString( String xml, List<InterpolatorProperty>
interpolatorProperties )
-            throws IOException
-    {
-        List<ModelProperty> modelProperties =
-            ModelMarshaller.marshallXmlToModelProperties( new ByteArrayInputStream(xml.getBytes()),
ProjectUri.baseUri, uris );
-
-        Map<String, String> aliases = new HashMap<String, String>();
-        aliases.put( "project.", "pom.");
-
-        List<InterpolatorProperty> ips = new ArrayList<InterpolatorProperty>(interpolatorProperties);
-        ips.addAll(ModelTransformerContext.createInterpolatorProperties(modelProperties,
ProjectUri.baseUri, aliases,
-                        PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false));
-
-        for(ModelProperty mp : modelProperties)
-        {
-            if(mp.getUri().startsWith(ProjectUri.properties) && mp.getValue() !=
null )
-            {
-                String uri = mp.getUri();
-                ips.add( new InterpolatorProperty( "${" + uri.substring( uri.lastIndexOf(
"/" ) + 1,
-                        uri.length() ) + "}", mp.getValue() ) );
-            }
-        }
-
-        ModelTransformerContext.interpolateModelProperties( modelProperties, ips );
-        return ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri
);
-    }
-
-    public static String interpolateModelAsString(Model model, List<InterpolatorProperty>
interpolatorProperties, File projectDirectory)
-            throws IOException
-    {
-        PomClassicDomainModel domainModel = new PomClassicDomainModel( model );
-        domainModel.setProjectDirectory( projectDirectory );
-        List<ModelProperty> modelProperties =
-                ModelMarshaller.marshallXmlToModelProperties( domainModel.getInputStream(),
ProjectUri.baseUri, uris );
-        interpolateModelProperties( modelProperties, interpolatorProperties, domainModel);
-
-        return ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri
);
-    }
-
-    public static Model interpolateModel(Model model, List<InterpolatorProperty> interpolatorProperties,
File projectDirectory)
-        throws IOException
-    {
-        String pomXml = interpolateModelAsString( model, interpolatorProperties, projectDirectory
);
-        PomClassicDomainModel domainModel = new PomClassicDomainModel( new ByteArrayInputStream(
pomXml.getBytes() ));
-        return domainModel.getModel();
-    }
-
-    private static boolean containsProjectVersion( List<InterpolatorProperty> interpolatorProperties
)
-    {
-        InterpolatorProperty versionInterpolatorProperty =
-                new ModelProperty( ProjectUri.version, "").asInterpolatorProperty( ProjectUri.baseUri);
-        for( InterpolatorProperty ip : interpolatorProperties)
-        {
-            if ( ip.equals( versionInterpolatorProperty ) )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private static final Map<String, String> aliases = new HashMap<String, String>();
-
-    private static void addProjectAlias( String element, boolean leaf )
-    {
-        String suffix = leaf ? "\\}" : "\\.";
-        aliases.put( "\\$\\{project\\." + element + suffix, "\\$\\{" + element + suffix );
-    }
-
-    static
-    {
-        aliases.put( "\\$\\{project\\.", "\\$\\{pom\\.");
-        addProjectAlias( "modelVersion", true );
-        addProjectAlias( "groupId", true );
-        addProjectAlias( "artifactId", true );
-        addProjectAlias( "version", true );
-        addProjectAlias( "packaging", true );
-        addProjectAlias( "name", true );
-        addProjectAlias( "description", true );
-        addProjectAlias( "inceptionYear", true );
-        addProjectAlias( "url", true );
-        addProjectAlias( "parent", false );
-        addProjectAlias( "prerequisites", false );
-        addProjectAlias( "organization", false );
-        addProjectAlias( "build", false );
-        addProjectAlias( "reporting", false );
-        addProjectAlias( "scm", false );
-        addProjectAlias( "distributionManagement", false );
-        addProjectAlias( "issueManagement", false );
-        addProjectAlias( "ciManagement", false );
-    }
-
-    private static void interpolateModelProperties(List<ModelProperty> modelProperties,
-                                                   List<InterpolatorProperty> interpolatorProperties,
-                                                   PomClassicDomainModel domainModel)
-           throws IOException
-    {
-        if(!containsProjectVersion(interpolatorProperties))
-        {
-            aliases.put("\\$\\{project.version\\}", "\\$\\{version\\}");
-        }
-
-        List<ModelProperty> firstPassModelProperties = new ArrayList<ModelProperty>();
-        List<ModelProperty> secondPassModelProperties = new ArrayList<ModelProperty>();
-
-        ModelProperty buildProperty = new ModelProperty(ProjectUri.Build.xUri, null);
-        for(ModelProperty mp : modelProperties)
-        {
-            if( mp.getValue() != null && !mp.getUri().contains( "#property" ) &&
!mp.getUri().contains( "#collection" ))
-            {
-                if( !buildProperty.isParentOf( mp ) || mp.getUri().equals(ProjectUri.Build.finalName
) )
-                {
-                    firstPassModelProperties.add(mp);
-                }
-                else
-                {
-                    secondPassModelProperties.add(mp);
-                }
-            }
-        }
-
-
-        List<InterpolatorProperty> standardInterpolatorProperties = new ArrayList<InterpolatorProperty>();
-        if(domainModel.isPomInBuild())
-        {
-            String basedir = domainModel.getProjectDirectory().getAbsolutePath();
-            standardInterpolatorProperties.add(new InterpolatorProperty("${project.basedir}",
basedir,
-                    PomInterpolatorTag.PROJECT_PROPERTIES.name() ));
-            standardInterpolatorProperties.add(new InterpolatorProperty("${basedir}", basedir,
-                    PomInterpolatorTag.PROJECT_PROPERTIES.name() ));
-            standardInterpolatorProperties.add(new InterpolatorProperty("${pom.basedir}",
basedir,
-                    PomInterpolatorTag.PROJECT_PROPERTIES.name() ));
-
-        }
-
-        for(ModelProperty mp : modelProperties)
-        {
-            if(mp.getUri().startsWith(ProjectUri.properties) && mp.getValue() !=
null )
-            {
-                String uri = mp.getUri();
-                standardInterpolatorProperties.add( new InterpolatorProperty( "${" + uri.substring(
uri.lastIndexOf( "/" ) + 1,
-                        uri.length() ) + "}", mp.getValue(), PomInterpolatorTag.PROJECT_PROPERTIES.name()
) );
-            }
-        }
-
-        //FIRST PASS - Withhold using build directories as interpolator properties
-        List<InterpolatorProperty> ips1 = new ArrayList<InterpolatorProperty>(interpolatorProperties);
-        ips1.addAll(standardInterpolatorProperties);
-        ips1.addAll(ModelTransformerContext.createInterpolatorProperties(firstPassModelProperties,
ProjectUri.baseUri, aliases,
-                        PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false));
-        Collections.sort(ips1, new Comparator<InterpolatorProperty>()
-        {
-            public int compare(InterpolatorProperty o, InterpolatorProperty o1) {
-                return PomInterpolatorTag.valueOf(o.getTag()).compareTo(PomInterpolatorTag.valueOf(o1.getTag()));
-            }
-        });
-
-        ModelTransformerContext.interpolateModelProperties( modelProperties, ips1 );
-
-        //SECOND PASS - Set absolute paths on build directories
-        if( domainModel.isPomInBuild() )
-        {   String basedir = domainModel.getProjectDirectory().getAbsolutePath();
-            Map<ModelProperty, ModelProperty> buildDirectories = new HashMap<ModelProperty,
ModelProperty>();
-            for(ModelProperty mp : secondPassModelProperties)
-            {
-                if(mp.getUri().equals( ProjectUri.Build.directory ))
-                {
-                    File file = new File(mp.getResolvedValue());
-                    if( !file.isAbsolute() )
-                    {
-                        buildDirectories.put(mp, new ModelProperty(mp.getUri(), new File(basedir,
file.getPath()).getAbsolutePath()));
-                    }
-                }
-            }
-
-            for ( Map.Entry<ModelProperty, ModelProperty> e : buildDirectories.entrySet()
)
-            {
-                secondPassModelProperties.remove( e.getKey() );
-                secondPassModelProperties.add(e.getValue() );
-            }
-        }
-
-        //THIRD PASS - Use build directories as interpolator properties
-        List<InterpolatorProperty> ips2 = new ArrayList<InterpolatorProperty>(interpolatorProperties);
-        ips2.addAll(standardInterpolatorProperties);        
-        ips2.addAll(ModelTransformerContext.createInterpolatorProperties(secondPassModelProperties,
ProjectUri.baseUri, aliases,
-                        PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false));
-        ips2.addAll(interpolatorProperties);
-        Collections.sort(ips2, new Comparator<InterpolatorProperty>()
-        {
-            public int compare(InterpolatorProperty o, InterpolatorProperty o1) {
-                return PomInterpolatorTag.valueOf(o.getTag()).compareTo(PomInterpolatorTag.valueOf(o1.getTag()));
-            }
-        });
-
-        ModelTransformerContext.interpolateModelProperties( modelProperties, ips2 );
+        ProjectBuilder.Interpolator.interpolateModelProperties( modelProperties, interpolatorProperties,
(PomClassicDomainModel) domainModel);
     }
 
     private static boolean hasExecutionId( ModelContainer executionContainer )

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java?rev=719724&r1=719723&r2=719724&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/ProjectBuilder.java
Fri Nov 21 13:50:31 2008
@@ -22,14 +22,13 @@
 import org.apache.maven.model.Model;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuilderConfiguration;
-import org.apache.maven.shared.model.ImportModel;
-import org.apache.maven.shared.model.InterpolatorProperty;
+import org.apache.maven.shared.model.*;
 
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collection;
-import java.util.List;
+import java.io.ByteArrayInputStream;
+import java.util.*;
 
 /**
  * Provides services for building maven projects from models.
@@ -39,6 +38,7 @@
 
     String ROLE = ProjectBuilder.class.getName();
 
+
     /**
      * Returns a maven project for the specified input stream.
      *
@@ -57,4 +57,207 @@
                                      ProjectBuilderConfiguration projectBuilderConfiguration
)
         throws IOException;
 
+
+    public static class Interpolator {
+
+        public static String interpolateXmlString( String xml, List<InterpolatorProperty>
interpolatorProperties )
+                throws IOException
+        {
+            List<ModelProperty> modelProperties =
+                ModelMarshaller.marshallXmlToModelProperties( new ByteArrayInputStream(xml.getBytes()),
ProjectUri.baseUri,
+                        PomTransformer.URIS );
+
+            Map<String, String> aliases = new HashMap<String, String>();
+            aliases.put( "project.", "pom.");
+
+            List<InterpolatorProperty> ips = new ArrayList<InterpolatorProperty>(interpolatorProperties);
+            ips.addAll(ModelTransformerContext.createInterpolatorProperties(modelProperties,
ProjectUri.baseUri, aliases,
+                            PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false));
+
+            for(ModelProperty mp : modelProperties)
+            {
+                if(mp.getUri().startsWith(ProjectUri.properties) && mp.getValue()
!= null )
+                {
+                    String uri = mp.getUri();
+                    ips.add( new InterpolatorProperty( "${" + uri.substring( uri.lastIndexOf(
"/" ) + 1,
+                            uri.length() ) + "}", mp.getValue() ) );
+                }
+            }
+
+            ModelTransformerContext.interpolateModelProperties( modelProperties, ips );
+            return ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri
);
+        }
+
+        public static String interpolateModelAsString(Model model, List<InterpolatorProperty>
interpolatorProperties, File projectDirectory)
+                throws IOException
+        {
+            PomClassicDomainModel domainModel = new PomClassicDomainModel( model );
+            domainModel.setProjectDirectory( projectDirectory );
+            List<ModelProperty> modelProperties =
+                    ModelMarshaller.marshallXmlToModelProperties( domainModel.getInputStream(),
ProjectUri.baseUri, PomTransformer.URIS );
+            interpolateModelProperties( modelProperties, interpolatorProperties, domainModel);
+
+            return ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri
);
+        }
+
+        public static Model interpolateModel(Model model, List<InterpolatorProperty>
interpolatorProperties, File projectDirectory)
+            throws IOException
+        {
+            String pomXml = interpolateModelAsString( model, interpolatorProperties, projectDirectory
);
+            PomClassicDomainModel domainModel = new PomClassicDomainModel( new ByteArrayInputStream(
pomXml.getBytes() ));
+            return domainModel.getModel();
+        }
+
+        private static final Map<String, String> aliases = new HashMap<String, String>();
+
+        private static void addProjectAlias( String element, boolean leaf )
+        {
+            String suffix = leaf ? "\\}" : "\\.";
+            aliases.put( "\\$\\{project\\." + element + suffix, "\\$\\{" + element + suffix
);
+        }
+
+        static
+        {
+            aliases.put( "\\$\\{project\\.", "\\$\\{pom\\.");
+            addProjectAlias( "modelVersion", true );
+            addProjectAlias( "groupId", true );
+            addProjectAlias( "artifactId", true );
+            addProjectAlias( "version", true );
+            addProjectAlias( "packaging", true );
+            addProjectAlias( "name", true );
+            addProjectAlias( "description", true );
+            addProjectAlias( "inceptionYear", true );
+            addProjectAlias( "url", true );
+            addProjectAlias( "parent", false );
+            addProjectAlias( "prerequisites", false );
+            addProjectAlias( "organization", false );
+            addProjectAlias( "build", false );
+            addProjectAlias( "reporting", false );
+            addProjectAlias( "scm", false );
+            addProjectAlias( "distributionManagement", false );
+            addProjectAlias( "issueManagement", false );
+            addProjectAlias( "ciManagement", false );
+        }
+
+        public static void interpolateModelProperties(List<ModelProperty> modelProperties,
+                                                       List<InterpolatorProperty> interpolatorProperties,
+                                                       PomClassicDomainModel domainModel)
+               throws IOException
+        {
+            if(!containsProjectVersion(interpolatorProperties))
+            {
+                aliases.put("\\$\\{project.version\\}", "\\$\\{version\\}");
+            }
+
+            List<ModelProperty> firstPassModelProperties = new ArrayList<ModelProperty>();
+            List<ModelProperty> secondPassModelProperties = new ArrayList<ModelProperty>();
+
+            ModelProperty buildProperty = new ModelProperty(ProjectUri.Build.xUri, null);
+            for(ModelProperty mp : modelProperties)
+            {
+                if( mp.getValue() != null && !mp.getUri().contains( "#property" )
&& !mp.getUri().contains( "#collection" ))
+                {
+                    if( !buildProperty.isParentOf( mp ) || mp.getUri().equals(ProjectUri.Build.finalName
) )
+                    {
+                        firstPassModelProperties.add(mp);
+                    }
+                    else
+                    {
+                        secondPassModelProperties.add(mp);
+                    }
+                }
+            }
+
+
+            List<InterpolatorProperty> standardInterpolatorProperties = new ArrayList<InterpolatorProperty>();
+            if(domainModel.isPomInBuild())
+            {
+                String basedir = domainModel.getProjectDirectory().getAbsolutePath();
+                standardInterpolatorProperties.add(new InterpolatorProperty("${project.basedir}",
basedir,
+                        PomInterpolatorTag.PROJECT_PROPERTIES.name() ));
+                standardInterpolatorProperties.add(new InterpolatorProperty("${basedir}",
basedir,
+                        PomInterpolatorTag.PROJECT_PROPERTIES.name() ));
+                standardInterpolatorProperties.add(new InterpolatorProperty("${pom.basedir}",
basedir,
+                        PomInterpolatorTag.PROJECT_PROPERTIES.name() ));
+
+            }
+
+            for(ModelProperty mp : modelProperties)
+            {
+                if(mp.getUri().startsWith(ProjectUri.properties) && mp.getValue()
!= null )
+                {
+                    String uri = mp.getUri();
+                    standardInterpolatorProperties.add( new InterpolatorProperty( "${" +
uri.substring( uri.lastIndexOf( "/" ) + 1,
+                            uri.length() ) + "}", mp.getValue(), PomInterpolatorTag.PROJECT_PROPERTIES.name()
) );
+                }
+            }
+
+            //FIRST PASS - Withhold using build directories as interpolator properties
+            List<InterpolatorProperty> ips1 = new ArrayList<InterpolatorProperty>(interpolatorProperties);
+            ips1.addAll(standardInterpolatorProperties);
+            ips1.addAll(ModelTransformerContext.createInterpolatorProperties(firstPassModelProperties,
ProjectUri.baseUri, aliases,
+                            PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false));
+            Collections.sort(ips1, new Comparator<InterpolatorProperty>()
+            {
+                public int compare(InterpolatorProperty o, InterpolatorProperty o1) {
+                    return PomInterpolatorTag.valueOf(o.getTag()).compareTo(PomInterpolatorTag.valueOf(o1.getTag()));
+                }
+            });
+
+            ModelTransformerContext.interpolateModelProperties( modelProperties, ips1 );
+
+            //SECOND PASS - Set absolute paths on build directories
+            if( domainModel.isPomInBuild() )
+            {   String basedir = domainModel.getProjectDirectory().getAbsolutePath();
+                Map<ModelProperty, ModelProperty> buildDirectories = new HashMap<ModelProperty,
ModelProperty>();
+                for(ModelProperty mp : secondPassModelProperties)
+                {
+                    if(mp.getUri().equals( ProjectUri.Build.directory ))
+                    {
+                        File file = new File(mp.getResolvedValue());
+                        if( !file.isAbsolute() )
+                        {
+                            buildDirectories.put(mp, new ModelProperty(mp.getUri(), new File(basedir,
file.getPath()).getAbsolutePath()));
+                        }
+                    }
+                }
+
+                for ( Map.Entry<ModelProperty, ModelProperty> e : buildDirectories.entrySet()
)
+                {
+                    secondPassModelProperties.remove( e.getKey() );
+                    secondPassModelProperties.add(e.getValue() );
+                }
+            }
+
+            //THIRD PASS - Use build directories as interpolator properties
+            List<InterpolatorProperty> ips2 = new ArrayList<InterpolatorProperty>(interpolatorProperties);
+            ips2.addAll(standardInterpolatorProperties);
+            ips2.addAll(ModelTransformerContext.createInterpolatorProperties(secondPassModelProperties,
ProjectUri.baseUri, aliases,
+                            PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false));
+            ips2.addAll(interpolatorProperties);
+            Collections.sort(ips2, new Comparator<InterpolatorProperty>()
+            {
+                public int compare(InterpolatorProperty o, InterpolatorProperty o1) {
+                    return PomInterpolatorTag.valueOf(o.getTag()).compareTo(PomInterpolatorTag.valueOf(o1.getTag()));
+                }
+            });
+
+            ModelTransformerContext.interpolateModelProperties( modelProperties, ips2 );
+        }
+
+        private static boolean containsProjectVersion( List<InterpolatorProperty> interpolatorProperties
)
+        {
+            InterpolatorProperty versionInterpolatorProperty =
+                    new ModelProperty( ProjectUri.version, "").asInterpolatorProperty( ProjectUri.baseUri);
+            for( InterpolatorProperty ip : interpolatorProperties)
+            {
+                if ( ip.equals( versionInterpolatorProperty ) )
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
 }



Mime
View raw message