mirror of https://github.com/apache/maven.git
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
This commit is contained in:
parent
c2c3134b34
commit
57756314e2
|
@ -28,10 +28,6 @@
|
|||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-reporting-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
</dependency>
|
||||
<!-- Required for Maven Artifact mediator as we phase it out. -->
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
@ -109,10 +105,6 @@
|
|||
<artifactId>maven-mercury</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.sonatype.spice</groupId>
|
||||
<artifactId>model-builder</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.sonatype.plexus</groupId>
|
||||
<artifactId>plexus-sec-dispatcher</artifactId>
|
||||
|
@ -121,6 +113,20 @@
|
|||
<groupId>commons-jxpath</groupId>
|
||||
<artifactId>commons-jxpath</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-repo-remote-m2</artifactId>
|
||||
<version>${mercuryVersion}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
<artifactId>mercury-transport-http</artifactId>
|
||||
<version>${mercuryVersion}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
@ -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<BuildExtension> buildExtensions = new ArrayList<BuildExtension>();
|
||||
|
||||
public void fire(List<? extends ModelContainer> modelContainers)
|
||||
throws DataSourceException
|
||||
{
|
||||
if ( !inBuild )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ModelContainer mc : modelContainers )
|
||||
{
|
||||
if ( hasExtension( mc ) )
|
||||
{
|
||||
buildExtensions.add( new BuildExtension( mc.getProperties() ) );
|
||||
}
|
||||
}
|
||||
private List<Extension> buildExtensions = new ArrayList<Extension>();
|
||||
|
||||
public void fire(Model model)
|
||||
{
|
||||
buildExtensions.addAll(new ArrayList<Extension>(model.getBuild().getExtensions()));
|
||||
}
|
||||
|
||||
public List<String> getUris()
|
||||
{
|
||||
return Arrays.asList( ProjectUri.Build.Extensions.Extension.xUri );
|
||||
}
|
||||
|
||||
public Collection<ModelContainerFactory> 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<ModelProperty> 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() ) );
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<InterpolatorProperty> interpolatorProperties )
|
||||
throws IOException
|
||||
{
|
||||
List<ModelProperty> modelProperties = ModelMarshaller.marshallXmlToModelProperties( new ByteArrayInputStream( xml.getBytes() ), ProjectUri.baseUri, PomTransformer.URIS );
|
||||
List<ModelProperty> modelProperties = ProcessorContext.marshallXmlToModelProperties( new ByteArrayInputStream( xml.getBytes() ), ProjectUri.baseUri, ProcessorContext.URIS );
|
||||
|
||||
Map<String, String> aliases = new HashMap<String, String>();
|
||||
aliases.put( "project.", "pom." );
|
||||
|
||||
List<InterpolatorProperty> ips = new ArrayList<InterpolatorProperty>( interpolatorProperties );
|
||||
ips.addAll( ModelTransformerContext.createInterpolatorProperties( modelProperties, ProjectUri.baseUri, aliases, PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false ) );
|
||||
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
|
||||
|
|
|
@ -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<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
|
||||
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<ModelProperty> modelProperties;
|
||||
|
||||
public TestModelContainer( List<ModelProperty> properties )
|
||||
{
|
||||
this.modelProperties = properties;
|
||||
}
|
||||
|
||||
public List<ModelProperty> getProperties()
|
||||
{
|
||||
return new ArrayList<ModelProperty>( modelProperties );
|
||||
}
|
||||
|
||||
public ModelContainerAction containerAction( ModelContainer modelContainer )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, String> asMap( boolean withResolvedValues )
|
||||
throws IOException
|
||||
{
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
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<ModelProperty> modelProperties )
|
||||
throws IOException
|
||||
{
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( !containsModelProperty( mp ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean matchModelProperties( List<ModelProperty> hasProperties, List<ModelProperty> doesNotHaveProperties )
|
||||
throws IOException
|
||||
{
|
||||
return containsAllModelPropertiesOf( hasProperties ) && containNoModelPropertiesOf( doesNotHaveProperties );
|
||||
}
|
||||
|
||||
public boolean matchUris( List<String> hasAllUris, List<String> doesNotHaveUris )
|
||||
throws IOException
|
||||
{
|
||||
return hasAllUris( hasAllUris ) && hasNoUris( doesNotHaveUris );
|
||||
}
|
||||
|
||||
public boolean containNoModelPropertiesOf( List<ModelProperty> 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<String> uris )
|
||||
throws IOException
|
||||
{
|
||||
for ( String s : uris )
|
||||
{
|
||||
if ( !hasUri( s ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasNoUris( List<String> uris )
|
||||
throws IOException
|
||||
{
|
||||
for ( String s : uris )
|
||||
{
|
||||
if ( hasUri( s ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,11 +42,6 @@
|
|||
<artifactId>plexus-component-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sonatype.spice</groupId>
|
||||
<artifactId>model-builder</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.mercury</groupId>
|
||||
|
@ -85,6 +80,12 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -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<ModelContainer> activeProfiles = domainModel.getActiveProfileContainers( interpolatorProperties );
|
||||
|
||||
for ( ModelContainer mc : activeProfiles )
|
||||
{
|
||||
domainModels.add( new MavenDomainModel( transformProfiles( mc.getProperties() ) ) );
|
||||
}
|
||||
|
||||
*/
|
||||
List<DomainModel> 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<InterpolatorProperty> createInterpolatorProperties(Map system, Map user)
|
||||
|
@ -165,20 +154,4 @@ public class MavenDependencyProcessor
|
|||
}
|
||||
return domainModels;
|
||||
}
|
||||
|
||||
private static List<ModelProperty> transformProfiles( List<ModelProperty> modelProperties )
|
||||
{
|
||||
List<ModelProperty> properties = new ArrayList<ModelProperty>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ArtifactMetadata> 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<InterpolatorProperty> interpolatorProperties = createInterpolatorProperties(system, user);
|
||||
|
||||
List<DomainModel> domainModels = new ArrayList<DomainModel>();
|
||||
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<DomainModel> 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;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> 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<ModelProperty> modelProperties )
|
||||
throws IOException
|
||||
{
|
||||
super(modelProperties);
|
||||
this.modelProperties = new ArrayList<ModelProperty>( 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<ArtifactMetadata> getDependencyMetadata()
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ArtifactMetadata> metadatas = new ArrayList<ArtifactMetadata>();
|
||||
|
||||
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<ArtifactMetadata> exclusions = new ArrayList<ArtifactMetadata>();
|
||||
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<ModelContainer> getActiveProfileContainers( List<InterpolatorProperty> 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<ModelProperty> getModelProperties()
|
||||
throws IOException
|
||||
{
|
||||
return new ArrayList<ModelProperty>( modelProperties );
|
||||
}
|
||||
|
||||
private ArtifactMetadata transformContainerToMetadata( ModelContainer container )
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelProperty> 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<ArtifactMetadata> exclusions = new ArrayList<ArtifactMetadata>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ModelProperty> modelProperties )
|
||||
throws IOException
|
||||
{
|
||||
return new MavenDomainModel( modelProperties );
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> getRawPom(ArtifactMetadata bmd, MetadataReader mdReader, Map<String, String> env,
|
||||
Map<String, String> sysProps)
|
||||
throws MetadataReaderException, PomProcessorException;
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -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<String> uris = Collections.unmodifiableList( Arrays.asList(
|
||||
|
||||
ProjectUri.Build.Plugins.Plugin.Executions.Execution.Goals.goal
|
||||
// ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri
|
||||
|
||||
) );
|
||||
|
||||
public Collection<String> getUris()
|
||||
{
|
||||
return uris;
|
||||
}
|
||||
|
||||
public ModelContainer create( List<ModelProperty> 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<ModelProperty> properties) {
|
||||
this.properties = new ArrayList<ModelProperty>(properties);
|
||||
}
|
||||
|
||||
private List<ModelProperty> properties;
|
||||
|
||||
|
||||
public ModelContainerAction containerAction( ModelContainer modelContainer )
|
||||
{
|
||||
return ModelContainerAction.JOIN;
|
||||
}
|
||||
|
||||
public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
|
||||
{
|
||||
return new Anon_ModelContainer( modelProperties );
|
||||
}
|
||||
|
||||
public List<ModelProperty> getProperties()
|
||||
{
|
||||
return new ArrayList<ModelProperty>(properties);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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<String> 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<String> u;
|
||||
|
||||
public Collection<String> getUris()
|
||||
{
|
||||
return u;
|
||||
}
|
||||
|
||||
public ArtifactModelContainerFactory() {
|
||||
u = uris;
|
||||
}
|
||||
|
||||
public ArtifactModelContainerFactory(String uri) {
|
||||
u = Collections.unmodifiableList( Arrays.asList(uri) );
|
||||
}
|
||||
|
||||
public ModelContainer create( List<ModelProperty> 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<ModelProperty> properties;
|
||||
|
||||
private static String findBaseUriFrom( List<ModelProperty> modelProperties )
|
||||
{
|
||||
String baseUri = null;
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( baseUri == null || mp.getUri().length() < baseUri.length() )
|
||||
{
|
||||
baseUri = mp.getUri();
|
||||
}
|
||||
}
|
||||
return baseUri;
|
||||
}
|
||||
|
||||
private ArtifactModelContainer( List<ModelProperty> properties )
|
||||
{
|
||||
this.properties = new ArrayList<ModelProperty>( 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<ModelProperty> modelProperties )
|
||||
{
|
||||
return new ArtifactModelContainer( modelProperties );
|
||||
}
|
||||
|
||||
public List<ModelProperty> 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<String> uris = Collections.unmodifiableList( Arrays.asList(
|
||||
|
||||
ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri
|
||||
|
||||
) );
|
||||
|
||||
public Collection<String> getUris()
|
||||
{
|
||||
return uris;
|
||||
}
|
||||
|
||||
public ModelContainer create( List<ModelProperty> 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<ModelProperty> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
private List<ModelProperty> properties;
|
||||
|
||||
|
||||
public ModelContainerAction containerAction( ModelContainer modelContainer )
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
|
||||
{
|
||||
return new ExclusionModelContainer( modelProperties );
|
||||
}
|
||||
|
||||
public List<ModelProperty> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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<IdModelContainerFactory> 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<String> getUris()
|
||||
{
|
||||
return Collections.unmodifiableList(Arrays.asList(uri));
|
||||
}
|
||||
|
||||
public ModelContainer create( List<ModelProperty> 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<ModelProperty> properties;
|
||||
|
||||
private IdModelContainer( List<ModelProperty> properties )
|
||||
{
|
||||
this.properties = new ArrayList<ModelProperty>( 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<ModelProperty> modelProperties )
|
||||
{
|
||||
return new IdModelContainer( modelProperties );
|
||||
}
|
||||
|
||||
public List<ModelProperty> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "ID = " + id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<String> uris = Collections.unmodifiableList(Arrays.asList(
|
||||
ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.Execution.xUri));
|
||||
|
||||
public Collection<String> getUris() {
|
||||
return uris;
|
||||
}
|
||||
|
||||
public ModelContainer create(List<ModelProperty> 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<ModelProperty> properties;
|
||||
|
||||
private PluginExecutionIdModelContainer( List<ModelProperty> properties )
|
||||
{
|
||||
this.properties = new ArrayList<ModelProperty>( 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<ModelProperty> modelProperties )
|
||||
{
|
||||
return new PluginExecutionIdModelContainer( modelProperties );
|
||||
}
|
||||
|
||||
public List<ModelProperty> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "ID = " + id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<String> uris = Collections.unmodifiableList(Arrays.asList(
|
||||
ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri));
|
||||
|
||||
public Collection<String> getUris() {
|
||||
return uris;
|
||||
}
|
||||
|
||||
public ModelContainer create(List<ModelProperty> 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<ModelProperty> properties;
|
||||
|
||||
private PluginReportSetIdModelContainer( List<ModelProperty> properties )
|
||||
{
|
||||
this.properties = new ArrayList<ModelProperty>( 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<ModelProperty> modelProperties )
|
||||
{
|
||||
return new PluginReportSetIdModelContainer( modelProperties );
|
||||
}
|
||||
|
||||
public List<ModelProperty> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "ID = " + id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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<ModelProperty> execute(List<ModelProperty> modelProperties) throws DataSourceException;
|
||||
}
|
|
@ -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<ModelProperty> 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<ModelProperty> 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<ModelProperty> 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<ModelProperty> 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<ModelProperty> getModelProperties() throws IOException
|
||||
{
|
||||
if(modelProperties == null)
|
||||
{
|
||||
Set<String> s = new HashSet<String>();
|
||||
//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<ModelProperty>(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<ModelProperty> props = new ArrayList<ModelProperty>();
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -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<ModelProperty> modelProperties) throws IOException
|
||||
{
|
||||
return new PomClassicDomainModel(modelProperties);
|
||||
}
|
||||
}
|
|
@ -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<ModelContainerFactory> 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<ModelContainerInfo> goals_infos = Arrays.asList(
|
||||
ModelContainerInfo.Factory.createModelContainerInfo(
|
||||
new AlwaysJoinModelContainerFactory(), new ExecutionRule(), null)
|
||||
);
|
||||
|
||||
private static Collection<ModelContainerInfo> plugin_executions = Arrays.asList(
|
||||
ModelContainerInfo.Factory.createModelContainerInfo(
|
||||
new IdModelContainerFactory(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri),
|
||||
null, goals_infos)
|
||||
);
|
||||
|
||||
private static Collection<ModelContainerInfo> 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<ModelContainerInfo> 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<String> URIS = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.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<String> PATH_URIS =
|
||||
Collections.unmodifiableSet( new HashSet<String>(
|
||||
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<ModelProperty> properties, List<? extends ModelEventListener> eventListeners )
|
||||
throws IOException
|
||||
{
|
||||
if ( properties == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "properties: null" );
|
||||
}
|
||||
|
||||
if( eventListeners == null )
|
||||
{
|
||||
eventListeners = new ArrayList<ModelEventListener>();
|
||||
}
|
||||
else
|
||||
{
|
||||
eventListeners = new ArrayList<ModelEventListener>(eventListeners);
|
||||
}
|
||||
|
||||
List<ModelProperty> props = new ArrayList<ModelProperty>( properties );
|
||||
|
||||
|
||||
ModelDataSource source = new DefaultModelDataSource( props, PomTransformer.MODEL_CONTAINER_FACTORIES );
|
||||
|
||||
//Dependency Management
|
||||
new DependencyManagementDataSourceRule().execute( source );
|
||||
|
||||
//Plugin Management
|
||||
List<ModelProperty> joinedContainers = new ArrayList<ModelProperty>();
|
||||
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<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();
|
||||
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<ModelProperty> pList;
|
||||
|
||||
if ( !hasExecutionsTag )
|
||||
{
|
||||
pList = managementContainer.getProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
pList = new ArrayList<ModelProperty>();
|
||||
|
||||
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<ModelContainer> managementExecutionContainers = managementDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
|
||||
List<ModelProperty> managementPropertiesWithoutExecutions = new ArrayList<ModelProperty>(managementContainer.getProperties());
|
||||
for(ModelContainer a : managementExecutionContainers)
|
||||
{
|
||||
managementPropertiesWithoutExecutions.removeAll(a.getProperties());
|
||||
}
|
||||
|
||||
source.joinWithOriginalOrder( pluginContainer, new ArtifactModelContainerFactory().create(managementPropertiesWithoutExecutions) );
|
||||
|
||||
List<ModelContainer> pluginExecutionContainers = pluginDatasource.queryFor(ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri);
|
||||
List<ModelContainer> joinedExecutionContainers = new ArrayList<ModelContainer>();
|
||||
|
||||
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<ModelProperty> listWithId = new ArrayList<ModelProperty>(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<ModelProperty> removeProperties = new HashSet<ModelProperty>();
|
||||
|
||||
ModelDataSource dataSource = new DefaultModelDataSource( props, PomTransformer.MODEL_CONTAINER_FACTORIES );
|
||||
|
||||
List<ModelContainer> 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<ModelContainer> 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<ModelProperty> x = rule.execute(es.getProperties());
|
||||
List<ModelProperty> 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<ModelProperty> p = new ArrayList<ModelProperty>();
|
||||
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<ModelProperty> a, List<ModelProperty> b) {
|
||||
for(ModelProperty mpA : a )
|
||||
{
|
||||
for(ModelProperty mpB : b)
|
||||
{
|
||||
if(mpA.equals(mpB))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<TransformerRule> transformerRules = Arrays.asList(new MissingVersionTransformerRule(),
|
||||
new DefaultDependencyScopeTransformerRule(), new MissingGroupIdTransformerRule());
|
||||
|
||||
List<TransformerRemovalRule> 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<ModelProperty> transformToModelProperties(List<? extends DomainModel> domainModels
|
||||
)
|
||||
throws IOException
|
||||
{
|
||||
if ( domainModels == null || domainModels.isEmpty() )
|
||||
{
|
||||
throw new IllegalArgumentException( "domainModels: null or empty" );
|
||||
}
|
||||
|
||||
List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
|
||||
List<String> projectNames = new ArrayList<String>();
|
||||
StringBuilder projectUrl = new StringBuilder( 128 );
|
||||
StringBuilder siteUrl = new StringBuilder( 128 );
|
||||
StringBuilder scmUrl = new StringBuilder( 128 );
|
||||
StringBuilder scmConnectionUrl = new StringBuilder( 128 );
|
||||
StringBuilder scmDeveloperUrl = new StringBuilder( 128 );
|
||||
|
||||
boolean containsBuildResources = false;
|
||||
boolean containsTestResources = false;
|
||||
boolean containsPluginRepositories = false;
|
||||
boolean containsLicenses = false;
|
||||
boolean containsDevelopers = false;
|
||||
boolean containsContributors = false;
|
||||
boolean containsMailingLists = false;
|
||||
boolean containsOrganization = false;
|
||||
boolean containsIssueManagement = false;
|
||||
boolean containsCiManagement = false;
|
||||
boolean containsDistRepo = false;
|
||||
boolean containsDistSnapRepo = false;
|
||||
boolean containsDistSite = false;
|
||||
|
||||
|
||||
for ( DomainModel domainModel : domainModels )
|
||||
{
|
||||
List<ModelProperty> tmp = domainModel.getModelProperties();
|
||||
|
||||
List<ModelProperty> clearedProperties = new ArrayList<ModelProperty>();
|
||||
|
||||
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<String, String> aliases = new HashMap<String, String>();
|
||||
|
||||
private static void addProjectAlias( String element, boolean leaf )
|
||||
{
|
||||
String suffix = leaf ? "\\}" : "\\.";
|
||||
aliases.put( "\\$\\{project\\." + element + suffix, "\\$\\{" + element + suffix );
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
aliases.put( "\\$\\{project\\.", "\\$\\{pom\\." );
|
||||
addProjectAlias( "modelVersion", true );
|
||||
addProjectAlias( "groupId", true );
|
||||
addProjectAlias( "artifactId", true );
|
||||
addProjectAlias( "version", true );
|
||||
addProjectAlias( "packaging", true );
|
||||
addProjectAlias( "name", true );
|
||||
addProjectAlias( "description", true );
|
||||
addProjectAlias( "inceptionYear", true );
|
||||
addProjectAlias( "url", true );
|
||||
addProjectAlias( "parent", false );
|
||||
addProjectAlias( "prerequisites", false );
|
||||
addProjectAlias( "organization", false );
|
||||
addProjectAlias( "build", false );
|
||||
addProjectAlias( "reporting", false );
|
||||
addProjectAlias( "scm", false );
|
||||
addProjectAlias( "distributionManagement", false );
|
||||
addProjectAlias( "issueManagement", false );
|
||||
addProjectAlias( "ciManagement", false );
|
||||
}
|
||||
|
||||
public void interpolateModelProperties( List<ModelProperty> modelProperties,
|
||||
List<InterpolatorProperty> interpolatorProperties,
|
||||
DomainModel domainModel )
|
||||
throws IOException
|
||||
{
|
||||
PomClassicDomainModel dm = (PomClassicDomainModel) domainModel;
|
||||
|
||||
if ( !containsProjectVersion( interpolatorProperties ) )
|
||||
{
|
||||
aliases.put( "\\$\\{project.version\\}", "\\$\\{version\\}" );
|
||||
}
|
||||
|
||||
List<ModelProperty> firstPassModelProperties = new ArrayList<ModelProperty>();
|
||||
List<ModelProperty> secondPassModelProperties = new ArrayList<ModelProperty>();
|
||||
|
||||
ModelProperty buildProperty = new ModelProperty( ProjectUri.Build.xUri, null );
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getValue() != null && !mp.getUri().contains( "#property" ) && !mp.getUri().contains( "#collection" ) )
|
||||
{
|
||||
if ( ( !buildProperty.isParentOf( mp ) && !mp.getUri().equals( ProjectUri.Reporting.outputDirectory ) || mp.getUri().equals( ProjectUri.Build.finalName ) ) )
|
||||
{
|
||||
firstPassModelProperties.add( mp );
|
||||
}
|
||||
else
|
||||
{
|
||||
secondPassModelProperties.add( mp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<InterpolatorProperty> standardInterpolatorProperties = new ArrayList<InterpolatorProperty>();
|
||||
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<InterpolatorProperty> ips1 = new ArrayList<InterpolatorProperty>( interpolatorProperties );
|
||||
ips1.addAll( standardInterpolatorProperties );
|
||||
ips1.addAll( ModelTransformerContext.createInterpolatorProperties( firstPassModelProperties, ProjectUri.baseUri, aliases, PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false ) );
|
||||
Collections.sort( ips1, new Comparator<InterpolatorProperty>()
|
||||
{
|
||||
public int compare( InterpolatorProperty o, InterpolatorProperty o1 )
|
||||
{
|
||||
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<ModelProperty, ModelProperty> buildDirectories = new HashMap<ModelProperty, ModelProperty>();
|
||||
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<ModelProperty, ModelProperty> e : buildDirectories.entrySet() )
|
||||
{
|
||||
secondPassModelProperties.remove( e.getKey() );
|
||||
secondPassModelProperties.add( e.getValue() );
|
||||
}
|
||||
}
|
||||
|
||||
//THIRD PASS - Use build directories as interpolator properties
|
||||
List<InterpolatorProperty> ips2 = new ArrayList<InterpolatorProperty>( interpolatorProperties );
|
||||
ips2.addAll( standardInterpolatorProperties );
|
||||
ips2.addAll( ModelTransformerContext.createInterpolatorProperties( secondPassModelProperties, ProjectUri.baseUri, aliases, PomInterpolatorTag.PROJECT_PROPERTIES.name(), false, false ) );
|
||||
ips2.addAll( interpolatorProperties );
|
||||
Collections.sort( ips2, new Comparator<InterpolatorProperty>()
|
||||
{
|
||||
public int compare( InterpolatorProperty o, InterpolatorProperty o1 )
|
||||
{
|
||||
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<ModelProperty> preprocessModelProperties(List<ModelProperty> modelProperties)
|
||||
{
|
||||
return new ArrayList<ModelProperty>(modelProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base uri of all model properties: http://apache.org/maven/project/
|
||||
*
|
||||
* @return Returns the base uri of all model properties: http://apache.org/maven/project/
|
||||
*/
|
||||
public final String getBaseUri()
|
||||
{
|
||||
return ProjectUri.baseUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts an inherited URL to compensate for a child's relation/distance to the parent that defines the URL.
|
||||
*
|
||||
* @param url The buffer for the adjusted URL, must not be {@code null}.
|
||||
* @param properties The model properties to update, must not be {@code null}.
|
||||
* @param uri The URI of the model property defining the URL to adjust, must not be {@code null}.
|
||||
* @param ids The artifact identifiers of the parent projects, starting with the least significant parent, must not
|
||||
* be {@code null}.
|
||||
*/
|
||||
private void adjustUrl( StringBuilder url, List<ModelProperty> properties, String uri, List<String> ids )
|
||||
{
|
||||
if ( url.length() == 0 )
|
||||
{
|
||||
ModelProperty property = getPropertyFor( uri, properties );
|
||||
if ( property != null )
|
||||
{
|
||||
url.append( property.getResolvedValue() );
|
||||
for ( String id : ids )
|
||||
{
|
||||
if ( url.length() > 0 && url.charAt( url.length() - 1 ) != '/' )
|
||||
{
|
||||
url.append( '/' );
|
||||
}
|
||||
url.append( id );
|
||||
}
|
||||
int index = properties.indexOf( property );
|
||||
properties.set( index, new ModelProperty( uri, url.toString() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean containsProjectVersion( List<InterpolatorProperty> interpolatorProperties )
|
||||
{
|
||||
InterpolatorProperty versionInterpolatorProperty =
|
||||
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<ModelProperty> modelProperties )
|
||||
{
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().equals( projectUri ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all model properties containing the specified uri from the specified properties list.
|
||||
*
|
||||
* @param uri the uri to use in finding the returned model properties
|
||||
* @param properties the model properties list to search
|
||||
* @return all model properties containing the specified uri from the specified properties list
|
||||
*/
|
||||
public static List<ModelProperty> getPropertiesFor( String uri, List<ModelProperty> properties )
|
||||
{
|
||||
List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
|
||||
for ( ModelProperty mp : properties )
|
||||
{
|
||||
if ( uri.equals( mp.getUri() ) )
|
||||
{
|
||||
modelProperties.add( mp );
|
||||
}
|
||||
}
|
||||
return modelProperties;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the first model property containing the specified uri from the specified properties list.
|
||||
*
|
||||
* @param uri the uri to use in finding the returned model property
|
||||
* @param properties the model properties list to search
|
||||
* @return the first model property containing the specified uri from the specified properties list.
|
||||
*/
|
||||
public static ModelProperty getPropertyFor( String uri, List<ModelProperty> properties )
|
||||
{
|
||||
for ( ModelProperty mp : properties )
|
||||
{
|
||||
if ( uri.equals( mp.getUri() ) )
|
||||
{
|
||||
return mp;
|
||||
}
|
||||
}
|
||||
return 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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> modelProperties, boolean isMostSpecialized)
|
||||
throws DataSourceException;
|
||||
}
|
|
@ -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<ModelProperty> modelProperties, boolean isMostSpecialized) throws DataSourceException;
|
||||
|
||||
}
|
|
@ -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<InterpolatorProperty> properties);
|
||||
}
|
|
@ -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<InterpolatorProperty> 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;
|
||||
}
|
||||
}
|
|
@ -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<InterpolatorProperty> properties) {
|
||||
if(modelContainer == null ) {
|
||||
throw new IllegalArgumentException("modelContainer: null");
|
||||
}
|
||||
|
||||
List<String> exists = new ArrayList<String>(), missings = new ArrayList<String>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<InterpolatorProperty> 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<RangeValue> 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<String> valueTokens = new ArrayList<String>( Arrays.asList( value.split( "\\." ) ) );
|
||||
List<String> rangeValueTokens = new ArrayList<String>( 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<String> 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<RangeValue> getRange( String range )
|
||||
{
|
||||
List<RangeValue> ranges = new ArrayList<RangeValue>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<InterpolatorProperty> 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;
|
||||
}
|
||||
}
|
|
@ -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<InterpolatorProperty> properties;
|
||||
|
||||
private Collection<String> activeProfileIds;
|
||||
|
||||
private Collection<String> inactiveProfileIds;
|
||||
|
||||
private ActiveProfileMatcher defaultMatcher = new ByDefaultMatcher();
|
||||
|
||||
private List<ActiveProfileMatcher> matchers = Collections.unmodifiableList( Arrays.asList(
|
||||
new FileMatcher(), new JdkMatcher(), new OperatingSystemMatcher(), new PropertyMatcher()
|
||||
) );
|
||||
|
||||
public ProfileContext( ModelDataSource modelDataSource, Collection<String> activeProfileIds,
|
||||
Collection<String> inactiveProfileIds, List<InterpolatorProperty> properties )
|
||||
{
|
||||
this.modelDataSource = modelDataSource;
|
||||
this.properties = new ArrayList<InterpolatorProperty>( properties );
|
||||
this.activeProfileIds = ( activeProfileIds != null ) ? activeProfileIds : new ArrayList<String>();
|
||||
this.inactiveProfileIds = ( inactiveProfileIds != null ) ? inactiveProfileIds : new ArrayList<String>();
|
||||
}
|
||||
|
||||
public Collection<ModelContainer> getActiveProfiles()
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelContainer> matchedContainers = new ArrayList<ModelContainer>();
|
||||
List<ModelContainer> defaultContainers = new ArrayList<ModelContainer>();
|
||||
|
||||
List<ModelContainer> 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<ModelProperty> modelProperties)
|
||||
{
|
||||
for(ModelProperty mp : modelProperties)
|
||||
{
|
||||
if(mp.getUri().equals(ProfileUri.Profiles.Profile.id))
|
||||
{
|
||||
return mp.getResolvedValue();
|
||||
}
|
||||
}
|
||||
return 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";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<InterpolatorProperty> 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;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> 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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> modelProperties, boolean isMostSpecialized)
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelProperty> replace = new ArrayList<ModelProperty>();
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<ModelContainer> 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<ModelProperty> transformDependencyManagement( List<ModelProperty> modelProperties )
|
||||
{
|
||||
List<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> execute(List<ModelProperty> modelProperties) {
|
||||
List<ModelProperty> properties = new ArrayList<ModelProperty>(modelProperties);
|
||||
List<ModelProperty> goalProperties = new ArrayList<ModelProperty>();
|
||||
List<ModelProperty> processedProperties = new ArrayList<ModelProperty>();
|
||||
|
||||
return processedProperties;
|
||||
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> modelProperties, boolean isMostSpecialized)
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelProperty> removedProperties = new ArrayList<ModelProperty>();
|
||||
List<String> filters = new ArrayList<String>();
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> execute(List<ModelProperty> modelProperties) {
|
||||
List<ModelProperty> properties = new ArrayList<ModelProperty>(modelProperties);
|
||||
List<ModelProperty> goalProperties = new ArrayList<ModelProperty>();
|
||||
List<ModelProperty> processedProperties = new ArrayList<ModelProperty>();
|
||||
|
||||
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<ModelProperty> c = new ArrayList<ModelProperty>();
|
||||
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<ModelProperty> uniqueGoals = new ArrayList<ModelProperty>();
|
||||
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<ModelProperty> emptyTags = new ArrayList<ModelProperty>();
|
||||
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<ModelProperty> modelProperties) {
|
||||
for(ModelProperty mp : modelProperties) {
|
||||
if(mp.getUri().equals(uri)) {
|
||||
return modelProperties.indexOf(mp);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static boolean containsProperty(ModelProperty modelProperty, List<ModelProperty> 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;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> 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() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> 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() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> 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<ModelProperty>();//todo: fix
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> modelProperties, boolean isMostSpecialized)
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelProperty> removedProperties = new ArrayList<ModelProperty>();
|
||||
if ( !isMostSpecialized )
|
||||
{
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().startsWith( ProjectUri.name ) )
|
||||
{
|
||||
removedProperties.add( mp );
|
||||
return removedProperties;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removedProperties;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> modelProperties, boolean isMostSpecialized)
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
|
||||
|
||||
if ( !isMostSpecialized)
|
||||
{
|
||||
ModelDataSource source = new DefaultModelDataSource( modelProperties, Arrays.asList(
|
||||
new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() ));
|
||||
List<ModelContainer> containers =
|
||||
source.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
|
||||
for ( ModelContainer container : containers )
|
||||
{
|
||||
for ( ModelProperty mp : container.getProperties() )
|
||||
{
|
||||
if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.Execution.inherited ) &&
|
||||
mp.getResolvedValue() != null && mp.getResolvedValue().equals( "false" ) )
|
||||
{
|
||||
removeProperties.addAll( container.getProperties() );
|
||||
for ( int j = 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;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> modelProperties, boolean isMostSpecialized)
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
|
||||
if ( !isMostSpecialized)
|
||||
{
|
||||
ModelDataSource source = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES );
|
||||
List<ModelContainer> containers = source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri );
|
||||
for ( ModelContainer container : containers )
|
||||
{
|
||||
for ( ModelProperty mp : container.getProperties() )
|
||||
{
|
||||
if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.inherited ) && mp.getResolvedValue() != null &&
|
||||
mp.getResolvedValue().equals( "false" ) )
|
||||
{
|
||||
removeProperties.addAll( container.getProperties() );
|
||||
for ( int j = 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;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> execute(List<ModelProperty> modelProperties) throws DataSourceException
|
||||
{
|
||||
ModelDataSource source = new DefaultModelDataSource( modelProperties, PomTransformer.MODEL_CONTAINER_FACTORIES );
|
||||
List<ModelContainer> reportContainers = source.queryFor( ProjectUri.Reporting.Plugins.Plugin.xUri );
|
||||
for ( ModelContainer pluginContainer : source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri ) )
|
||||
{
|
||||
ModelContainer transformedReportContainer = new ArtifactModelContainerFactory().create(
|
||||
transformPlugin( pluginContainer.getProperties() ) );
|
||||
|
||||
for(ModelContainer reportContainer : reportContainers) {
|
||||
ModelContainerAction action = transformedReportContainer.containerAction( reportContainer );
|
||||
if ( action.equals( ModelContainerAction.JOIN ) )
|
||||
{
|
||||
source.join( transformedReportContainer, reportContainer );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return source.getModelProperties();
|
||||
}
|
||||
|
||||
private static List<ModelProperty> transformPlugin( List<ModelProperty> modelProperties )
|
||||
{
|
||||
List<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().startsWith( ProjectUri.Build.Plugins.xUri ) )
|
||||
{ if(mp.getUri().startsWith(ProjectUri.Build.Plugins.Plugin.configuration)
|
||||
|| mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.groupId)
|
||||
|| mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.artifactId)
|
||||
|| mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.version)
|
||||
|| mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.xUri ) )
|
||||
{
|
||||
transformedProperties.add( new ModelProperty(
|
||||
mp.getUri().replace( ProjectUri.Build.Plugins.xUri, ProjectUri.Reporting.Plugins.xUri ),
|
||||
mp.getResolvedValue() ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return transformedProperties;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> modelProperties, boolean isMostSpecialized)
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelProperty> removedProperties = new ArrayList<ModelProperty>();
|
||||
if ( !isMostSpecialized )
|
||||
{
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().startsWith( ProjectUri.packaging ) )
|
||||
{
|
||||
removedProperties.add( mp );
|
||||
return removedProperties;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removedProperties;
|
||||
}
|
||||
}
|
|
@ -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<ModelProperty> executeWithReturnPropertiesToRemove(List<ModelProperty> modelProperties, boolean isMostSpecialized)
|
||||
throws DataSourceException
|
||||
{
|
||||
List<ModelProperty> removedProperties = new ArrayList<ModelProperty>();
|
||||
if ( !isMostSpecialized )
|
||||
{
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().startsWith( ProjectUri.Parent.relativePath ) )
|
||||
{
|
||||
removedProperties.add( mp );
|
||||
return removedProperties;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removedProperties;
|
||||
}
|
||||
}
|
|
@ -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<String> getUris();
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -170,10 +170,17 @@ public class ProcessorContext
|
|||
return models;
|
||||
}
|
||||
|
||||
public static PomClassicDomainModel build( List<DomainModel> domainModels,
|
||||
List<InterpolatorProperty> interpolationProperties, List<ModelEventListener> listeners)
|
||||
throws IOException
|
||||
{
|
||||
/**
|
||||
* Parent domain models on bottom.
|
||||
*
|
||||
* @param domainModels
|
||||
* @param listeners
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static PomClassicDomainModel build( List<DomainModel> domainModels, List<ModelEventListener> 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<DomainModel> domainModels,
|
||||
List<InterpolatorProperty> interpolationProperties )
|
||||
throws IOException
|
||||
{
|
||||
return build(domainModels, interpolationProperties, null);
|
||||
}
|
||||
|
||||
private static Model processModelsForInheritance(List<Model> models, List<Processor> processors)
|
||||
|
@ -680,7 +681,7 @@ public class ProcessorContext
|
|||
}
|
||||
}
|
||||
|
||||
private static List<InterpolatorProperty> createInterpolatorProperties(List<ModelProperty> modelProperties,
|
||||
public static List<InterpolatorProperty> createInterpolatorProperties(List<ModelProperty> modelProperties,
|
||||
String baseUriForModel,
|
||||
Map<String, String> aliases,
|
||||
String interpolatorTag)
|
||||
|
@ -864,7 +865,7 @@ public class ProcessorContext
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public static List<ModelProperty> getModelProperties(InputStream is) throws IOException
|
||||
private static List<ModelProperty> getModelProperties(InputStream is) throws IOException
|
||||
{
|
||||
Set<String> s = new HashSet<String>();
|
||||
//TODO: Should add all collections from ProjectUri
|
||||
|
@ -893,7 +894,7 @@ public class ProcessorContext
|
|||
|
||||
return new ArrayList<ModelProperty>(marshallXmlToModelProperties(is, ProjectUri.baseUri, s ));
|
||||
}
|
||||
private static final Set<String> URIS = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri,
|
||||
public static final Set<String> URIS = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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]" ) );
|
||||
|
|
Loading…
Reference in New Issue