From 57756314e254a2eaa6378f3300e166981ed30e5e Mon Sep 17 00:00:00 2001 From: Britton Isbell Date: Thu, 16 Apr 2009 16:50:46 +0000 Subject: [PATCH] Support for build extensions. Updated maven-mercury to use latest project builder code. Dumped all references to model-builder. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@765684 13f79535-47bb-0310-9956-ffa450edef68 --- maven-core/pom.xml | 22 +- .../listeners/BuildExtensionListener.java | 93 +- .../listeners/MavenModelEventListener.java | 3 +- .../maven/plugin/DefaultPluginManager.java | 16 +- .../listeners/BuildExtensionListenerTest.java | 56 +- .../maven/project/harness/PomTestWrapper.java | 153 +-- maven-mercury/pom.xml | 11 +- .../mercury/MavenDependencyProcessor.java | 53 +- .../mercury/MavenDependencyProcessor2.java | 78 -- .../maven/mercury/MavenDomainModel.java | 252 +---- .../mercury/MavenDomainModelFactory.java | 38 - .../apache/maven/mercury/PomProcessor.java | 16 - .../maven/mercury/PomProcessorException.java | 36 - .../AlwaysJoinModelContainerFactory.java | 63 -- .../ArtifactModelContainerFactory.java | 241 ----- .../ExclusionModelContainerFactory.java | 62 -- .../factories/IdModelContainerFactory.java | 127 --- ...luginExecutionIdModelContainerFactory.java | 86 -- ...luginReportSetIdModelContainerFactory.java | 85 -- .../builder/legacy/DataSourceRule.java | 9 - .../project/builder/legacy/JoinRule.java | 11 - .../builder/legacy/PomClassicDomainModel.java | 441 --------- .../legacy/PomClassicDomainModelFactory.java | 16 - .../builder/legacy/PomTransformer.java | 881 ------------------ .../legacy/TransformerRemovalRule.java | 12 - .../builder/legacy/TransformerRule.java | 12 - .../builder/profile/ActiveProfileMatcher.java | 18 - .../builder/profile/ByDefaultMatcher.java | 24 - .../project/builder/profile/FileMatcher.java | 47 - .../project/builder/profile/JdkMatcher.java | 195 ---- .../profile/OperatingSystemMatcher.java | 62 -- .../builder/profile/ProfileContext.java | 88 -- .../project/builder/profile/ProfileUri.java | 178 ---- .../builder/profile/PropertyMatcher.java | 46 - ...DefaultDependencyScopeTransformerRule.java | 46 - .../DefaultExecutionIdTransformerRule.java | 29 - .../DependencyManagementDataSourceRule.java | 67 -- .../project/builder/rules/DependencyRule.java | 18 - .../DuplicateFiltersTransformerRule.java | 34 - .../project/builder/rules/ExecutionRule.java | 100 -- .../rules/MissingGroupIdTransformerRule.java | 28 - .../rules/MissingVersionTransformerRule.java | 27 - .../ModulesNotInheritedTransformerRule.java | 31 - .../NameNotInheritedTransformerRule.java | 33 - ...heritedPluginExecutionTransformerRule.java | 56 -- .../NotInheritedPluginTransformerRule.java | 51 - .../rules/OverideConfigTransformerRule.java | 61 -- .../PackagingNotInheritedTransformerRule.java | 30 - ...lativePathNotInheritedTransformerRule.java | 33 - .../project/builder/ModelEventListener.java | 5 +- .../builder/PomClassicDomainModel.java | 2 +- .../project/builder/ProcessorContext.java | 43 +- .../project/DefaultMavenProjectBuilder.java | 8 +- .../maven/project/PomConstructionTest.java | 2 - 54 files changed, 149 insertions(+), 4086 deletions(-) delete mode 100644 maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor2.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModelFactory.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessor.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessorException.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/factories/AlwaysJoinModelContainerFactory.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/factories/ArtifactModelContainerFactory.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/factories/ExclusionModelContainerFactory.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/factories/IdModelContainerFactory.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/factories/PluginExecutionIdModelContainerFactory.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/factories/PluginReportSetIdModelContainerFactory.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/DataSourceRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/JoinRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomClassicDomainModel.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomClassicDomainModelFactory.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomTransformer.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/TransformerRemovalRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/TransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ActiveProfileMatcher.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ByDefaultMatcher.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/profile/FileMatcher.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/profile/OperatingSystemMatcher.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ProfileContext.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ProfileUri.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/profile/PropertyMatcher.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DefaultDependencyScopeTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DefaultExecutionIdTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DependencyManagementDataSourceRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DependencyRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DuplicateFiltersTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/ExecutionRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/MissingGroupIdTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/MissingVersionTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/ModulesNotInheritedTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NameNotInheritedTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NotInheritedPluginExecutionTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NotInheritedPluginTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/OverideConfigTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/PackagingNotInheritedTransformerRule.java delete mode 100644 maven-mercury/src/main/java/org/apache/maven/project/builder/rules/RelativePathNotInheritedTransformerRule.java diff --git a/maven-core/pom.xml b/maven-core/pom.xml index 7364f4963c..88558efb80 100644 --- a/maven-core/pom.xml +++ b/maven-core/pom.xml @@ -28,10 +28,6 @@ org.apache.maven maven-reporting-api - - org.apache.maven - maven-model - org.apache.maven @@ -109,10 +105,6 @@ maven-mercury ${project.version} - - org.sonatype.spice - model-builder - org.sonatype.plexus plexus-sec-dispatcher @@ -121,6 +113,20 @@ commons-jxpath commons-jxpath + + + org.apache.maven.mercury + mercury-repo-remote-m2 + ${mercuryVersion} + test + + + org.apache.maven.mercury + mercury-transport-http + ${mercuryVersion} + test + + diff --git a/maven-core/src/main/java/org/apache/maven/listeners/BuildExtensionListener.java b/maven-core/src/main/java/org/apache/maven/listeners/BuildExtensionListener.java index d529548f9a..58d084842d 100644 --- a/maven-core/src/main/java/org/apache/maven/listeners/BuildExtensionListener.java +++ b/maven-core/src/main/java/org/apache/maven/listeners/BuildExtensionListener.java @@ -2,17 +2,13 @@ package org.apache.maven.listeners; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.builder.factories.ArtifactModelContainerFactory; +import org.apache.maven.model.Extension; +import org.apache.maven.model.Model; import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.shared.model.DataSourceException; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelContainerFactory; -import org.apache.maven.shared.model.ModelProperty; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Configuration; @@ -43,81 +39,17 @@ public class BuildExtensionListener @Requirement PlexusPluginManager pluginManager; - private List buildExtensions = new ArrayList(); - - public void fire(List modelContainers) - throws DataSourceException - { - if ( !inBuild ) - { - return; - } - - for ( ModelContainer mc : modelContainers ) - { - if ( hasExtension( mc ) ) - { - buildExtensions.add( new BuildExtension( mc.getProperties() ) ); - } - } + private List buildExtensions = new ArrayList(); + + public void fire(Model model) + { + buildExtensions.addAll(new ArrayList(model.getBuild().getExtensions())); } public List getUris() { return Arrays.asList( ProjectUri.Build.Extensions.Extension.xUri ); } - - public Collection getModelContainerFactories() - { - return Arrays.asList( (ModelContainerFactory) new ArtifactModelContainerFactory() ); - } - - private static boolean hasExtension( ModelContainer container ) - { - for ( ModelProperty mp : container.getProperties() ) - { - if ( mp.getUri().equals( ProjectUri.Build.Extensions.Extension.xUri ) ) - { - return true; - } - } - return false; - } - - private static class BuildExtension - { - private String groupId; - - private String artifactId; - - private String version; - - public BuildExtension( String groupId, String artifactId, String version ) - { - this.groupId = groupId; - this.artifactId = artifactId; - this.version = version; - } - - BuildExtension( List modelProperties ) - { - for ( ModelProperty mp : modelProperties ) - { - if ( mp.getUri().equals( ProjectUri.Build.Extensions.Extension.groupId ) ) - { - groupId = mp.getValue(); - } - else if ( mp.getUri().equals( ProjectUri.Build.Extensions.Extension.artifactId ) ) - { - artifactId = mp.getValue(); - } - else if ( mp.getUri().equals( ProjectUri.Build.Extensions.Extension.version ) ) - { - version = mp.getValue(); - } - } - } - } /** * Take the extension elements that were found during the POM construction process and now @@ -129,11 +61,16 @@ public class BuildExtensionListener * @param session Maven session used as the execution context for the current Maven project. */ public void processModelContainers( MavenSession session ) - { - for ( BuildExtension be : buildExtensions ) + { + if(!inBuild) + { + return; + } + + for ( Extension be : buildExtensions ) { PluginResolutionRequest request = new PluginResolutionRequest() - .setPluginMetadata( new PluginMetadata( be.groupId, be.artifactId, be.version ) ) + .setPluginMetadata( new PluginMetadata( be.getGroupId(), be.getArtifactId(), be.getVersion() ) ) .addLocalRepository( session.getRequest().getLocalRepositoryPath() ) .setRemoteRepositories( convertToMercuryRepositories( session.getRequest().getRemoteRepositories() ) ); diff --git a/maven-core/src/main/java/org/apache/maven/listeners/MavenModelEventListener.java b/maven-core/src/main/java/org/apache/maven/listeners/MavenModelEventListener.java index d122a6624b..d7bf7c69fb 100644 --- a/maven-core/src/main/java/org/apache/maven/listeners/MavenModelEventListener.java +++ b/maven-core/src/main/java/org/apache/maven/listeners/MavenModelEventListener.java @@ -1,7 +1,8 @@ package org.apache.maven.listeners; import org.apache.maven.execution.MavenSession; -import org.apache.maven.shared.model.ModelEventListener; +import org.apache.maven.project.builder.ModelEventListener; + public interface MavenModelEventListener extends ModelEventListener diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 356440a408..23a7f19b36 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -73,9 +73,11 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.artifact.InvalidDependencyVersionException; +import org.apache.maven.project.builder.InterpolatorProperty; +import org.apache.maven.project.builder.ModelProperty; import org.apache.maven.project.builder.PomInterpolatorTag; +import org.apache.maven.project.builder.ProcessorContext; import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.PomTransformer; import org.apache.maven.project.path.PathTranslator; import org.apache.maven.realm.MavenRealmManager; import org.apache.maven.realm.RealmManagementException; @@ -83,10 +85,6 @@ import org.apache.maven.realm.RealmScanningUtils; import org.apache.maven.reporting.MavenReport; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.VersionNotFoundException; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.apache.maven.shared.model.ModelMarshaller; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.ModelTransformerContext; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; @@ -1531,13 +1529,13 @@ public class DefaultPluginManager private static String interpolateXmlString( String xml, List interpolatorProperties ) throws IOException { - List modelProperties = ModelMarshaller.marshallXmlToModelProperties( new ByteArrayInputStream( xml.getBytes() ), ProjectUri.baseUri, PomTransformer.URIS ); + List modelProperties = ProcessorContext.marshallXmlToModelProperties( new ByteArrayInputStream( xml.getBytes() ), ProjectUri.baseUri, ProcessorContext.URIS ); Map aliases = new HashMap(); aliases.put( "project.", "pom." ); List ips = new ArrayList( interpolatorProperties ); - ips.addAll( ModelTransformerContext.createInterpolatorProperties( modelProperties, ProjectUri.baseUri, aliases, PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false ) ); + ips.addAll( ProcessorContext.createInterpolatorProperties( modelProperties, ProjectUri.baseUri, aliases, PomInterpolatorTag.PROJECT_PROPERTIES.name()) ); for ( ModelProperty mp : modelProperties ) { @@ -1548,8 +1546,8 @@ public class DefaultPluginManager } } - ModelTransformerContext.interpolateModelProperties( modelProperties, ips ); - return ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri ); + ProcessorContext.interpolateModelProperties( modelProperties, ips ); + return ProcessorContext.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri ); } // Plugin Prefix Loader diff --git a/maven-core/src/test/java/org/apache/maven/listeners/BuildExtensionListenerTest.java b/maven-core/src/test/java/org/apache/maven/listeners/BuildExtensionListenerTest.java index 3a1318f8e5..f62feaa5ed 100644 --- a/maven-core/src/test/java/org/apache/maven/listeners/BuildExtensionListenerTest.java +++ b/maven-core/src/test/java/org/apache/maven/listeners/BuildExtensionListenerTest.java @@ -11,13 +11,12 @@ import org.apache.maven.execution.DuplicateProjectException; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; +import org.apache.maven.model.Build; +import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.monitor.event.DefaultEventDispatcher; import org.apache.maven.project.MavenProject; import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelContainerAction; -import org.apache.maven.shared.model.ModelProperty; import org.apache.maven.wagon.Wagon; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.dag.CycleDetectedException; @@ -28,19 +27,21 @@ public class BuildExtensionListenerTest public void testBuildExtensionListener() throws Exception { - /*DISABLE - the listener is in the old model-builder code - need to add back in support BuildExtensionListener listener = (BuildExtensionListener) lookup( MavenModelEventListener.class, "extensions" ); - // Create the model properties and the model container to feed to the event firing - List modelProperties = new ArrayList(); - modelProperties.add( new ModelProperty( ProjectUri.Build.Extensions.Extension.xUri, null ) ); - modelProperties.add( new ModelProperty( ProjectUri.Build.Extensions.Extension.groupId, "org.apache.maven.wagon" ) ); - modelProperties.add( new ModelProperty( ProjectUri.Build.Extensions.Extension.artifactId, "wagon-webdav" ) ); - modelProperties.add( new ModelProperty( ProjectUri.Build.Extensions.Extension.version, "1.0-beta-2" ) ); - ModelContainer container = new TestModelContainer( modelProperties ); - + Extension extension = new Extension(); + extension.setGroupId("org.apache.maven.wagon" ); + extension.setArtifactId("wagon-webdav" ); + extension.setVersion( "1.0-beta-2" ); + + Build build = new Build(); + build.addExtension(extension); + + Model model = new Model(); + model.setBuild(build); + // Fire the event. - listener.fire( Arrays.asList( container ) ); + listener.fire( model ); try { @@ -56,9 +57,7 @@ public class BuildExtensionListenerTest listener.processModelContainers( newMavenSession() ); // Now we should be able to find the extension. - // lookup( Wagon.class, "dav" ); - * */ - + lookup( Wagon.class, "dav" ); } private MavenSession newMavenSession() @@ -78,29 +77,4 @@ public class BuildExtensionListenerTest return session; } - public class TestModelContainer - implements ModelContainer - { - List modelProperties; - - public TestModelContainer( List properties ) - { - this.modelProperties = properties; - } - - public List getProperties() - { - return new ArrayList( modelProperties ); - } - - public ModelContainerAction containerAction( ModelContainer modelContainer ) - { - return null; - } - - public ModelContainer createNewInstance( List modelProperties ) - { - return null; - } - } } diff --git a/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java b/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java index d5465398e9..6483d991b2 100644 --- a/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java +++ b/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java @@ -20,26 +20,18 @@ package org.apache.maven.project.harness; */ import java.io.*; -import java.util.HashMap; import java.util.Iterator; -import java.util.List; -import java.util.Map; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathNotFoundException; import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl; -import org.apache.maven.model.Model; -import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.project.builder.legacy.PomClassicDomainModel; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.model.ModelProperty; -import org.codehaus.plexus.util.WriterFactory; +import org.apache.maven.project.builder.PomClassicDomainModel; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; public class PomTestWrapper { - private PomClassicDomainModel domainModel; private File pomFile; @@ -125,7 +117,7 @@ public class PomTestWrapper { try { - domainModel = convertToDomainModel( mavenProject.getModel() ); + domainModel = new PomClassicDomainModel( mavenProject.getModel() ); int lineageCount = 1; for ( MavenProject parent = mavenProject.getParent(); parent != null; parent = parent.getParent() ) { @@ -142,30 +134,6 @@ public class PomTestWrapper return this.domainModel; } - private PomClassicDomainModel convertToDomainModel(Model model) throws IOException - { - if ( model == null ) - { - throw new IllegalArgumentException( "model: null" ); - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - Writer out = null; - MavenXpp3Writer writer = new MavenXpp3Writer(); - try - { - out = WriterFactory.newXmlWriter( baos ); - writer.write( out, model ); - } - finally - { - if ( out != null ) - { - out.close(); - } - } - return new PomClassicDomainModel(new ByteArrayInputStream(baos.toByteArray())); - } - public File getBasedir() { return ( pomFile != null ) ? pomFile.getParentFile() : null; @@ -176,20 +144,6 @@ public class PomTestWrapper context.setValue( expression, value ); } - /* - public int containerCountForUri( String uri ) - throws IOException - { - if ( uri == null || uri.trim().equals( "" ) ) - { - throw new IllegalArgumentException( "uri: null or empty" ); - } - ModelDataSource source = new DefaultModelDataSource(); - source.init( domainModel.getModelProperties(), null ); - return source.queryFor( uri ).size(); - } - */ - public Iterator getIteratorForXPathExpression( String expression ) { return context.iterate( expression ); @@ -216,107 +170,4 @@ public class PomTestWrapper { return context.getValue( expression ) != null && context.getValue( expression ).equals( value ); } - - public Map asMap( boolean withResolvedValues ) - throws IOException - { - Map map = new HashMap(); - for ( ModelProperty mp : domainModel.getModelProperties() ) - { - if ( withResolvedValues ) - { - map.put( mp.getUri(), mp.getResolvedValue() ); - } - else - { - map.put( mp.getUri(), mp.getValue() ); - } - - } - return map; - } - - public boolean containsModelProperty( ModelProperty modelProperty ) - throws IOException - { - return domainModel.getModelProperties().contains( modelProperty ); - } - - public boolean containsAllModelPropertiesOf( List modelProperties ) - throws IOException - { - for ( ModelProperty mp : modelProperties ) - { - if ( !containsModelProperty( mp ) ) - { - return false; - } - } - return true; - } - - public boolean matchModelProperties( List hasProperties, List doesNotHaveProperties ) - throws IOException - { - return containsAllModelPropertiesOf( hasProperties ) && containNoModelPropertiesOf( doesNotHaveProperties ); - } - - public boolean matchUris( List hasAllUris, List doesNotHaveUris ) - throws IOException - { - return hasAllUris( hasAllUris ) && hasNoUris( doesNotHaveUris ); - } - - public boolean containNoModelPropertiesOf( List modelProperties ) - throws IOException - { - for ( ModelProperty mp : modelProperties ) - { - if ( containsModelProperty( mp ) ) - { - return false; - } - } - return true; - } - - public boolean hasUri( String uri ) - throws IOException - { - for ( ModelProperty mp : domainModel.getModelProperties() ) - { - if ( mp.getValue().equals( uri ) ) - { - return true; - } - } - return false; - } - - public boolean hasAllUris( List uris ) - throws IOException - { - for ( String s : uris ) - { - if ( !hasUri( s ) ) - { - return false; - } - } - return true; - } - - public boolean hasNoUris( List uris ) - throws IOException - { - for ( String s : uris ) - { - if ( hasUri( s ) ) - { - return false; - } - } - return true; - } - } diff --git a/maven-mercury/pom.xml b/maven-mercury/pom.xml index a4c9ce31cb..8f1dce6a21 100644 --- a/maven-mercury/pom.xml +++ b/maven-mercury/pom.xml @@ -42,11 +42,6 @@ plexus-component-annotations - - org.sonatype.spice - model-builder - - org.apache.maven.mercury @@ -85,6 +80,12 @@ test + + commons-cli + commons-cli + test + + junit junit diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java index 8814e6843b..833b92780d 100644 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java +++ b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java @@ -21,7 +21,6 @@ package org.apache.maven.mercury; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -30,14 +29,11 @@ import org.apache.maven.mercury.builder.api.DependencyProcessor; import org.apache.maven.mercury.builder.api.DependencyProcessorException; import org.apache.maven.mercury.builder.api.MetadataReader; import org.apache.maven.mercury.builder.api.MetadataReaderException; +import org.apache.maven.project.builder.DomainModel; +import org.apache.maven.project.builder.InterpolatorProperty; +import org.apache.maven.project.builder.PomClassicDomainModel; import org.apache.maven.project.builder.PomInterpolatorTag; -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.PomTransformer; -import org.apache.maven.shared.model.DomainModel; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.ModelTransformerContext; +import org.apache.maven.project.builder.ProcessorContext; import org.codehaus.plexus.component.annotations.Component; /** @@ -52,6 +48,7 @@ import org.codehaus.plexus.component.annotations.Component; public class MavenDependencyProcessor implements DependencyProcessor { + /** * Over-ride this method to change how dependencies are obtained */ @@ -88,14 +85,14 @@ public class MavenDependencyProcessor MavenDomainModel domainModel = new MavenDomainModel( superBytes ); domainModel.setMostSpecialized(true); domainModels.add( domainModel ); - +/*TODO: Profiles Collection activeProfiles = domainModel.getActiveProfileContainers( interpolatorProperties ); for ( ModelContainer mc : activeProfiles ) { domainModels.add( new MavenDomainModel( transformProfiles( mc.getProperties() ) ) ); } - +*/ List parentModels = getParentsOfDomainModel( domainModel, mdReader ); if ( parentModels == null ) @@ -110,21 +107,13 @@ public class MavenDependencyProcessor throw new MetadataReaderException( "Failed to create domain model. Message = " + e.getMessage(), e ); } - PomTransformer transformer = new PomTransformer( new MavenDomainModelFactory() ); - ModelTransformerContext ctx = - new ModelTransformerContext( PomTransformer.MODEL_CONTAINER_INFOS ); + try { + return new MavenDomainModel(ProcessorContext.interpolateDomainModel(ProcessorContext.build(domainModels, null), + interpolatorProperties)).getDependencyMetadata(); + } catch (IOException e) { + throw new DependencyProcessorException(); + } - try - { - MavenDomainModel model = - ( (MavenDomainModel) ctx.transform( domainModels, transformer, transformer, null, - interpolatorProperties, null ) ); - return model.getDependencyMetadata(); - } - catch ( IOException e ) - { - throw new MetadataReaderException( "Unable to transform model", e ); - } } protected final List createInterpolatorProperties(Map system, Map user) @@ -165,20 +154,4 @@ public class MavenDependencyProcessor } return domainModels; } - - private static List transformProfiles( List modelProperties ) - { - List properties = new ArrayList(); - for ( ModelProperty mp : modelProperties ) - { - if ( mp.getUri().startsWith( ProjectUri.Profiles.Profile.xUri ) - && !mp.getUri().equals( ProjectUri.Profiles.Profile.id ) - && !mp.getUri().startsWith( ProjectUri.Profiles.Profile.Activation.xUri ) ) - { - properties.add( new ModelProperty( mp.getUri().replace( ProjectUri.Profiles.Profile.xUri, - ProjectUri.xUri ), mp.getResolvedValue() ) ); - } - } - return properties; - } } diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor2.java b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor2.java deleted file mode 100644 index 124831bcf9..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor2.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.apache.maven.mercury; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.maven.mercury.artifact.ArtifactMetadata; -import org.apache.maven.mercury.builder.api.DependencyProcessor; -import org.apache.maven.mercury.builder.api.DependencyProcessorException; -import org.apache.maven.mercury.builder.api.MetadataReader; -import org.apache.maven.mercury.builder.api.MetadataReaderException; -import org.apache.maven.project.builder.ProcessorContext; -import org.apache.maven.shared.model.DomainModel; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.codehaus.plexus.component.annotations.Component; - -@Component( role=DependencyProcessor.class, hint="maven2" ) -public class MavenDependencyProcessor2 - extends MavenDependencyProcessor -{ - public List getDependencies( ArtifactMetadata bmd, MetadataReader mdReader, Map system, - Map user ) - throws MetadataReaderException, DependencyProcessorException - { - if ( bmd == null ) - { - throw new IllegalArgumentException( "bmd: null" ); - } - - if ( mdReader == null ) - { - throw new IllegalArgumentException( "mdReader: null" ); - } - - List interpolatorProperties = createInterpolatorProperties(system, user); - - List domainModels = new ArrayList(); - try - { - byte[] superBytes = mdReader.readMetadata( bmd ); - - if ( superBytes == null || superBytes.length < 1 ) - { - throw new DependencyProcessorException( "cannot read metadata for " + bmd.getGAV() ); - } - - MavenDomainModel domainModel = new MavenDomainModel( superBytes ); - domainModel.setMostSpecialized(true); - domainModels.add( domainModel ); - - List parentModels = getParentsOfDomainModel( domainModel, mdReader ); - - if ( parentModels == null ) - { - throw new DependencyProcessorException( "cannot read parent for " + bmd.getGAV() ); - } - - domainModels.addAll( parentModels ); - } - catch ( IOException e ) - { - throw new MetadataReaderException( "Failed to create domain model. Message = " + e.getMessage(), e ); - } -/* - try - { - MavenDomainModel model = new MavenDomainModel(ProcessorContext.build(domainModels, interpolatorProperties)); - return model.getDependencyMetadata(); - } - catch ( IOException e ) - { - throw new MetadataReaderException( "Unable to transform model", e ); - } - */ - return null; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java index 3f20fce02d..67c9c7b4c0 100644 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java +++ b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java @@ -21,44 +21,19 @@ package org.apache.maven.mercury; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.List; import org.apache.maven.mercury.artifact.ArtifactMetadata; -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.factories.ArtifactModelContainerFactory; -import org.apache.maven.project.builder.factories.ExclusionModelContainerFactory; -import org.apache.maven.project.builder.legacy.PomClassicDomainModel; -import org.apache.maven.project.builder.legacy.PomTransformer; -import org.apache.maven.project.builder.profile.ProfileContext; -import org.apache.maven.shared.model.DataSourceException; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelDataSource; -import org.apache.maven.shared.model.ModelMarshaller; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.impl.DefaultModelDataSource; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Exclusion; +import org.apache.maven.model.Parent; +import org.apache.maven.project.builder.PomClassicDomainModel; -/** - * Provides a wrapper for the maven model. - */ public final class MavenDomainModel extends PomClassicDomainModel { - /** - * Bytes containing the underlying model - */ - private final List modelProperties; - - /** - * History of joins and deletes of model properties - */ - private String eventHistory; - private ArtifactMetadata parentMetadata; /** @@ -69,105 +44,74 @@ public final class MavenDomainModel public MavenDomainModel( byte[] bytes ) throws IOException { - this( new ByteArrayInputStream( bytes ) ); + super( new ByteArrayInputStream( bytes ) ); } - /** - * Constructor - * - * @throws IOException if there is a problem constructing the model - */ - public MavenDomainModel( InputStream inputStream ) - throws IOException - { - this( ModelMarshaller.marshallXmlToModelProperties( inputStream, ProjectUri.baseUri, PomTransformer.URIS ) ); - } - - /** - * Constructor - * - * @throws IOException if there is a problem constructing the model - */ - public MavenDomainModel( List modelProperties ) - throws IOException - { - super(modelProperties); - this.modelProperties = new ArrayList( modelProperties ); - } public MavenDomainModel(PomClassicDomainModel model) throws IOException { - this(model.getInputStream()); + super(model.getModel()); } public boolean hasParent() { - // TODO: Expensive call if no parent return getParentMetadata() != null; } public List getDependencyMetadata() - throws DataSourceException { List metadatas = new ArrayList(); - ModelDataSource source = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES ); - for ( ModelContainer modelContainer : source.queryFor( ProjectUri.Dependencies.Dependency.xUri ) ) + for(Dependency d: model.getDependencies()) { - metadatas.add( transformContainerToMetadata( modelContainer ) ); + ArtifactMetadata metadata = new ArtifactMetadata(); + metadata.setArtifactId(d.getArtifactId()); + metadata.setClassifier(d.getClassifier()); + metadata.setGroupId(d.getGroupId()); + metadata.setScope( (d.getScope() == null) ? "runtime" : d.getScope()); + metadata.setVersion(d.getVersion()); + metadata.setOptional(d.isOptional()); + + if( "test-jar".equals( d.getType() ) ) + { + metadata.setType( "jar" ); + metadata.setClassifier( "tests" ); + } + else + { + metadata.setType( d.getType() ); + } + + List exclusions = new ArrayList(); + for( Exclusion e : d.getExclusions() ) + { + ArtifactMetadata md = new ArtifactMetadata(); + md.setArtifactId(e.getArtifactId()); + md.setGroupId(e.getGroupId()); + exclusions.add(md); + } + metadata.setExclusions(exclusions); + metadatas.add(metadata); } - + return metadatas; } - public Collection getActiveProfileContainers( List properties ) - throws DataSourceException - { - ModelDataSource dataSource = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES ); - - return new ProfileContext( dataSource, null, null, properties ).getActiveProfiles(); - } - public ArtifactMetadata getParentMetadata() { - if ( parentMetadata != null ) + if(parentMetadata == null) { - return copyArtifactBasicMetadata( parentMetadata ); + Parent parent = model.getParent(); + if(parent != null) + { + parentMetadata = new ArtifactMetadata(); + parentMetadata.setArtifactId( parent.getArtifactId() ); + parentMetadata.setVersion( parent.getVersion() ); + parentMetadata.setGroupId( parent.getGroupId() ); + } } - - String groupId = null, artifactId = null, version = null; - - for ( ModelProperty mp : modelProperties ) - { - if ( mp.getUri().equals( ProjectUri.Parent.version ) ) - { - version = mp.getResolvedValue(); - } - else if ( mp.getUri().equals( ProjectUri.Parent.artifactId ) ) - { - artifactId = mp.getResolvedValue(); - } - else if ( mp.getUri().equals( ProjectUri.Parent.groupId ) ) - { - groupId = mp.getResolvedValue(); - } - if ( groupId != null && artifactId != null && version != null ) - { - break; - } - } - - if ( groupId == null || artifactId == null || version == null ) - { - return null; - } - parentMetadata = new ArtifactMetadata(); - parentMetadata.setArtifactId( artifactId ); - parentMetadata.setVersion( version ); - parentMetadata.setGroupId( groupId ); - - return copyArtifactBasicMetadata( parentMetadata ); + return (parentMetadata != null) ? copyArtifactBasicMetadata( parentMetadata ) : null; } private ArtifactMetadata copyArtifactBasicMetadata( ArtifactMetadata metadata ) @@ -178,108 +122,4 @@ public final class MavenDomainModel amd.setVersion( metadata.getVersion() ); return amd; } - - /** - * @see org.apache.maven.shared.model.DomainModel#getEventHistory() - */ - public String getEventHistory() - { - return eventHistory; - } - - /** - * @see org.apache.maven.shared.model.DomainModel#setEventHistory(String) - */ - public void setEventHistory( String eventHistory ) - { - if ( eventHistory == null ) - { - throw new IllegalArgumentException( "eventHistory: null" ); - } - this.eventHistory = eventHistory; - } - - public List getModelProperties() - throws IOException - { - return new ArrayList( modelProperties ); - } - - private ArtifactMetadata transformContainerToMetadata( ModelContainer container ) - throws DataSourceException - { - List modelProperties = container.getProperties(); - - ArtifactMetadata metadata = new ArtifactMetadata(); - for ( ModelProperty mp : modelProperties ) - { - if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.groupId ) ) - { - metadata.setGroupId( mp.getResolvedValue() ); - } - else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.artifactId ) ) - { - metadata.setArtifactId( mp.getResolvedValue() ); - } - else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.version ) ) - { - metadata.setVersion( mp.getResolvedValue() ); - } - else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.classifier ) ) - { - metadata.setClassifier( mp.getResolvedValue() ); - } - else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.scope ) ) - { - metadata.setScope( mp.getResolvedValue() ); - } - else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.type ) ) - { - String val = mp.getResolvedValue(); - // 2009-03-23 Oleg: TODO ask Shane where this really belongs? - if( "test-jar".equals( val ) ) - { - metadata.setType( "jar" ); - metadata.setClassifier( "tests" ); - } - else - metadata.setType( val ); - } - else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.optional ) ) - { - metadata.setOptional( mp.getResolvedValue() ); - } - } - - if ( metadata.getScope() == null ) - { - metadata.setScope( "runtime" ); - } - - ModelDataSource dataSource = new DefaultModelDataSource( container.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(), - new ExclusionModelContainerFactory() ) ); - List exclusions = new ArrayList(); - - for ( ModelContainer exclusion : dataSource.queryFor( ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri ) ) - { - ArtifactMetadata meta = new ArtifactMetadata(); - exclusions.add( meta ); - - for ( ModelProperty mp : exclusion.getProperties() ) - { - if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.artifactId ) ) - { - meta.setArtifactId( mp.getResolvedValue() ); - } - else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.groupId ) ) - { - meta.setGroupId( mp.getResolvedValue() ); - } - } - - } - metadata.setExclusions( exclusions ); - - return metadata; - } } diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModelFactory.java b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModelFactory.java deleted file mode 100644 index 11af600c13..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModelFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.maven.mercury; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; -import java.util.List; - -import org.apache.maven.shared.model.DomainModel; -import org.apache.maven.shared.model.DomainModelFactory; -import org.apache.maven.shared.model.ModelProperty; - -public class MavenDomainModelFactory - implements DomainModelFactory -{ - - public DomainModel createDomainModel( List modelProperties ) - throws IOException - { - return new MavenDomainModel( modelProperties ); - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessor.java b/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessor.java deleted file mode 100644 index d419059a03..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessor.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.apache.maven.mercury; - -import java.util.List; -import java.util.Map; - -import org.apache.maven.mercury.artifact.ArtifactMetadata; -import org.apache.maven.mercury.builder.api.MetadataReader; -import org.apache.maven.mercury.builder.api.MetadataReaderException; -import org.apache.maven.shared.model.ModelProperty; - -public interface PomProcessor -{ - List getRawPom(ArtifactMetadata bmd, MetadataReader mdReader, Map env, - Map sysProps) - throws MetadataReaderException, PomProcessorException; -} diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessorException.java b/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessorException.java deleted file mode 100644 index ad523233c7..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessorException.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.maven.mercury; - -public class PomProcessorException - extends Exception -{ - static final long serialVersionUID = 980457843528974352L; - - /** - * Default constructor - */ - public PomProcessorException() - { - super(); - } - - /** - * Constructor - * - * @param message exception message - */ - public PomProcessorException( String message ) - { - super( message ); - } - - /** - * Constructor - * - * @param message exception message - */ - public PomProcessorException( String message, Exception e ) - { - super( message, e ); - } - -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/AlwaysJoinModelContainerFactory.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/AlwaysJoinModelContainerFactory.java deleted file mode 100644 index cd566c8467..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/AlwaysJoinModelContainerFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.apache.maven.project.builder.factories; - -import org.apache.maven.shared.model.ModelContainerFactory; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.ModelContainerAction; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.*; - -public class AlwaysJoinModelContainerFactory - implements ModelContainerFactory -{ - - private static final Collection uris = Collections.unmodifiableList( Arrays.asList( - - ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.goal - // ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri - - ) ); - - public Collection getUris() - { - return uris; - } - - public ModelContainer create( List modelProperties ) - { - if ( modelProperties == null || modelProperties.size() == 0 ) - { - throw new IllegalArgumentException( "modelProperties: null or empty" ); - } - return new Anon_ModelContainer( modelProperties ); - } - - private static class Anon_ModelContainer - implements ModelContainer - { - - public Anon_ModelContainer(List properties) { - this.properties = new ArrayList(properties); - } - - private List properties; - - - public ModelContainerAction containerAction( ModelContainer modelContainer ) - { - return ModelContainerAction.JOIN; - } - - public ModelContainer createNewInstance( List modelProperties ) - { - return new Anon_ModelContainer( modelProperties ); - } - - public List getProperties() - { - return new ArrayList(properties); - } - - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/ArtifactModelContainerFactory.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/ArtifactModelContainerFactory.java deleted file mode 100644 index 11d420361a..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/ArtifactModelContainerFactory.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.apache.maven.project.builder.factories; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelContainerAction; -import org.apache.maven.shared.model.ModelContainerFactory; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -public final class ArtifactModelContainerFactory - implements ModelContainerFactory -{ - - private static final Collection uris = Collections.unmodifiableList( Arrays.asList( - ProjectUri.DependencyManagement.Dependencies.Dependency.xUri, - ProjectUri.Dependencies.Dependency.xUri, - ProjectUri.Reporting.Plugins.Plugin.xUri, - ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri, - ProjectUri.Build.Plugins.Plugin.xUri, - ProjectUri.Build.Extensions.Extension.xUri - ) ); - - private final Collection u; - - public Collection getUris() - { - return u; - } - - public ArtifactModelContainerFactory() { - u = uris; - } - - public ArtifactModelContainerFactory(String uri) { - u = Collections.unmodifiableList( Arrays.asList(uri) ); - } - - public ModelContainer create( List modelProperties ) - { - if ( modelProperties == null || modelProperties.size() == 0 ) - { - throw new IllegalArgumentException( "modelProperties: null or empty" ); - } - return new ArtifactModelContainer( modelProperties ); - } - - private static class ArtifactModelContainer - implements ModelContainer - { - - private String groupId; - - private String artifactId; - - private String version; - - private String type; - - private String scope; - - private String classifier; - - private String uri; - - private List properties; - - private static String findBaseUriFrom( List modelProperties ) - { - String baseUri = null; - for ( ModelProperty mp : modelProperties ) - { - if ( baseUri == null || mp.getUri().length() < baseUri.length() ) - { - baseUri = mp.getUri(); - } - } - return baseUri; - } - - private ArtifactModelContainer( List properties ) - { - this.properties = new ArrayList( properties ); - this.properties = Collections.unmodifiableList( this.properties ); - uri = findBaseUriFrom( this.properties ); - - for ( ModelProperty mp : this.properties ) - { - if ( version == null && mp.getUri().equals( uri + "/version" ) ) - { - this.version = mp.getResolvedValue(); - } - else if ( artifactId == null && mp.getUri().equals( uri + "/artifactId" ) ) - { - this.artifactId = mp.getResolvedValue(); - } - else if ( groupId == null && mp.getUri().equals( uri + "/groupId" ) ) - { - this.groupId = mp.getResolvedValue(); - } - else if ( scope == null && mp.getUri().equals( uri + "/scope" ) ) - { - this.scope = mp.getResolvedValue(); - } - else if ( classifier == null && mp.getUri().equals( uri + "/classifier" ) ) - { - this.classifier = mp.getResolvedValue(); - } - else if ( type == null && mp.getUri().equals( ProjectUri.Dependencies.Dependency.type ) - || mp.getUri().equals(ProjectUri.DependencyManagement.Dependencies.Dependency.type) - || mp.getUri().equals(ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.type) - || mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.type)) - { - this.type = mp.getResolvedValue(); - } - } - if ( groupId == null ) - { - if ( ProjectUri.Build.Plugins.Plugin.xUri.equals( uri ) - || ProjectUri.Profiles.Profile.Build.Plugins.Plugin.xUri.equals( uri ) - || ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri.equals( uri ) - || ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.xUri.equals( uri ) - || ProjectUri.Reporting.Plugins.Plugin.xUri.equals( uri ) - || ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.xUri.equals( uri )) - { - groupId = "org.apache.maven.plugins"; - } - else - { - throw new IllegalArgumentException( "Properties do not contain group id. Artifact ID = " - + artifactId + ", Version = " + version ); - } - } - - if ( artifactId == null ) - { - StringBuffer sb = new StringBuffer(); - for ( ModelProperty mp : properties ) - { - sb.append( mp ).append( "\r\n" ); - } - throw new IllegalArgumentException( "Properties does not contain artifact id. Group ID = " + groupId + - ", Version = " + version + ", Base = " + uri + ":\r\n" + sb ); - } - - if ( version == null ) - { - version = ""; - } - - if ( type == null ) - { - type = "jar"; - } - - if ( classifier == null ) - { - classifier = ""; - } - - if ( scope == null || scope.equals("provided")) - { - scope = "compile"; - } - } - - public ModelContainerAction containerAction( ModelContainer modelContainer ) - { - if ( modelContainer == null ) - { - throw new IllegalArgumentException( "modelContainer: null" ); - } - - if ( !( modelContainer instanceof ArtifactModelContainer ) ) - { - throw new IllegalArgumentException( "modelContainer: wrong type" ); - } - - ArtifactModelContainer c = (ArtifactModelContainer) modelContainer; - if ( c.groupId.equals( groupId ) && c.artifactId.equals( artifactId ) && c.type.equals( type ) - && c.classifier.equals( classifier )) - { - if ( uri.startsWith(ProjectUri.Build.Plugins.xUri) || c.version.equals( version ) - || version.equals("") || c.version.equals("")) - { - return ModelContainerAction.JOIN; - } - else - { - return ModelContainerAction.DELETE; - } - } - return ModelContainerAction.NOP; - } - - public ModelContainer createNewInstance( List modelProperties ) - { - return new ArtifactModelContainer( modelProperties ); - } - - public List getProperties() - { - return properties; - } - - public String toString() - { - StringBuffer sb = new StringBuffer(); - sb.append( "Group ID = " ).append( groupId ).append( ", Artifact ID = " ).append( artifactId ) - .append( ", Version" ).append( version ).append( "\r\n" ); - for ( ModelProperty mp : properties ) - { - sb.append( mp ).append( "\r\n" ); - } - return sb.toString(); - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/ExclusionModelContainerFactory.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/ExclusionModelContainerFactory.java deleted file mode 100644 index 795ff555a7..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/ExclusionModelContainerFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.project.builder.factories; - -import org.apache.maven.shared.model.ModelContainerFactory; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.ModelContainerAction; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.*; - -public class ExclusionModelContainerFactory implements ModelContainerFactory -{ - - private static final Collection uris = Collections.unmodifiableList( Arrays.asList( - - ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri - - ) ); - - public Collection getUris() - { - return uris; - } - - public ModelContainer create( List modelProperties ) - { - if ( modelProperties == null || modelProperties.size() == 0 ) - { - throw new IllegalArgumentException( "modelProperties: null or empty" ); - } - return new ExclusionModelContainer( modelProperties ); - } - - private static class ExclusionModelContainer - implements ModelContainer - { - - public ExclusionModelContainer(List properties) { - this.properties = properties; - } - - private List properties; - - - public ModelContainerAction containerAction( ModelContainer modelContainer ) - { - throw new UnsupportedOperationException(); - } - - public ModelContainer createNewInstance( List modelProperties ) - { - return new ExclusionModelContainer( modelProperties ); - } - - public List getProperties() - { - return properties; - } - - } -} - diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/IdModelContainerFactory.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/IdModelContainerFactory.java deleted file mode 100644 index 91ed3a74d2..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/IdModelContainerFactory.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.apache.maven.project.builder.factories; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelContainerAction; -import org.apache.maven.shared.model.ModelContainerFactory; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -public class IdModelContainerFactory - implements ModelContainerFactory -{ - - private String uri; - - public IdModelContainerFactory(String uri) - { - if(uri == null) - { - throw new IllegalArgumentException("uri: null"); - } - this.uri = uri; - } - - public static final List ID_CONTAINER_FACTORIES = - Collections.unmodifiableList(Arrays.asList(new IdModelContainerFactory(ProjectUri.PluginRepositories.PluginRepository.xUri), - new IdModelContainerFactory(ProjectUri.Repositories.Repository.xUri), - new IdModelContainerFactory(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri), - new IdModelContainerFactory(ProjectUri.Profiles.Profile.xUri), - new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri))); - - public Collection getUris() - { - return Collections.unmodifiableList(Arrays.asList(uri)); - } - - public ModelContainer create( List modelProperties ) - { - if ( modelProperties == null || modelProperties.size() == 0 ) - { - throw new IllegalArgumentException( "modelProperties: null or empty" ); - } - return new IdModelContainer( modelProperties ); - } - - private static class IdModelContainer - implements ModelContainer - { - - private String id; - - private List properties; - - private IdModelContainer( List properties ) - { - this.properties = new ArrayList( properties ); - this.properties = Collections.unmodifiableList( this.properties ); - - for ( ModelProperty mp : properties ) - { - if ( mp.getUri().endsWith( "/id" ) ) - { - this.id = mp.getResolvedValue(); - } - } - } - - public ModelContainerAction containerAction( ModelContainer modelContainer ) - { - if ( modelContainer == null ) - { - throw new IllegalArgumentException( "modelContainer: null" ); - } - - if ( !( modelContainer instanceof IdModelContainer ) ) - { - throw new IllegalArgumentException( "modelContainer: wrong type" ); - } - - IdModelContainer c = (IdModelContainer) modelContainer; - if ( c.id == null || id == null ) - { - return ModelContainerAction.NOP; - } - return ( c.id.equals( id ) ) ? ModelContainerAction.JOIN : ModelContainerAction.NOP; - } - - public ModelContainer createNewInstance( List modelProperties ) - { - return new IdModelContainer( modelProperties ); - } - - public List getProperties() - { - return properties; - } - - public String toString() - { - return "ID = " + id; - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/PluginExecutionIdModelContainerFactory.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/PluginExecutionIdModelContainerFactory.java deleted file mode 100644 index dc12e365ae..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/PluginExecutionIdModelContainerFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.project.builder.factories; - -import org.apache.maven.shared.model.ModelContainerFactory; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.ModelContainerAction; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.*; - -public class PluginExecutionIdModelContainerFactory implements ModelContainerFactory { - - private static final Collection uris = Collections.unmodifiableList(Arrays.asList( - ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri, - ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.Execution.xUri)); - - public Collection getUris() { - return uris; - } - - public ModelContainer create(List modelProperties) { - if ( modelProperties == null || modelProperties.size() == 0 ) - { - throw new IllegalArgumentException( "modelProperties: null or empty" ); - } - return new PluginExecutionIdModelContainer( modelProperties ); - } - - private static class PluginExecutionIdModelContainer - implements ModelContainer - { - - private String id; - - private List properties; - - private PluginExecutionIdModelContainer( List properties ) - { - this.properties = new ArrayList( properties ); - this.properties = Collections.unmodifiableList( this.properties ); - - for ( ModelProperty mp : properties ) - { - if ( mp.getUri().endsWith( "/id" ) ) - { - this.id = mp.getResolvedValue(); - } - } - } - - public ModelContainerAction containerAction( ModelContainer modelContainer ) - { - if ( modelContainer == null ) - { - throw new IllegalArgumentException( "modelContainer: null" ); - } - - if ( !( modelContainer instanceof PluginExecutionIdModelContainer ) ) - { - throw new IllegalArgumentException( "modelContainer: wrong type" ); - } - - PluginExecutionIdModelContainer c = (PluginExecutionIdModelContainer) modelContainer; - if ( c.id == null || id == null ) - { - return ModelContainerAction.NOP; - } - return ( c.id.equals( id ) ) ? ModelContainerAction.JOIN : ModelContainerAction.NOP; - } - - public ModelContainer createNewInstance( List modelProperties ) - { - return new PluginExecutionIdModelContainer( modelProperties ); - } - - public List getProperties() - { - return properties; - } - - public String toString() - { - return "ID = " + id; - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/PluginReportSetIdModelContainerFactory.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/PluginReportSetIdModelContainerFactory.java deleted file mode 100644 index 5f72881c31..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/factories/PluginReportSetIdModelContainerFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.apache.maven.project.builder.factories; - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.ModelContainerAction; -import org.apache.maven.shared.model.ModelContainerFactory; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.*; - -public class PluginReportSetIdModelContainerFactory implements ModelContainerFactory { - - private static final Collection uris = Collections.unmodifiableList(Arrays.asList( - ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri)); - - public Collection getUris() { - return uris; - } - - public ModelContainer create(List modelProperties) { - if ( modelProperties == null || modelProperties.size() == 0 ) - { - throw new IllegalArgumentException( "modelProperties: null or empty" ); - } - return new PluginReportSetIdModelContainer( modelProperties ); - } - - private static class PluginReportSetIdModelContainer - implements ModelContainer - { - - private String id; - - private List properties; - - private PluginReportSetIdModelContainer( List properties ) - { - this.properties = new ArrayList( properties ); - this.properties = Collections.unmodifiableList( this.properties ); - - for ( ModelProperty mp : properties ) - { - if ( mp.getUri().endsWith( "/id" ) ) - { - this.id = mp.getResolvedValue(); - } - } - } - - public ModelContainerAction containerAction( ModelContainer modelContainer ) - { - if ( modelContainer == null ) - { - throw new IllegalArgumentException( "modelContainer: null" ); - } - - if ( !( modelContainer instanceof PluginReportSetIdModelContainer ) ) - { - throw new IllegalArgumentException( "modelContainer: wrong type" ); - } - - PluginReportSetIdModelContainer c = (PluginReportSetIdModelContainer) modelContainer; - if ( c.id == null || id == null ) - { - return ModelContainerAction.NOP; - } - return ( c.id.equals( id ) ) ? ModelContainerAction.JOIN : ModelContainerAction.NOP; - } - - public ModelContainer createNewInstance( List modelProperties ) - { - return new PluginReportSetIdModelContainer( modelProperties ); - } - - public List getProperties() - { - return properties; - } - - public String toString() - { - return "ID = " + id; - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/DataSourceRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/DataSourceRule.java deleted file mode 100644 index e48d3ca316..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/DataSourceRule.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.apache.maven.project.builder.legacy; - -import org.apache.maven.shared.model.ModelDataSource; -import org.apache.maven.shared.model.DataSourceException; - -public interface DataSourceRule -{ - void execute(ModelDataSource dataSource) throws DataSourceException; -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/JoinRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/JoinRule.java deleted file mode 100644 index 2369263637..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/JoinRule.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.apache.maven.project.builder.legacy; - -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import java.util.List; - -public interface JoinRule -{ - List execute(List modelProperties) throws DataSourceException; -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomClassicDomainModel.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomClassicDomainModel.java deleted file mode 100644 index 5d79265418..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomClassicDomainModel.java +++ /dev/null @@ -1,441 +0,0 @@ -package org.apache.maven.project.builder.legacy; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.model.Model; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.ModelMarshaller; -import org.apache.maven.shared.model.InputStreamDomainModel; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; -import java.util.ArrayList; -import java.util.Set; -import java.util.HashSet; - -/** - * Provides a wrapper for the maven model. - */ -public class PomClassicDomainModel implements InputStreamDomainModel -{ - - /** - * Bytes containing the underlying model - */ - private byte[] inputBytes; - - /** - * History of joins and deletes of model properties - */ - private String eventHistory; - - private String id; - - private File file; - - private File parentFile; - - private File projectDirectory; - - private List modelProperties; - - private int lineageCount; - - private boolean isMostSpecialized = false; - - private String parentGroupId = null, parentArtifactId = null, parentVersion = null, parentId = null, parentRelativePath; - - private Model model; - - public Model getModel() throws IOException - { - if(model == null) - { - InputStream is; - try { - is = getInputStream(); - } catch (Exception e1) { - throw new IOException("inputStream not set"); - } - - MavenXpp3Reader reader = new MavenXpp3Reader(); - try - { - model = reader.read( is, false ) ; - } - catch ( XmlPullParserException e ) - { - throw new IOException( e.getMessage() ); - } - } - return model; - } - - public PomClassicDomainModel( List modelProperties ) - { - this.modelProperties = modelProperties; - try - { - String xml = ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri ); - inputBytes = xml.getBytes( "UTF-8" ); - } - catch ( IOException e ) - { - throw new IllegalStateException( "Unmarshalling of model properties failed", e ); - } - initializeProperties( modelProperties ); - } - - public PomClassicDomainModel( List modelProperties, boolean isMostSpecialized ) - { - this( modelProperties ); - this.isMostSpecialized = isMostSpecialized; - } - - - /** - * Constructor - * - * @param inputStream input stream of the maven model - * @throws IOException if there is a problem constructing the model - */ - public PomClassicDomainModel( InputStream inputStream ) - throws IOException - { - if ( inputStream == null ) - { - throw new IllegalArgumentException( "inputStream: null" ); - } - this.inputBytes = IOUtil.toByteArray( inputStream ); - modelProperties = getModelProperties(); - initializeProperties( modelProperties ); - } - - public PomClassicDomainModel( InputStream inputStream, boolean isMostSpecialized ) - throws IOException - { - this( inputStream ); - this.isMostSpecialized = isMostSpecialized; - } - - private void initializeProperties(List modelProperties) - { - String groupId = null, artifactId = null, version = null; - for(ModelProperty mp : modelProperties) - { - if(mp.getUri().equals(ProjectUri.groupId)) - { - groupId = mp.getResolvedValue(); - } - else if(mp.getUri().equals(ProjectUri.artifactId)) - { - artifactId = mp.getResolvedValue(); - } - else if(mp.getUri().equals(ProjectUri.version)) - { - version = mp.getResolvedValue(); - } - else if(mp.getUri().equals(ProjectUri.Parent.artifactId)) - { - parentArtifactId = mp.getResolvedValue(); - } - else if(mp.getUri().equals(ProjectUri.Parent.groupId)) - { - parentGroupId = mp.getResolvedValue(); - } - else if(mp.getUri().equals(ProjectUri.Parent.version)) - { - parentVersion = mp.getResolvedValue(); - } - else if(mp.getUri().equals(ProjectUri.Parent.relativePath)) - { - parentRelativePath = mp.getResolvedValue(); - } - - if(groupId != null && artifactId != null && version != null && parentGroupId != null && - parentArtifactId != null && parentVersion != null & parentRelativePath != null) - { - break; - } - } - if( groupId == null && parentGroupId != null) - { - groupId = parentGroupId; - } - if( artifactId == null && parentArtifactId != null) - { - artifactId = parentArtifactId; - } - if( version == null && parentVersion != null ) - { - version = parentVersion; - } - - if(parentGroupId != null && parentArtifactId != null && parentVersion != null) - { - parentId = parentGroupId + ":" + parentArtifactId + ":" + parentVersion; - } - - if(parentRelativePath == null) - { - parentRelativePath = ".." + File.separator + "pom.xml"; - } - - id = groupId + ":" + artifactId + ":" + version; - } - - public PomClassicDomainModel( File file ) - throws IOException - { - this( new FileInputStream( file ) ); - this.file = file; - } - - public PomClassicDomainModel(Model model2) { - this.model = model2; - } - - public PomClassicDomainModel(Model model2, boolean b) { - this.model = model2; - this.isMostSpecialized = b; - } - - public File getParentFile() - { - return parentFile; - } - - public void setParentFile( File parentFile ) - { - this.parentFile = parentFile; - } - - public String getParentGroupId() { - return parentGroupId; - } - - public String getParentArtifactId() { - return parentArtifactId; - } - - public String getParentVersion() { - return parentVersion; - } - - /** - * This should only be set for projects that are in the build. Setting for poms in the repo may cause unstable behavior. - * - * @param projectDirectory - */ - public void setProjectDirectory(File projectDirectory) - { - this.projectDirectory = projectDirectory; - } - - public File getProjectDirectory() - { - return projectDirectory; - } - - public boolean isPomInBuild() - { - return projectDirectory != null; - } - - public String getParentId() throws IOException - { - return parentId; - } - - public String getRelativePathOfParent() - { - return parentRelativePath; - } - - public String getId() throws IOException - { - return id; - } - - - public boolean matchesParentOf( PomClassicDomainModel domainModel ) throws IOException - { - if ( domainModel == null ) - { - throw new IllegalArgumentException( "domainModel: null" ); - } - - return getId().equals(domainModel.getParentId()); - } - - /** - * Returns XML model as string - * - * @return XML model as string - */ - public String asString() - { - try - { - return IOUtil.toString( ReaderFactory.newXmlReader( new ByteArrayInputStream( inputBytes ) ) ); - } - catch ( IOException ioe ) - { - // should not occur: everything is in-memory - return ""; - } - } - - /** - * @see org.apache.maven.shared.model.InputStreamDomainModel#getInputStream() - */ - public InputStream getInputStream() - { - byte[] copy = new byte[inputBytes.length]; - System.arraycopy( inputBytes, 0, copy, 0, inputBytes.length ); - //System.out.println(new String(copy)); - return new ByteArrayInputStream( copy ); - } - - /** - * @return file of pom. May be null. - */ - public File getFile() - { - return file; - } - - public List getModelProperties() throws IOException - { - if(modelProperties == null) - { - Set s = new HashSet(); - //TODO: Should add all collections from ProjectUri - s.addAll(PomTransformer.URIS); - s.add(ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri); - s.add(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.xUri); - s.add(ProjectUri.Dependencies.Dependency.Exclusions.xUri); - s.add(ProjectUri.Build.Plugins.Plugin.Executions.xUri); - s.add(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI); - s.add(ProjectUri.Reporting.Plugins.Plugin.ReportSets.xUri); - s.add(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.configuration); - s.add(ProjectUri.Build.Plugins.Plugin.Executions.Execution.configuration); - //TODO: More profile info - s.add(ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Executions.xUri); - s.add(ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.Dependency.Exclusions.xUri); - s.add(ProjectUri.Profiles.Profile.Dependencies.Dependency.Exclusions.xUri); - s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.xUri); - s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.Execution.Goals.xURI); - s.add(ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.ReportSets.xUri); - s.add(ProjectUri.Profiles.Profile.Reporting.Plugins.Plugin.ReportSets.ReportSet.configuration); - s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Executions.Execution.configuration); - s.add(ProjectUri.Profiles.Profile.properties); - s.add(ProjectUri.Profiles.Profile.modules); - s.add(ProjectUri.Profiles.Profile.Dependencies.xUri); - s.add(ProjectUri.Profiles.Profile.Build.Plugins.Plugin.configuration); - - modelProperties = ModelMarshaller.marshallXmlToModelProperties( - getInputStream(), ProjectUri.baseUri, s ); - } - return new ArrayList(modelProperties); - } - - /** - * @see org.apache.maven.shared.model.DomainModel#getEventHistory() - */ - public String getEventHistory() - { - return eventHistory; - } - - /** - * @see org.apache.maven.shared.model.DomainModel#setEventHistory(String) - */ - public void setEventHistory( String eventHistory ) - { - if ( eventHistory == null ) - { - throw new IllegalArgumentException( "eventHistory: null" ); - } - this.eventHistory = eventHistory; - } - - public int getLineageCount() - { - return lineageCount; - } - - public void setLineageCount( int lineageCount ) - { - this.lineageCount = lineageCount; - } - - public PomClassicDomainModel createCopy() - { - List props = new ArrayList(); - for(ModelProperty mp : modelProperties) - { - props.add(mp.createCopyOfOriginal()); - } - - return new PomClassicDomainModel(props); - } - - /** - * Returns true if this.asString.equals(o.asString()), otherwise false. - * - * @param o domain model - * @return true if this.asString.equals(o.asString()), otherwise false. - */ - public boolean equals( Object o ) - { - try { - return o instanceof PomClassicDomainModel && getId().equals( ( (PomClassicDomainModel) o ).getId() ); - } catch (IOException e) { - return false; - } - } - - public boolean isMostSpecialized() - { - return isMostSpecialized; - } - - public void setMostSpecialized( boolean isMostSpecialized ) - { - this.isMostSpecialized = isMostSpecialized; - } - - @Override - public String toString() - { - return String.valueOf( id ); - } - -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomClassicDomainModelFactory.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomClassicDomainModelFactory.java deleted file mode 100644 index 581ac2bcf9..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomClassicDomainModelFactory.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.apache.maven.project.builder.legacy; - -import org.apache.maven.shared.model.DomainModelFactory; -import org.apache.maven.shared.model.DomainModel; -import org.apache.maven.shared.model.ModelProperty; - -import java.util.List; -import java.io.IOException; - -public class PomClassicDomainModelFactory implements DomainModelFactory -{ - public DomainModel createDomainModel(List modelProperties) throws IOException - { - return new PomClassicDomainModel(modelProperties); - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomTransformer.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomTransformer.java deleted file mode 100644 index a54506aab7..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/PomTransformer.java +++ /dev/null @@ -1,881 +0,0 @@ -package org.apache.maven.project.builder.legacy; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.util.*; - -import org.apache.maven.shared.model.*; -import org.apache.maven.shared.model.impl.DefaultModelDataSource; -import org.apache.maven.project.builder.PomClassicDomainModel; -import org.apache.maven.project.builder.PomInterpolatorTag; -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.rules.*; -import org.apache.maven.project.builder.factories.PluginExecutionIdModelContainerFactory; -import org.apache.maven.project.builder.factories.AlwaysJoinModelContainerFactory; -import org.apache.maven.project.builder.factories.ArtifactModelContainerFactory; -import org.apache.maven.project.builder.factories.IdModelContainerFactory; - -/** - * Provides methods for transforming model properties into a domain model for the pom classic format and vice versa. - */ -public class PomTransformer - implements ModelTransformer -{ - - private final DomainModelFactory factory; - - public PomTransformer(DomainModelFactory factory) - { - this.factory = factory; - } - - public static final List MODEL_CONTAINER_FACTORIES = - Collections.unmodifiableList(Arrays.asList(new ArtifactModelContainerFactory(), - new IdModelContainerFactory(ProjectUri.PluginRepositories.PluginRepository.xUri), - new IdModelContainerFactory(ProjectUri.Repositories.Repository.xUri), - new IdModelContainerFactory(ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri), - new IdModelContainerFactory(ProjectUri.Profiles.Profile.xUri), - new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri))); - - private static Collection goals_infos = Arrays.asList( - ModelContainerInfo.Factory.createModelContainerInfo( - new AlwaysJoinModelContainerFactory(), new ExecutionRule(), null) - ); - - private static Collection plugin_executions = Arrays.asList( - ModelContainerInfo.Factory.createModelContainerInfo( - new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri), - null, goals_infos) - ); - - private static Collection dependency_exclusions = Arrays.asList( - ModelContainerInfo.Factory.createModelContainerInfo( - new IdModelContainerFactory(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.Exclusion.xUri), - new DependencyRule(), null) - ); - - //Don't add subcontainers here, breaks MNG-3821 - public static final Collection MODEL_CONTAINER_INFOS = Arrays.asList( - ModelContainerInfo.Factory.createModelContainerInfo( - new ArtifactModelContainerFactory(), null, plugin_executions), - ModelContainerInfo.Factory.createModelContainerInfo( - new IdModelContainerFactory(ProjectUri.PluginRepositories.PluginRepository.xUri), null, null), - ModelContainerInfo.Factory.createModelContainerInfo( - new IdModelContainerFactory(ProjectUri.Repositories.Repository.xUri), null, null), - ModelContainerInfo.Factory.createModelContainerInfo( - new ArtifactModelContainerFactory(), null, dependency_exclusions), - ModelContainerInfo.Factory.createModelContainerInfo( - new IdModelContainerFactory(ProjectUri.Profiles.Profile.xUri), null, null) - ); - - /** - * The URIs this transformer supports - */ - public static final Set URIS = Collections.unmodifiableSet(new HashSet( Arrays.asList( ProjectUri.Build.Extensions.xUri, - ProjectUri.Build.PluginManagement.Plugins.xUri, - ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration, - ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri, - ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.Execution.Goals.xURI, - ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri, - ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri, - ProjectUri.Build.Plugins.xUri, - ProjectUri.properties, - 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.Build.Filters.xUri, - ProjectUri.CiManagement.Notifiers.xUri, - ProjectUri.Contributors.xUri, - ProjectUri.Dependencies.xUri, - ProjectUri.DependencyManagement.Dependencies.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.DependencyManagement.Dependencies.xUri, - ProjectUri.Profiles.Profile.PluginRepositories.xUri, - ProjectUri.Profiles.Profile.Reporting.Plugins.xUri, - ProjectUri.Profiles.Profile.Repositories.xUri, - ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.xUri, - ProjectUri.Profiles.Profile.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri, - ProjectUri.Reporting.Plugins.xUri, - ProjectUri.Repositories.xUri) )); - - /** - * The URIs that denote file/directory paths and need their file separators being normalized. - */ - private static final Set PATH_URIS = - Collections.unmodifiableSet( new HashSet( - Arrays.asList( - ProjectUri.Build.directory, - ProjectUri.Build.outputDirectory, - ProjectUri.Build.testOutputDirectory, - ProjectUri.Build.sourceDirectory, - ProjectUri.Build.testSourceDirectory, - ProjectUri.Build.scriptSourceDirectory, - ProjectUri.Build.Resources.Resource.directory, - ProjectUri.Build.TestResources.TestResource.directory, - ProjectUri.Build.Filters.filter, - ProjectUri.Reporting.outputDirectory ) ) ); - /** - * @see ModelTransformer#transformToDomainModel(java.util.List, java.util.List) - */ - public final DomainModel transformToDomainModel( List properties, List eventListeners ) - throws IOException - { - if ( properties == null ) - { - throw new IllegalArgumentException( "properties: null" ); - } - - if( eventListeners == null ) - { - eventListeners = new ArrayList(); - } - else - { - eventListeners = new ArrayList(eventListeners); - } - - List props = new ArrayList( properties ); - - - ModelDataSource source = new DefaultModelDataSource( props, PomTransformer.MODEL_CONTAINER_FACTORIES ); - - //Dependency Management - new DependencyManagementDataSourceRule().execute( source ); - - //Plugin Management - List joinedContainers = new ArrayList(); - for ( ModelContainer pluginContainer : source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri ) ) - { - for ( ModelContainer managementContainer : source.queryFor( ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri ) ) - { - //Transform from plugin management to plugins - List transformedProperties = new ArrayList(); - for ( ModelProperty mp : managementContainer.getProperties() ) - { - if ( mp.getUri().startsWith( ProjectUri.Build.PluginManagement.xUri ) ) - { - transformedProperties.add( new ModelProperty( mp.getUri().replace( ProjectUri.Build.PluginManagement.xUri, - ProjectUri.Build.xUri ), mp.getResolvedValue() ) ); - } - } - - managementContainer = new ArtifactModelContainerFactory().create( transformedProperties ); - - //Remove duplicate executions tags - boolean hasExecutionsTag = false; - for ( ModelProperty mp : pluginContainer.getProperties() ) - { - if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.xUri ) ) - { - hasExecutionsTag = true; - break; - } - } - - List pList; - - if ( !hasExecutionsTag ) - { - pList = managementContainer.getProperties(); - } - else - { - pList = new ArrayList(); - - for ( ModelProperty mp : managementContainer.getProperties() ) - { - if ( !mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.xUri ) ) - { - pList.add( mp ); - } - } - } - - managementContainer = new ArtifactModelContainerFactory().create( pList ); - - ModelContainerAction action = pluginContainer.containerAction( managementContainer ); - - //Join Execution Containers - if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) ) - { - ModelDataSource pluginDatasource = new DefaultModelDataSource( pluginContainer.getProperties(), PomTransformer.MODEL_CONTAINER_FACTORIES ); - ModelDataSource managementDatasource = new DefaultModelDataSource( managementContainer.getProperties(), PomTransformer.MODEL_CONTAINER_FACTORIES ); - - List managementExecutionContainers = managementDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri); - List managementPropertiesWithoutExecutions = new ArrayList(managementContainer.getProperties()); - for(ModelContainer a : managementExecutionContainers) - { - managementPropertiesWithoutExecutions.removeAll(a.getProperties()); - } - - source.joinWithOriginalOrder( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions) ); - - List pluginExecutionContainers = pluginDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri); - List joinedExecutionContainers = new ArrayList(); - - for(ModelContainer a : managementExecutionContainers) - { - boolean hasId = false; - for(ModelProperty mp : a.getProperties()) { - if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.id)) { - hasId = true; - break; - } - } - - ModelContainer c = a; - if(!hasId) { - List listWithId = new ArrayList(a.getProperties()); - listWithId.add(1, new ModelProperty(ProjectUri.Build.Plugins.Plugin.Executions.Execution.id, "default")); - c = new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri).create(listWithId); - } - - - for(ModelContainer b : pluginExecutionContainers) - { - if(b.containerAction(c).equals(ModelContainerAction.JOIN)) - { - //MNG-3995 - property lost here - joinedContainers.addAll(source.join(b, c).getProperties()); - joinedExecutionContainers.add(a); - } - } - } - - ModelProperty executionsProperty = null; - for(ModelProperty a : pluginContainer.getProperties()) - { - if(a.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.xUri)) { - executionsProperty = a; - break; - } - } - - if(executionsProperty == null) - { - for(ModelProperty a : managementPropertiesWithoutExecutions) - { - if(a.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.xUri)) { - executionsProperty = a; - break; - } - } - } - - if(executionsProperty != null) - { - managementExecutionContainers.removeAll(joinedExecutionContainers); - Collections.reverse(managementExecutionContainers); - for(ModelContainer a : managementExecutionContainers) - { - source.insertModelPropertiesAfter(executionsProperty, - ModelTransformerContext.sort(a.getProperties(), ProjectUri.Build.Plugins.Plugin.Executions.xUri)); - } - } - - } - } - } - - props = source.getModelProperties(); - - //TransformerRule: Do not join plugin executions without ids - Set removeProperties = new HashSet(); - - ModelDataSource dataSource = new DefaultModelDataSource( props, PomTransformer.MODEL_CONTAINER_FACTORIES ); - - List containers = dataSource.queryFor( ProjectUri.Build.Plugins.Plugin.xUri ); - - for ( ModelContainer pluginContainer : containers ) - { - ModelDataSource executionSource = new DefaultModelDataSource( pluginContainer.getProperties(), - Arrays.asList( new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() )); - - List executionContainers = executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri ); - - if ( executionContainers.size() < 2 ) - { - continue; - } - - boolean hasAtLeastOneWithoutId = false; - - for ( ModelContainer executionContainer : executionContainers ) - { - - - if ( hasAtLeastOneWithoutId && !hasExecutionId( executionContainer ) && executionContainers.indexOf( executionContainer ) > 0 ) - { - removeProperties.addAll( executionContainer.getProperties() ); - } - if ( !hasAtLeastOneWithoutId ) - { - hasAtLeastOneWithoutId = !hasExecutionId( executionContainer ); - } - } - } - - props.removeAll( removeProperties ); - - //Execution TransformerRule - extension for this needs to be pushed into model-builder - dataSource = new DefaultModelDataSource( props, PomTransformer.MODEL_CONTAINER_FACTORIES ); - - for(ModelContainer mc : dataSource.queryFor( ProjectUri.Build.Plugins.Plugin.xUri )) - { - ModelDataSource executionSource = - new DefaultModelDataSource(mc.getProperties(), - Arrays.asList(new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri), - new AlwaysJoinModelContainerFactory())); - for(ModelContainer es : executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri )) { - ExecutionRule rule = new ExecutionRule(); - // List x = rule.execute(es.getProperties()); - List x = !aContainsAnyOfB(es.getProperties(), joinedContainers) ? rule.execute(es.getProperties()) : - ModelTransformerContext.sort(rule.execute(es.getProperties()), - ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri); - - dataSource.replace(es, es.createNewInstance(x)); - } - } - - props =// false ? ModelTransformerContext.sort(dataSource.getModelProperties(), ProjectUri.baseUri) - dataSource.getModelProperties(); - - for(ModelEventListener listener : eventListeners) - { - ModelDataSource ds = new DefaultModelDataSource( props, listener.getModelContainerFactories() ); - for(String uri : listener.getUris() ) - { - listener.fire(ds.queryFor(uri)); - } - } - - //Cleanup props (MNG-3979) - List p = new ArrayList(); - for(ModelProperty mp : props) - { - if(mp.getResolvedValue() != null - && mp.getResolvedValue().trim().equals("")) - { - int index = props.indexOf(mp) + 1; - - if(index < props.size() && mp.isParentOf(props.get(index)) && mp.getDepth() != props.get(index).getDepth() - && !props.get(index).getUri().contains("#property")) - { - p.add(new ModelProperty(mp.getUri(), null)); - } - else - { - p.add(mp); - } - } - else if ( mp.getResolvedValue() != null && PATH_URIS.contains( mp.getUri() ) ) - { - // normalize file separator - p.add( new ModelProperty( mp.getUri(), new File( mp.getResolvedValue() ).getPath() ) ); - } - else - { - p.add(mp); - } - } - - return factory.createDomainModel( p ); - } - - private static boolean aContainsAnyOfB(List a, List b) { - for(ModelProperty mpA : a ) - { - for(ModelProperty mpB : b) - { - if(mpA.equals(mpB)) - { - return true; - } - } - } - return false; - } - - - - List transformerRules = Arrays.asList(new MissingVersionTransformerRule(), - new DefaultDependencyScopeTransformerRule(), new MissingGroupIdTransformerRule()); - - List transformerRemovalRules = Arrays.asList(new DefaultExecutionIdTransformerRule(), - new ModulesNotInheritedTransformerRule(), new NotInheritedPluginExecutionTransformerRule(), - new NotInheritedPluginTransformerRule(), new RelativePathNotInheritedTransformerRule(), - new PackagingNotInheritedTransformerRule(), new NameNotInheritedTransformerRule()); - - /** - * @see ModelTransformer#transformToModelProperties(java.util.List) - */ - public final List transformToModelProperties(List domainModels - ) - throws IOException - { - if ( domainModels == null || domainModels.isEmpty() ) - { - throw new IllegalArgumentException( "domainModels: null or empty" ); - } - - List modelProperties = new ArrayList(); - List projectNames = new ArrayList(); - 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; - - - for ( DomainModel domainModel : domainModels ) - { - List tmp = domainModel.getModelProperties(); - - List clearedProperties = new ArrayList(); - - for(TransformerRule rule : transformerRules) - { - rule.execute(tmp, domainModel.isMostSpecialized()); - } - - for(TransformerRemovalRule rule : transformerRemovalRules) - { - tmp.removeAll(rule.executeWithReturnPropertiesToRemove(tmp, domainModel.isMostSpecialized())); - } - - // Project URL TransformerRule - adjustUrl( projectUrl, tmp, ProjectUri.url, projectNames ); - // Site TransformerRule - adjustUrl( siteUrl, tmp, ProjectUri.DistributionManagement.Site.url, projectNames ); - // SCM TransformerRule - adjustUrl( scmUrl, tmp, ProjectUri.Scm.url, projectNames ); - // SCM Connection TransformerRule - adjustUrl( scmConnectionUrl, tmp, ProjectUri.Scm.connection, projectNames ); - // SCM Developer TransformerRule - adjustUrl( scmDeveloperUrl, tmp, ProjectUri.Scm.developerConnection, projectNames ); - - // Profiles TransformerRule: not inherited - // Prerequisites TransformerRule: not inherited - // DistributionManagent.Relocation TransformerRule: not inherited - if ( !domainModel.isMostSpecialized() ) - { - for ( ModelProperty mp : tmp ) - { - String uri = mp.getUri(); - if ( uri.startsWith( ProjectUri.Profiles.xUri ) - || uri.startsWith( ProjectUri.Prerequisites.xUri ) - || uri.startsWith( ProjectUri.DistributionManagement.Relocation.xUri ) ) - { - clearedProperties.add( mp ); - } - } - } - - // Remove Plugin Repository Inheritance TransformerRule - // License TransformerRule: only inherited if not specified in child - // Organization TransformerRule: only inherited if not specified in child - // Developers TransformerRule: only inherited if not specified in child - // Contributors TransformerRule: only inherited if not specified in child - // Mailing Lists TransformerRule: only inherited if not specified in child - // Build Resources TransformerRule: only inherited if not specified in child - // Build Test Resources TransformerRule: only inherited if not specified in child - // CI Management TransformerRule: only inherited if not specified in child - // Issue Management TransformerRule: only inherited if not specified in child - // Distribution Management Repository TransformerRule: only inherited if not specified in child - // Distribution Management Snapshot Repository TransformerRule: only inherited if not specified in child - // Distribution Management Site TransformerRule: 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 ); - } - - //Rules processed on collapsed pom - - //TransformerRule: Remove duplicate filters - modelProperties.removeAll(new DuplicateFiltersTransformerRule().executeWithReturnPropertiesToRemove( modelProperties , false)); - - //TransformerRule: Build plugin config overrides reporting plugin config - return new OverideConfigTransformerRule().execute( modelProperties ); - } - - /** - * Overide this method to change the way interpolation is handled. - * - * @param modelProperties - * @param interpolatorProperties - * @param domainModel - * @throws IOException - */ - private static final Map aliases = new HashMap(); - - 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 void interpolateModelProperties( List modelProperties, - List interpolatorProperties, - DomainModel domainModel ) - throws IOException - { - PomClassicDomainModel dm = (PomClassicDomainModel) domainModel; - - if ( !containsProjectVersion( interpolatorProperties ) ) - { - aliases.put( "\\$\\{project.version\\}", "\\$\\{version\\}" ); - } - - List firstPassModelProperties = new ArrayList(); - List secondPassModelProperties = new ArrayList(); - - 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.Reporting.outputDirectory ) || mp.getUri().equals( ProjectUri.Build.finalName ) ) ) - { - firstPassModelProperties.add( mp ); - } - else - { - secondPassModelProperties.add( mp ); - } - } - } - - List standardInterpolatorProperties = new ArrayList(); - if ( dm.isPomInBuild() ) - { - String basedir = dm.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() ) ); - - String baseuri = dm.getProjectDirectory().toURI().toString(); - standardInterpolatorProperties.add( new InterpolatorProperty( "${project.baseUri}", baseuri, - PomInterpolatorTag.PROJECT_PROPERTIES.name() ) ); - standardInterpolatorProperties.add( new InterpolatorProperty( "${pom.baseUri}", baseuri, - 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 ips1 = new ArrayList( interpolatorProperties ); - ips1.addAll( standardInterpolatorProperties ); - ips1.addAll( ModelTransformerContext.createInterpolatorProperties( firstPassModelProperties, ProjectUri.baseUri, aliases, PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false ) ); - Collections.sort( ips1, new Comparator() - { - public int compare( InterpolatorProperty o, InterpolatorProperty o1 ) - { - if(o.getTag() == null || o1.getTag() == null) - { - return 0; - } - return PomInterpolatorTag.valueOf(o.getTag()).compareTo(PomInterpolatorTag.valueOf(o1.getTag())); - } - }); - - ModelTransformerContext.interpolateModelProperties( modelProperties, ips1 ); - - //SECOND PASS - Set absolute paths on build directories - if ( dm.isPomInBuild() ) - { - String basedir = dm.getProjectDirectory().getAbsolutePath(); - Map buildDirectories = new HashMap(); - for ( ModelProperty mp : secondPassModelProperties ) - { - if ( mp.getUri().startsWith( ProjectUri.Build.xUri ) || mp.getUri().equals( ProjectUri.Reporting.outputDirectory ) ) - { - File file = new File(mp.getResolvedValue()); - if( !file.isAbsolute() && !mp.getResolvedValue().startsWith("${project.build.") - && !mp.getResolvedValue().equals("${project.basedir}")) - { - buildDirectories.put( mp, new ModelProperty( mp.getUri(), new File( basedir, file.getPath() ).getAbsolutePath() ) ); - } - } - } - - for ( Map.Entry e : buildDirectories.entrySet() ) - { - secondPassModelProperties.remove( e.getKey() ); - secondPassModelProperties.add( e.getValue() ); - } - } - - //THIRD PASS - Use build directories as interpolator properties - List ips2 = new ArrayList( 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() - { - public int compare( InterpolatorProperty o, InterpolatorProperty o1 ) - { - if(o.getTag() == null || o1.getTag() == null) - { - return 0; - } - - return PomInterpolatorTag.valueOf( o.getTag() ).compareTo( PomInterpolatorTag.valueOf( o1.getTag() ) ); - } - } ); - - ModelTransformerContext.interpolateModelProperties( modelProperties, ips2 ); - } - /** - * Override this method for different preprocessing of model properties. - * - * @param modelProperties - * @return - */ - public List preprocessModelProperties(List modelProperties) - { - return new ArrayList(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 properties, String uri, List 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 interpolatorProperties ) - { - InterpolatorProperty versionInterpolatorProperty = - new ModelProperty( ProjectUri.version, "").asInterpolatorProperty( ProjectUri.baseUri); - for( InterpolatorProperty ip : interpolatorProperties) - { - if ( ip.equals( versionInterpolatorProperty ) ) - { - return true; - } - } - return false; - } - - private static boolean hasExecutionId( ModelContainer executionContainer ) - { - for ( ModelProperty mp : executionContainer.getProperties() ) - { - if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.Execution.id ) ) - { - return true; - } - } - return false; - } - - private static boolean hasProjectUri( String projectUri, List 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 - */ - public static List getPropertiesFor( String uri, List properties ) - { - List modelProperties = new ArrayList(); - 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. - */ - public static ModelProperty getPropertyFor( String uri, List properties ) - { - for ( ModelProperty mp : properties ) - { - if ( uri.equals( mp.getUri() ) ) - { - return mp; - } - } - return null; - } - - -} - diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/TransformerRemovalRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/TransformerRemovalRule.java deleted file mode 100644 index 4d00f4731c..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/TransformerRemovalRule.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.apache.maven.project.builder.legacy; - -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import java.util.List; - -public interface TransformerRemovalRule { - - List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException; -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/TransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/TransformerRule.java deleted file mode 100644 index 7c70a3c7e0..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/legacy/TransformerRule.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.apache.maven.project.builder.legacy; - -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import java.util.List; - -public interface TransformerRule -{ - void execute(List modelProperties, boolean isMostSpecialized) throws DataSourceException; - -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ActiveProfileMatcher.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ActiveProfileMatcher.java deleted file mode 100644 index 5618595d20..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ActiveProfileMatcher.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.apache.maven.project.builder.profile; - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.InterpolatorProperty; - -import java.util.List; - -public interface ActiveProfileMatcher { - - /** - * If model container does not contain the activator property, must return false. - * - * @param modelContainer - * @param properties - * @return - */ - boolean isMatch(ModelContainer modelContainer, List properties); -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ByDefaultMatcher.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ByDefaultMatcher.java deleted file mode 100644 index 9e616cecc7..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ByDefaultMatcher.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.apache.maven.project.builder.profile; - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.List; - -public class ByDefaultMatcher implements ActiveProfileMatcher { - - public boolean isMatch(ModelContainer modelContainer, List properties) { - if(modelContainer == null ) { - throw new IllegalArgumentException("modelContainer: null"); - } - - for(ModelProperty mp : modelContainer.getProperties()) { - if(mp.getUri().equals(ProjectUri.Profiles.Profile.Activation.activeByDefault)) { - return true; - } - } - return false; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/FileMatcher.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/FileMatcher.java deleted file mode 100644 index b8b5a49ea8..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/FileMatcher.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.maven.project.builder.profile; - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.List; -import java.util.ArrayList; -import java.io.File; - -public class FileMatcher implements ActiveProfileMatcher { - - public boolean isMatch(ModelContainer modelContainer, List properties) { - if(modelContainer == null ) { - throw new IllegalArgumentException("modelContainer: null"); - } - - List exists = new ArrayList(), missings = new ArrayList(); - - for(ModelProperty mp : modelContainer.getProperties()) { - if(mp.getUri().equals(ProjectUri.Profiles.Profile.Activation.File.exists)) { - exists.add(mp.getValue()); - } else if(mp.getUri().equals(ProjectUri.Profiles.Profile.Activation.File.missing)) { - missings.add(mp.getValue()); - } - } - - if(exists.isEmpty() && missings.isEmpty()) { - return false; - } - - for(String exist : exists) { - if(!new File(exist).exists()) { - return false; - } - } - - for(String missing : missings) { - if(new File(missing).exists()) { - return false; - } - } - - return true; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java deleted file mode 100644 index 7368e9d21e..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java +++ /dev/null @@ -1,195 +0,0 @@ -package org.apache.maven.project.builder.profile; - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class JdkMatcher - implements ActiveProfileMatcher -{ - public boolean isMatch( ModelContainer modelContainer, List properties ) - { - if ( modelContainer == null ) - { - throw new IllegalArgumentException( "modelContainer: null" ); - } - - if ( properties == null ) - { - return false; - } - - for ( InterpolatorProperty property : properties ) - { - if ( property.getKey().equals( "${java.specification.version}" ) ) - { - String version = property.getValue(); - for ( ModelProperty modelProperty : modelContainer.getProperties() ) - { - - if ( modelProperty.getUri().equals( ProjectUri.Profiles.Profile.Activation.jdk ) ) - { - if ( modelProperty.getResolvedValue().startsWith( "!" ) ) - { - return !version.startsWith( modelProperty.getResolvedValue().replaceFirst( "!", "" ) ); - } - else if ( isRange( modelProperty.getResolvedValue() ) ) - { - return isInRange( version, getRange( modelProperty.getResolvedValue() ) ); - } - else - { - return version.startsWith( modelProperty.getResolvedValue() ); - } - - } - } - return false; - } - } - return false; - } - - private static boolean isInRange( String value, List range ) - { - int leftRelation = getRelationOrder( value, range.get( 0 ), true ); - - if ( leftRelation == 0 ) - { - return true; - } - - if ( leftRelation < 0 ) - { - return false; - } - - return getRelationOrder( value, range.get( 1 ), false ) <= 0; - } - - private static int getRelationOrder( String value, RangeValue rangeValue, boolean isLeft ) - { - if ( rangeValue.value.length() <= 0 ) - { - return isLeft ? 1 : -1; - } - - List valueTokens = new ArrayList( Arrays.asList( value.split( "\\." ) ) ); - List rangeValueTokens = new ArrayList( Arrays.asList( rangeValue.value.split( "\\." ) ) ); - - int max = Math.max( valueTokens.size(), rangeValueTokens.size() ); - addZeroTokens( valueTokens, max ); - addZeroTokens( rangeValueTokens, max ); - - if ( value.equals( rangeValue.value ) ) - { - if ( !rangeValue.isClosed() ) - { - return isLeft ? -1 : 1; - } - return 0; - } - - for ( int i = 0; i < valueTokens.size(); i++ ) - { - int x = Integer.parseInt( valueTokens.get( i ) ); - int y = Integer.parseInt( rangeValueTokens.get( i ) ); - if ( x < y ) - { - return -1; - } - else if ( x > y ) - { - return 1; - } - } - if ( !rangeValue.isClosed() ) - { - return isLeft ? -1 : 1; - } - return 0; - } - - private static void addZeroTokens( List tokens, int max ) - { - if ( tokens.size() < max ) - { - for ( int i = 0; i < ( max - tokens.size() ); i++ ) - { - tokens.add( "0" ); - } - } - } - - private static boolean isRange( String value ) - { - return value.contains( "," ); - } - - private static List getRange( String range ) - { - List ranges = new ArrayList(); - - for ( String token : range.split( "," ) ) - { - if ( token.startsWith( "[" ) ) - { - ranges.add( new RangeValue( token.replace( "[", "" ), true ) ); - } - else if ( token.startsWith( "(" ) ) - { - ranges.add( new RangeValue( token.replace( "(", "" ), false ) ); - } - else if ( token.endsWith( "]" ) ) - { - ranges.add( new RangeValue( token.replace( "]", "" ), true ) ); - } - else if ( token.endsWith( ")" ) ) - { - ranges.add( new RangeValue( token.replace( ")", "" ), false ) ); - } - else if ( token.length() <= 0 ) - { - ranges.add( new RangeValue( "", false ) ); - } - } - if ( ranges.size() < 2 ) - { - ranges.add( new RangeValue( "99999999", false ) ); - } - return ranges; - } - - public static class RangeValue - { - private String value; - - private boolean isClosed; - - RangeValue( String value, boolean isClosed ) - { - this.value = value.trim(); - this.isClosed = isClosed; - } - - public String getValue() - { - return value; - } - - public boolean isClosed() - { - return isClosed; - } - - public String toString() - { - return value; - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/OperatingSystemMatcher.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/OperatingSystemMatcher.java deleted file mode 100644 index 727e727107..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/OperatingSystemMatcher.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.project.builder.profile; - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.List; - -public class OperatingSystemMatcher implements ActiveProfileMatcher { - - public boolean isMatch(ModelContainer modelContainer, List properties) { - if(modelContainer == null ) { - throw new IllegalArgumentException("modelContainer: null"); - } - - if(!doTest(modelContainer)) { - return false; - } - - for(InterpolatorProperty property : properties) { - if(!matches(modelContainer, property)) { - return false; - } - } - - return true; - } - - private static boolean doTest(ModelContainer modelContainer) { - for(ModelProperty mp : modelContainer.getProperties()) { - if(mp.getUri().startsWith(ProjectUri.Profiles.Profile.Activation.Os.xUri)) { - return true; - } - } - return false; - } - - private static boolean matches(ModelContainer modelContainer, InterpolatorProperty interpolatorProperty) { - String key = interpolatorProperty.getKey(); - - for(ModelProperty property : modelContainer.getProperties()) { - if((key.equals("${os.arch}") && property.getUri().equals(ProjectUri.Profiles.Profile.Activation.Os.arch)) - || (key.equals("${os.version}") && property.getUri().equals(ProjectUri.Profiles.Profile.Activation.Os.version)) - || (key.equals("${os.family}") && property.getUri().equals(ProjectUri.Profiles.Profile.Activation.Os.family)) - || (key.equals("${os.name}") && property.getUri().equals(ProjectUri.Profiles.Profile.Activation.Os.name)) ) - { - - if(property.getResolvedValue().startsWith("!")) - { - return !interpolatorProperty.getValue().equals(property.getResolvedValue()); - } - else - { - return interpolatorProperty.getValue().equals(property.getResolvedValue()); - } - - } - } - return true; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ProfileContext.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ProfileContext.java deleted file mode 100644 index 001f30423e..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ProfileContext.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.apache.maven.project.builder.profile; - -import org.apache.maven.shared.model.*; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.*; - - -public class ProfileContext { - - private ModelDataSource modelDataSource; - - private List properties; - - private Collection activeProfileIds; - - private Collection inactiveProfileIds; - - private ActiveProfileMatcher defaultMatcher = new ByDefaultMatcher(); - - private List matchers = Collections.unmodifiableList( Arrays.asList( - new FileMatcher(), new JdkMatcher(), new OperatingSystemMatcher(), new PropertyMatcher() - ) ); - - public ProfileContext( ModelDataSource modelDataSource, Collection activeProfileIds, - Collection inactiveProfileIds, List properties ) - { - this.modelDataSource = modelDataSource; - this.properties = new ArrayList( properties ); - this.activeProfileIds = ( activeProfileIds != null ) ? activeProfileIds : new ArrayList(); - this.inactiveProfileIds = ( inactiveProfileIds != null ) ? inactiveProfileIds : new ArrayList(); - } - - public Collection getActiveProfiles() - throws DataSourceException - { - List matchedContainers = new ArrayList(); - List defaultContainers = new ArrayList(); - - List modelContainers = modelDataSource.queryFor( ProjectUri.Profiles.Profile.xUri ); - for ( ModelContainer mc : modelContainers ) - { - String profileId = getProfileId( mc.getProperties() ); - - if ( !inactiveProfileIds.contains( profileId ) ) - { - if ( activeProfileIds.contains( profileId ) ) - { - matchedContainers.add( mc ); - } - else if ( defaultMatcher.isMatch( mc, properties ) ) - { - defaultContainers.add( mc ); - } - else - { - for ( ActiveProfileMatcher matcher : matchers ) - { - if ( matcher.isMatch( mc, properties ) ) - { - matchedContainers.add( mc ); - break; - } - } - } - } - } - - if ( matchedContainers.isEmpty() ) - { - matchedContainers = defaultContainers; - } - - return matchedContainers; - } - - private String getProfileId(List modelProperties) - { - for(ModelProperty mp : modelProperties) - { - if(mp.getUri().equals(ProfileUri.Profiles.Profile.id)) - { - return mp.getResolvedValue(); - } - } - return null; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ProfileUri.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ProfileUri.java deleted file mode 100644 index 124782aca3..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/ProfileUri.java +++ /dev/null @@ -1,178 +0,0 @@ -package org.apache.maven.project.builder.profile; - - -public class ProfileUri { - - public static class Profiles - { - public static String xUri = "http://apache.org/maven/project/profiles#collection"; - - public static class Profile - { - public static String xUri = "http://apache.org/maven/project/profiles#collection/profile"; - - public static String id = "http://apache.org/maven/project/profiles#collection/profile/id"; - - public static class Activation - { - public static String xUri = "http://apache.org/maven/profiles#collection/profile/activation"; - - public static String activeByDefault = - "http://apache.org/maven/profiles#collection/profile/activation/activeByDefault"; - - public static String jdk = "http://apache.org/maven/profiles#collection/profile/activation/jdk"; - - public static class Os - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/activation/os"; - - public static String name = - "http://apache.org/maven/profiles#collection/profile/activation/os/name"; - - public static String family = - "http://apache.org/maven/profiles#collection/profile/activation/os/family"; - - public static String arch = - "http://apache.org/maven/profiles#collection/profile/activation/os/arch"; - - public static String version = - "http://apache.org/maven/profiles#collection/profile/activation/os/version"; - } - - public static class Property - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/activation/property"; - - public static String name = - "http://apache.org/maven/profiles#collection/profile/activation/property/name"; - - public static String value = - "http://apache.org/maven/profiles#collection/profile/activation/property/value"; - } - - public static class File - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/activation/file"; - - public static String missing = - "http://apache.org/maven/profiles#collection/profile/activation/file/missing"; - - public static String exists = - "http://apache.org/maven/profiles#collection/profile/activation/file/exists"; - } - } - - public static class Repositories - { - public static String xUri = "http://apache.org/maven/profiles#collection/profile/repositories"; - - public static class Repository - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/repositories/repository"; - - public static class Releases - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/releases"; - - public static String enabled = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/releases/enabled"; - - public static String updatePolicy = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/releases/updatePolicy"; - - public static String checksumPolicy = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/releases/checksumPolicy"; - } - - public static class Snapshots - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/snapshots"; - - public static String enabled = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/snapshots/enabled"; - - public static String updatePolicy = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/snapshots/updatePolicy"; - - public static String checksumPolicy = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/snapshots/checksumPolicy"; - } - - public static String id = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/id"; - - public static String name = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/name"; - - public static String url = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/url"; - - public static String layout = - "http://apache.org/maven/profiles#collection/profile/repositories/repository/layout"; - } - } - - public static class PluginRepositories - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories"; - - public static class PluginRepository - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository"; - - public static class Releases - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/releases"; - - public static String enabled = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/releases/enabled"; - - public static String updatePolicy = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/releases/updatePolicy"; - - public static String checksumPolicy = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/releases/checksumPolicy"; - } - - public static class Snapshots - { - public static String xUri = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/snapshots"; - - public static String enabled = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/snapshots/enabled"; - - public static String updatePolicy = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/snapshots/updatePolicy"; - - public static String checksumPolicy = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/snapshots/checksumPolicy"; - } - - public static String id = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/id"; - - public static String name = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/name"; - - public static String url = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/url"; - - public static String layout = - "http://apache.org/maven/profiles#collection/profile/pluginRepositories/pluginRepository/layout"; - } - } - - public static String properties = "http://apache.org/maven/profiles#collection/profile/properties"; - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/PropertyMatcher.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/PropertyMatcher.java deleted file mode 100644 index f968d2a16c..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/profile/PropertyMatcher.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.project.builder.profile; - -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.InterpolatorProperty; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.List; - -public class PropertyMatcher implements ActiveProfileMatcher { - - public boolean isMatch(ModelContainer modelContainer, List properties) { - - if (modelContainer == null) { - throw new IllegalArgumentException("modelContainer: null"); - } - - String name = null, value = null; - - for(ModelProperty mp : modelContainer.getProperties()) { - if(mp.getUri().equals(ProjectUri.Profiles.Profile.Activation.Property.name)) { - name = mp.getValue(); - } else if(mp.getUri().equals(ProjectUri.Profiles.Profile.Activation.Property.value)) { - value = mp.getValue(); - } - } - - if(name == null ) - { - return false; - } - - if(value == null) - { - return !name.startsWith("!"); - } - - for(InterpolatorProperty ip : properties) { - if(ip.getKey().equals("${" + name + "}")) { - return ip.getValue().equals(value); - } - } - - return false; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DefaultDependencyScopeTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DefaultDependencyScopeTransformerRule.java deleted file mode 100644 index cf74367899..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DefaultDependencyScopeTransformerRule.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.ModelDataSource; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.DataSourceException; -import org.apache.maven.shared.model.impl.DefaultModelDataSource; -import org.apache.maven.project.builder.factories.ArtifactModelContainerFactory; -import org.apache.maven.project.builder.legacy.TransformerRule; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.List; -import java.util.Arrays; - - -/** - * If no scope is found in most specialized model, then set scope to compile. - */ -public class DefaultDependencyScopeTransformerRule implements TransformerRule -{ - public void execute(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - if(isMostSpecialized) - { - ModelDataSource s = new DefaultModelDataSource( modelProperties, Arrays.asList( new ArtifactModelContainerFactory()) ); - for(ModelContainer mc : s.queryFor(ProjectUri.Dependencies.Dependency.xUri)) - { - boolean containsScope = false; - for(ModelProperty mp :mc.getProperties()) - { - if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.scope)) { - containsScope = true; - break; - } - } - - if(!containsScope) - { - modelProperties.add(modelProperties.indexOf(mc.getProperties().get(0)) + 1, - new ModelProperty(ProjectUri.Dependencies.Dependency.scope, "compile")); - } - } - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DefaultExecutionIdTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DefaultExecutionIdTransformerRule.java deleted file mode 100644 index 6dd718ef25..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DefaultExecutionIdTransformerRule.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.TransformerRemovalRule; - -import java.util.List; -import java.util.ArrayList; - -/** - * Removes any plugin execution id that has a value of "default-execution-id": (mng-3965) - */ -public class DefaultExecutionIdTransformerRule implements TransformerRemovalRule -{ - public List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - List replace = new ArrayList(); - for(ModelProperty mp : modelProperties) - { - if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.id) - && mp.getResolvedValue() != null && mp.getResolvedValue().equals("default-execution-id")) { - replace.add(mp); - } - } - return replace; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DependencyManagementDataSourceRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DependencyManagementDataSourceRule.java deleted file mode 100644 index eb513d70c7..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DependencyManagementDataSourceRule.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.factories.ArtifactModelContainerFactory; -import org.apache.maven.project.builder.legacy.DataSourceRule; -import org.apache.maven.shared.model.*; -import org.apache.maven.shared.model.impl.DefaultModelDataSource; - -import java.util.Collections; -import java.util.Arrays; -import java.util.List; -import java.util.ArrayList; - -/** - * Transform Dependency Management section of pom into dependency section - */ -public class DependencyManagementDataSourceRule implements DataSourceRule -{ - public void execute(ModelDataSource source) throws DataSourceException - { - for ( ModelContainer dependencyContainer : source.queryFor( ProjectUri.Dependencies.Dependency.xUri ) ) - { - for ( ModelContainer managementContainer : source.queryFor( - ProjectUri.DependencyManagement.Dependencies.Dependency.xUri ) ) - { - //Join Duplicate Exclusions TransformerRule (MNG-4010) - ModelDataSource exclusionSource = new DefaultModelDataSource(managementContainer.getProperties(), - Collections.unmodifiableList(Arrays.asList(new ArtifactModelContainerFactory(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.Exclusion.xUri)))); - List exclusionContainers = - exclusionSource.queryFor(ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.Exclusion.xUri); - - for(ModelContainer mc : exclusionContainers) - { - for(ModelContainer mc1 : exclusionContainers) - { - if(!mc.equals(mc1) && mc.containerAction(mc1).equals(ModelContainerAction.JOIN)) - { - exclusionSource.joinWithOriginalOrder(mc1, mc); - } - } - } - - managementContainer = new ArtifactModelContainerFactory().create( - transformDependencyManagement( exclusionSource.getModelProperties() ) ); - ModelContainerAction action = dependencyContainer.containerAction( managementContainer ); - if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) ) - { - source.join( dependencyContainer, managementContainer ); - } - } - } - } - - private static List transformDependencyManagement( List modelProperties ) - { - List transformedProperties = new ArrayList(); - for ( ModelProperty mp : modelProperties ) - { - if ( mp.getUri().startsWith( ProjectUri.DependencyManagement.xUri ) ) - { - transformedProperties.add( new ModelProperty( - mp.getUri().replace( ProjectUri.DependencyManagement.xUri, ProjectUri.xUri ), mp.getResolvedValue() ) ); - } - } - return transformedProperties; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DependencyRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DependencyRule.java deleted file mode 100644 index 7c5a9f651c..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DependencyRule.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.shared.model.ModelContainerRule; -import org.apache.maven.shared.model.ModelProperty; - -import java.util.List; -import java.util.ArrayList; - -public class DependencyRule implements ModelContainerRule { - public List execute(List modelProperties) { - List properties = new ArrayList(modelProperties); - List goalProperties = new ArrayList(); - List processedProperties = new ArrayList(); - - return processedProperties; - - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DuplicateFiltersTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DuplicateFiltersTransformerRule.java deleted file mode 100644 index cffc0fb80f..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/DuplicateFiltersTransformerRule.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.TransformerRemovalRule; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import java.util.List; -import java.util.ArrayList; - -public class DuplicateFiltersTransformerRule implements TransformerRemovalRule -{ - public List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - List removedProperties = new ArrayList(); - List filters = new ArrayList(); - for(ModelProperty mp : modelProperties) - { - if(mp.getUri().equals(ProjectUri.Build.Filters.filter)) - { - if(filters.contains(mp.getResolvedValue())) - { - removedProperties.add(mp); - } - else - { - filters.add(mp.getResolvedValue()); - } - } - } - return removedProperties; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/ExecutionRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/ExecutionRule.java deleted file mode 100644 index 612072d811..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/ExecutionRule.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.shared.model.*; -import org.apache.maven.project.builder.ProjectUri; - -import java.util.List; -import java.util.ArrayList; -import java.util.Collections; - -public class ExecutionRule implements ModelContainerRule { - - public List execute(List modelProperties) { - List properties = new ArrayList(modelProperties); - List goalProperties = new ArrayList(); - List processedProperties = new ArrayList(); - - for(ModelProperty mp : properties) { - if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.goal)) { - goalProperties.add(mp); - } else if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI)) { - if(!containsProperty(mp, processedProperties)) { - processedProperties.add(mp); - } - } else { - processedProperties.add(mp); - } - } - - //Remove duplicate collections - List c = new ArrayList(); - boolean x = false; - for(ModelProperty mp : processedProperties) { - if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.configuration)) { - if(x) { - c.add(mp); - } else { - x = true; - } - - } - } - - processedProperties.removeAll(c); - - if(!goalProperties.isEmpty()) { - Collections.reverse(goalProperties); - List uniqueGoals = new ArrayList(); - for(ModelProperty mp : goalProperties) { - if(!containsProperty(mp, uniqueGoals)) { - uniqueGoals.add(mp); - } - } - Collections.reverse(uniqueGoals); - - processedProperties.addAll( - findIndexOf(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI, processedProperties) + 1, - uniqueGoals); - } - - List emptyTags = new ArrayList(); - for(ModelProperty mp : processedProperties) { - if(mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.xURI) - && mp.getResolvedValue() != null && mp.getResolvedValue().trim().equals("")) { - emptyTags.add(mp); - } - } - processedProperties.removeAll(emptyTags); - - return processedProperties; - } - - - private static int findIndexOf(String uri, List modelProperties) { - for(ModelProperty mp : modelProperties) { - if(mp.getUri().equals(uri)) { - return modelProperties.indexOf(mp); - } - } - return -1; - } - - private static boolean containsProperty(ModelProperty modelProperty, List modelProperties) { - for (ModelProperty mp : modelProperties) { - if ((mp.getUri().equals(modelProperty.getUri()))) { - boolean b = (mp.getResolvedValue() == null && modelProperty.getResolvedValue() == null) || - (mp.getResolvedValue() != null && !mp.getResolvedValue().trim().equals("") - && mp.getResolvedValue().equals(modelProperty.getResolvedValue())); - /* - boolean b = (mp.getResolvedValue() == null && modelProperty.getResolvedValue() == null) || - (mp.getResolvedValue() != null && modelProperty.getResolvedValue() != null - && mp.getResolvedValue().equals(modelProperty.getResolvedValue())); - */ - if(b) { - return true; - } - } - } - return false; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/MissingGroupIdTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/MissingGroupIdTransformerRule.java deleted file mode 100644 index 5358ee6960..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/MissingGroupIdTransformerRule.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.TransformerRule; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import static org.apache.maven.project.builder.legacy.PomTransformer.getPropertyFor; - -import java.util.List; - -/** - * If the groupId is missing, add it using the value of the parent groupId. - */ -public class MissingGroupIdTransformerRule implements TransformerRule -{ - public void execute(List modelProperties, boolean isMostSpecialized) throws DataSourceException - { - if ( getPropertyFor( ProjectUri.groupId, modelProperties ) == null ) - { - ModelProperty parentGroupId = getPropertyFor( ProjectUri.Parent.groupId, modelProperties ); - if ( parentGroupId != null ) - { - modelProperties.add( new ModelProperty( ProjectUri.groupId, parentGroupId.getResolvedValue() ) ); - } - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/MissingVersionTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/MissingVersionTransformerRule.java deleted file mode 100644 index 71cb0cf6d9..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/MissingVersionTransformerRule.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.PomTransformer; -import org.apache.maven.project.builder.legacy.TransformerRule; - -import java.util.List; - -/** - * If model does not have version, then find the parent version and use it - */ -public class MissingVersionTransformerRule implements TransformerRule -{ - public void execute(List modelProperties, boolean isMostSpecialized) throws DataSourceException - { - if ( PomTransformer.getPropertyFor( ProjectUri.version, modelProperties ) == null ) - { - ModelProperty parentVersion = PomTransformer.getPropertyFor( ProjectUri.Parent.version, modelProperties ); - if ( parentVersion != null ) - { - modelProperties.add( new ModelProperty( ProjectUri.version, parentVersion.getResolvedValue() ) ); - } - } - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/ModulesNotInheritedTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/ModulesNotInheritedTransformerRule.java deleted file mode 100644 index 758a3d9353..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/ModulesNotInheritedTransformerRule.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.PomTransformer; -import org.apache.maven.project.builder.legacy.TransformerRemovalRule; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import java.util.List; -import java.util.ArrayList; - -/** - * If the model is not the least child and has a module element, remove it. - */ -public class ModulesNotInheritedTransformerRule implements TransformerRemovalRule -{ - public List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - if (!isMostSpecialized) - { - ModelProperty modulesProperty = PomTransformer.getPropertyFor(ProjectUri.Modules.xUri, modelProperties); - if (modulesProperty != null) - { - modelProperties.remove(modulesProperty); - modelProperties.removeAll(PomTransformer.getPropertiesFor(ProjectUri.Modules.module, modelProperties)); - } - } - return new ArrayList();//todo: fix - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NameNotInheritedTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NameNotInheritedTransformerRule.java deleted file mode 100644 index 8f5e13e0e0..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NameNotInheritedTransformerRule.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.TransformerRemovalRule; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import java.util.List; -import java.util.ArrayList; - -/** - * Do not inherit the name attribute of the pom - */ -public class NameNotInheritedTransformerRule implements TransformerRemovalRule -{ - public List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - List removedProperties = new ArrayList(); - if ( !isMostSpecialized ) - { - for ( ModelProperty mp : modelProperties ) - { - if ( mp.getUri().startsWith( ProjectUri.name ) ) - { - removedProperties.add( mp ); - return removedProperties; - } - } - } - return removedProperties; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NotInheritedPluginExecutionTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NotInheritedPluginExecutionTransformerRule.java deleted file mode 100644 index d6612960b7..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NotInheritedPluginExecutionTransformerRule.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.factories.ArtifactModelContainerFactory; -import org.apache.maven.project.builder.factories.PluginExecutionIdModelContainerFactory; -import org.apache.maven.project.builder.legacy.TransformerRemovalRule; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; -import org.apache.maven.shared.model.ModelDataSource; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.impl.DefaultModelDataSource; - -import java.util.List; -import java.util.ArrayList; -import java.util.Arrays; - -/** - * If plugin execution inherited property is false, do not inherit the execution - */ -public class NotInheritedPluginExecutionTransformerRule implements TransformerRemovalRule -{ - public List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - List removeProperties = new ArrayList(); - - if ( !isMostSpecialized) - { - ModelDataSource source = new DefaultModelDataSource( modelProperties, Arrays.asList( - new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() )); - List 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 = modelProperties.indexOf( mp ); j >= 0; j-- ) - { - if ( modelProperties.get( j ).getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.xUri ) ) - { - removeProperties.add( modelProperties.get( j ) ); - break; - } - } - break; - } - } - } - } - return removeProperties; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NotInheritedPluginTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NotInheritedPluginTransformerRule.java deleted file mode 100644 index 905c076f6e..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/NotInheritedPluginTransformerRule.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.PomTransformer; -import org.apache.maven.project.builder.legacy.TransformerRemovalRule; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; -import org.apache.maven.shared.model.ModelDataSource; -import org.apache.maven.shared.model.ModelContainer; -import org.apache.maven.shared.model.impl.DefaultModelDataSource; - -import java.util.List; -import java.util.ArrayList; - -/** - * If plugin inherited element value is false, do not inherit the plugin. - */ -public class NotInheritedPluginTransformerRule implements TransformerRemovalRule -{ - public List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - List removeProperties = new ArrayList(); - if ( !isMostSpecialized) - { - ModelDataSource source = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES ); - List 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 = modelProperties.indexOf( mp ); j >= 0; j-- ) - { - if ( modelProperties.get( j ).getUri().equals( ProjectUri.Build.Plugins.Plugin.xUri ) ) - { - removeProperties.add( modelProperties.get( j ) ); - break; - } - } - break; - } - } - } - } - return removeProperties; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/OverideConfigTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/OverideConfigTransformerRule.java deleted file mode 100644 index 3be3616ef0..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/OverideConfigTransformerRule.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.factories.ArtifactModelContainerFactory; -import org.apache.maven.project.builder.legacy.JoinRule; -import org.apache.maven.project.builder.legacy.PomTransformer; -import org.apache.maven.shared.model.*; -import org.apache.maven.shared.model.impl.DefaultModelDataSource; - -import java.util.List; -import java.util.ArrayList; - -/** - * - */ -public class OverideConfigTransformerRule implements JoinRule -{ - public List execute(List modelProperties) throws DataSourceException - { - ModelDataSource source = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES ); - List 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; - } - } - } - - return source.getModelProperties(); - } - - private static List transformPlugin( List modelProperties ) - { - List transformedProperties = new ArrayList(); - 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; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/PackagingNotInheritedTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/PackagingNotInheritedTransformerRule.java deleted file mode 100644 index 01a09758c9..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/PackagingNotInheritedTransformerRule.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.TransformerRemovalRule; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import java.util.List; -import java.util.ArrayList; - -public class PackagingNotInheritedTransformerRule implements TransformerRemovalRule -{ - public List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - List removedProperties = new ArrayList(); - if ( !isMostSpecialized ) - { - for ( ModelProperty mp : modelProperties ) - { - if ( mp.getUri().startsWith( ProjectUri.packaging ) ) - { - removedProperties.add( mp ); - return removedProperties; - } - } - } - return removedProperties; - } -} diff --git a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/RelativePathNotInheritedTransformerRule.java b/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/RelativePathNotInheritedTransformerRule.java deleted file mode 100644 index a18c1e7b3b..0000000000 --- a/maven-mercury/src/main/java/org/apache/maven/project/builder/rules/RelativePathNotInheritedTransformerRule.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.apache.maven.project.builder.rules; - -import org.apache.maven.project.builder.ProjectUri; -import org.apache.maven.project.builder.legacy.TransformerRemovalRule; -import org.apache.maven.shared.model.ModelProperty; -import org.apache.maven.shared.model.DataSourceException; - -import java.util.List; -import java.util.ArrayList; - -/** - * The relativePath element is not inherited. - */ -public class RelativePathNotInheritedTransformerRule implements TransformerRemovalRule -{ - public List executeWithReturnPropertiesToRemove(List modelProperties, boolean isMostSpecialized) - throws DataSourceException - { - List removedProperties = new ArrayList(); - if ( !isMostSpecialized ) - { - for ( ModelProperty mp : modelProperties ) - { - if ( mp.getUri().startsWith( ProjectUri.Parent.relativePath ) ) - { - removedProperties.add( mp ); - return removedProperties; - } - } - } - return removedProperties; - } -} diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/builder/ModelEventListener.java b/maven-project-builder/src/main/java/org/apache/maven/project/builder/ModelEventListener.java index 8863307cac..f0f8759f4a 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/builder/ModelEventListener.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/builder/ModelEventListener.java @@ -1,10 +1,13 @@ package org.apache.maven.project.builder; import java.util.List; -import java.util.Collection; + +import org.apache.maven.model.Model; public interface ModelEventListener { + void fire(Model model); + List getUris(); } diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java b/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java index e6ddda395c..8e5a33ed1b 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java @@ -38,7 +38,7 @@ public class PomClassicDomainModel implements DomainModel private String parentGroupId = null, parentArtifactId = null, parentVersion = null, parentId = null, parentRelativePath; - private Model model; + protected Model model; public Model getModel() throws IOException { diff --git a/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java b/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java index 8eca0d08a2..48535cec46 100644 --- a/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java +++ b/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProcessorContext.java @@ -170,10 +170,17 @@ public class ProcessorContext return models; } - public static PomClassicDomainModel build( List domainModels, - List interpolationProperties, List listeners) - throws IOException - { + /** + * Parent domain models on bottom. + * + * @param domainModels + * @param listeners + * @return + * @throws IOException + */ + public static PomClassicDomainModel build( List domainModels, List listeners ) + throws IOException + { PomClassicDomainModel child = null; for ( DomainModel domainModel : domainModels ) { @@ -196,24 +203,18 @@ public class ProcessorContext new LicensesProcessor(), new ScmProcessor(), new PrerequisitesProcessor(), new ContributorsProcessor(), new DevelopersProcessor(), new ProfilesProcessor() ); Model target = processModelsForInheritance( convertDomainModelsToMavenModels( domainModels ), processors ); - + if(listeners != null) + { + for(ModelEventListener listener : listeners) + { + listener.fire(target); + } + } PomClassicDomainModel domainModel = new PomClassicDomainModel( target, child.isMostSpecialized() ); domainModel.setProjectDirectory(child.getProjectDirectory()); domainModel.setParentFile(child.getParentFile()); + return domainModel; - } - /** - * Parent domain models on bottom. - * - * @param domainModels - * @return - * @throws IOException - */ - public static PomClassicDomainModel build( List domainModels, - List interpolationProperties ) - throws IOException - { - return build(domainModels, interpolationProperties, null); } private static Model processModelsForInheritance(List models, List processors) @@ -680,7 +681,7 @@ public class ProcessorContext } } - private static List createInterpolatorProperties(List modelProperties, + public static List createInterpolatorProperties(List modelProperties, String baseUriForModel, Map aliases, String interpolatorTag) @@ -864,7 +865,7 @@ public class ProcessorContext return sb.toString(); } - public static List getModelProperties(InputStream is) throws IOException + private static List getModelProperties(InputStream is) throws IOException { Set s = new HashSet(); //TODO: Should add all collections from ProjectUri @@ -893,7 +894,7 @@ public class ProcessorContext return new ArrayList(marshallXmlToModelProperties(is, ProjectUri.baseUri, s )); } - private static final Set URIS = Collections.unmodifiableSet(new HashSet( Arrays.asList( ProjectUri.Build.Extensions.xUri, + public static final Set URIS = Collections.unmodifiableSet(new HashSet( Arrays.asList( ProjectUri.Build.Extensions.xUri, ProjectUri.Build.PluginManagement.Plugins.xUri, ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration, ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri, diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 3ebd0afd27..99d3fa238b 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -15,12 +15,9 @@ package org.apache.maven.project; * the License. */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.Reader; -import java.io.Writer; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; @@ -48,7 +45,7 @@ import org.apache.maven.profiles.ProfileManager; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.builder.DomainModel; import org.apache.maven.project.builder.InterpolatorProperty; -import org.apache.maven.project.builder.ModelProperty; +import org.apache.maven.project.builder.ModelEventListener; import org.apache.maven.project.builder.PomClassicDomainModel; import org.apache.maven.project.builder.PomInterpolatorTag; import org.apache.maven.project.builder.ProcessorContext; @@ -56,7 +53,6 @@ import org.apache.maven.project.validation.ModelValidationResult; import org.apache.maven.project.validation.ModelValidator; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.VersionNotFoundException; -import org.apache.maven.shared.model.ModelEventListener; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @@ -513,7 +509,7 @@ public class DefaultMavenProjectBuilder } } - PomClassicDomainModel transformedDomainModel = ProcessorContext.build( profileModels, null ); + PomClassicDomainModel transformedDomainModel = ProcessorContext.build(profileModels, listeners); // Lineage count is inclusive to add the POM read in itself. transformedDomainModel.setLineageCount( lineageCount + 1 ); diff --git a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java index e35c7ab7a4..56b7884860 100644 --- a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -220,7 +220,6 @@ public class PomConstructionTest throws Exception { PomTestWrapper pom = buildPom( "plugin-management-dependencies/sub", "test" ); - System.out.println(pom.getDomainModel().asString()); assertEquals( "1.0-alpha-21", pom.getValue( "build/plugins[1]/version" ) ); assertEquals( "1.0", pom.getValue( "build/plugins[1]/dependencies[1]/version" ) ); } @@ -782,7 +781,6 @@ public class PomConstructionTest throws Exception { PomTestWrapper pom = buildPom( "plugin-config-append/" + test + "/subproject" ); - System.out.println(pom.getDomainModel().asString()); String prefix = "build/plugins[1]/configuration/"; assertEquals( "PARENT-1", pom.getValue( prefix + "stringParams/stringParam[1]" ) ); assertEquals( "PARENT-3", pom.getValue( prefix + "stringParams/stringParam[2]" ) );