Merge of SI_MAVEN_2_1 branch. New builder code.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@679609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2008-07-24 23:06:59 +00:00
parent d52ffdef81
commit c8b842c976
17 changed files with 3210 additions and 67 deletions

View File

@ -334,9 +334,9 @@ public class MavenEmbedderTest
MavenProject project = maven.readProject( pomFile );
assertEquals( "http://host/viewer?path=/trunk/parent/modules/child1", project.getScm().getUrl() );
assertEquals( "scm:svn:http://host/trunk/parent/modules/child1", project.getScm().getConnection() );
assertEquals( "scm:svn:https://host/trunk/parent/modules/child1", project.getScm().getDeveloperConnection() );
assertEquals( "http://host/viewer?path=/trunk/parent/child1", project.getScm().getUrl() );
assertEquals( "scm:svn:http://host/trunk/parent/child1", project.getScm().getConnection() );
assertEquals( "scm:svn:https://host/trunk/parent/child1", project.getScm().getDeveloperConnection() );
}
public void testProjectReading_SkipMissingModuleSilently()

View File

@ -68,7 +68,15 @@ under the License.
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<scope>test</scope>
</dependency>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-model</artifactId>
</dependency>
</dependencies>
<build>
<plugins>

View File

@ -46,6 +46,7 @@ import org.apache.maven.model.Extension;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Parent;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Repository;
import org.apache.maven.model.Resource;
@ -69,6 +70,9 @@ import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
import org.apache.maven.project.workspace.ProjectWorkspace;
import org.apache.maven.project.builder.PomArtifactResolver;
import org.apache.maven.project.builder.ProjectBuilder;
import org.apache.maven.project.builder.PomClassicDomainModel;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@ -77,24 +81,9 @@ import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.*;
/*:apt
@ -137,7 +126,7 @@ public class DefaultMavenProjectBuilder
implements MavenProjectBuilder,
Initializable, LogEnabled
{
protected MavenProfilesBuilder profilesBuilder;
protected MavenProfilesBuilder profilesBuilder;
protected ArtifactResolver artifactResolver;
@ -166,6 +155,8 @@ public class DefaultMavenProjectBuilder
private ProjectWorkspace projectWorkspace;
private ProjectBuilder projectBuilder;
//DO NOT USE, it is here only for backward compatibility reasons. The existing
// maven-assembly-plugin (2.2-beta-1) is accessing it via reflection.
@ -500,11 +491,9 @@ public class DefaultMavenProjectBuilder
if ( project == null )
{
// getLogger().debug( "Allowing project-build to proceed for: " + projectDescriptor );
Model model = readModel( "unknown", projectDescriptor, STRICT_MODEL_PARSING );
project = buildInternal( model,
Model model = readModelFromLocalPath( "unknown", projectDescriptor, new PomArtifactResolver(config.getLocalRepository(),
buildArtifactRepositories( getSuperModel() ), artifactResolver) );
project = buildInternal(model,
config,
buildArtifactRepositories( getSuperModel() ),
projectDescriptor,
@ -512,11 +501,6 @@ public class DefaultMavenProjectBuilder
true,
true );
}
// else
// {
// getLogger().debug( "Returning cached project: " + project );
// }
return project;
}
@ -525,8 +509,8 @@ public class DefaultMavenProjectBuilder
ArtifactRepository localRepository )
throws ProjectBuildingException
{
String projectId = safeVersionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
String projectId = safeVersionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
remoteArtifactRepositories = normalizeToArtifactRepositories( remoteArtifactRepositories, projectId );
Artifact projectArtifact;
@ -548,21 +532,20 @@ public class DefaultMavenProjectBuilder
artifact.getScope() );
}
Model model;
Model legacy_model;
try
{
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
File file = projectArtifact.getFile();
model = readModel( projectId, file, STRICT_MODEL_PARSING );
legacy_model = readModelLegacy( projectId, file, STRICT_MODEL_PARSING );
String downloadUrl = null;
ArtifactStatus status = ArtifactStatus.NONE;
DistributionManagement distributionManagement = model.getDistributionManagement();
DistributionManagement distributionManagement = legacy_model.getDistributionManagement();
if ( distributionManagement != null )
{
@ -581,7 +564,7 @@ public class DefaultMavenProjectBuilder
}
else
{
projectArtifact.setDownloadUrl( model.getUrl() );
projectArtifact.setDownloadUrl( legacy_model.getUrl() );
}
}
catch ( ArtifactResolutionException e )
@ -593,7 +576,7 @@ public class DefaultMavenProjectBuilder
throw new ProjectBuildingException( projectId, "POM '" + projectId + "' not found in repository: " + e.getMessage(), e );
}
return model;
return legacy_model;
}
private List normalizeToArtifactRepositories( List remoteArtifactRepositories,
@ -841,6 +824,7 @@ public class DefaultMavenProjectBuilder
// getLogger().debug( "Caching project: " + project.getId() + " (also keyed by file: " + project.getFile() + ")" );
projectWorkspace.storeProjectByCoordinate( project );
projectWorkspace.storeProjectByFile( project );
@ -1791,7 +1775,7 @@ public class DefaultMavenProjectBuilder
}
}
private Model readModel( String projectId,
private Model readModelLegacy( String projectId,
File file,
boolean strict )
throws ProjectBuildingException
@ -2085,4 +2069,31 @@ public class DefaultMavenProjectBuilder
{
this.logger = logger;
}
private Model readModelFromLocalPath( String projectId,
File projectDescriptor,
PomArtifactResolver resolver )
throws ProjectBuildingException
{
if(projectDescriptor == null) {
throw new IllegalArgumentException("projectDescriptor: null, Project Id =" + projectId);
}
if(projectBuilder == null) {
throw new IllegalArgumentException("projectBuilder: not initialized");
}
MavenProject mavenProject;
try {
mavenProject = projectBuilder.buildFromLocalPath(new FileInputStream(projectDescriptor),
null, null, resolver,
projectDescriptor.getParentFile());
} catch (IOException e) {
e.printStackTrace();
throw new ProjectBuildingException(projectId, "File = " + projectDescriptor.getAbsolutePath() , e);
}
return mavenProject.getModel();
}
}

View File

@ -0,0 +1,186 @@
package org.apache.maven.project.builder;
/*
* 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 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.Build.PluginManagement.Plugins.Plugin.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.xUri,
ProjectUri.Build.Plugins.Plugin.xUri, ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.xUri,
ProjectUri.Build.Plugins.Plugin.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 ArtifactModelContainer( modelProperties );
}
private static class ArtifactModelContainer
implements ModelContainer
{
private String groupId;
private String artifactId;
private String version;
private String type;
private List<ModelProperty> properties;
private ArtifactModelContainer( List<ModelProperty> properties )
{
this.properties = new ArrayList<ModelProperty>( properties );
this.properties = Collections.unmodifiableList( this.properties );
for ( ModelProperty mp : properties )
{
if ( mp.getUri().endsWith( "version" ) )
{
this.version = mp.getValue();
}
else if ( mp.getUri().endsWith( "artifactId" ) )
{
this.artifactId = mp.getValue();
}
else if ( mp.getUri().endsWith( "groupId" ) )
{
this.groupId = mp.getValue();
}
else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.type ) )
{
this.type = mp.getValue();
}
}
if ( groupId == null )
{
groupId = "org.apache.maven.plugins";
// throw new IllegalArgumentException("properties does not contain group id. Artifact ID = "
// + artifactId + ", Version = " + version);
}
if ( artifactId == null )
{
throw new IllegalArgumentException(
"Properties does not contain artifact id. Group ID = " + groupId + ", Version = " + version );
}
if ( type == null )
{
type = "";
}
}
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 ) )
{
if ( c.version == null )
{
if ( version == null )
{
return ModelContainerAction.JOIN;
}
return ModelContainerAction.DELETE;//TODO Verify - PluginManagement Section may make versions equal
}
if ( c.version.equals( version ) )
{
if ( c.type.equals( type ) )
{
return ModelContainerAction.JOIN;
}
else
{
return ModelContainerAction.NOP;
}
}
else
{
return ModelContainerAction.DELETE;
}
}
else
{
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();
}
}
}

View File

@ -0,0 +1,113 @@
package org.apache.maven.project.builder;
/*
* 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 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 static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
ProjectUri.PluginRepositories.PluginRepository.xUri, ProjectUri.Repositories.Repository.xUri,
ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri, ProjectUri.Profiles.Profile.xUri,
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 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.getValue();
}
}
}
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;
}
}
}

View File

@ -0,0 +1,93 @@
package org.apache.maven.project.builder;
/*
* 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.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* Provides methods for resolving of artifacts.
*/
public class PomArtifactResolver
{
/**
* Local repository used in resolving artifacts
*/
private ArtifactRepository localRepository;
/**
* Remote repositories used in resolving artifacts
*/
private List<ArtifactRepository> remoteRepositories;
/**
* Artifact resolver used to resolve artifacts
*/
private ArtifactResolver resolver;
/**
* Constructor
*
* @param localRepository local repository used in resolving artifacts
* @param remoteRepositories remote repositories used in resolving artifacts
* @param resolver artifact resolver used to resolve artifacts
*/
public PomArtifactResolver( ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
ArtifactResolver resolver )
{
this.localRepository = localRepository;
this.remoteRepositories = remoteRepositories;
this.resolver = resolver;
}
/**
* Resolves the specified artifact
*
* @param artifact the artifact to resolve
* @throws IOException if there is a problem resolving the artifact
*/
public void resolve( Artifact artifact )
throws IOException
{
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
artifact.setFile( artifactFile );
try
{
resolver.resolve( artifact, remoteRepositories, localRepository );
}
catch ( ArtifactResolutionException e )
{
throw new IOException( e.getMessage() );
}
catch ( ArtifactNotFoundException e )
{
throw new IOException( e.getMessage() );
}
}
}

View File

@ -0,0 +1,245 @@
package org.apache.maven.project.builder;
/*
* 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.Parent;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.shared.model.InputStreamDomainModel;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
/**
* Provides a wrapper for the maven model.
*/
public final class PomClassicDomainModel
implements InputStreamDomainModel
{
/**
* Bytes containing the underlying model
*/
private byte[] inputBytes;
/**
* History of joins and deletes of model properties
*/
private String eventHistory;
/**
* Maven model
*/
private Model model;
private String id;
/**
* Constructor
*
* @param model maven model
* @throws IOException if there is a problem constructing the model
*/
public PomClassicDomainModel( Model model )
throws IOException
{
if ( model == null )
{
throw new IllegalArgumentException( "model: null" );
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer out = WriterFactory.newXmlWriter( baos );
MavenXpp3Writer writer = new MavenXpp3Writer();
writer.write( out, model );
out.close();
inputBytes = baos.toByteArray();
}
/**
* 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 );
}
/**
* Returns true if groupId.equals(a.groupId) && artifactId.equals(a.artifactId) && version.equals(a.version),
* otherwise returns false.
*
* @param a model to compare
* @return true if groupId.equals(a.groupId) && artifactId.equals(a.artifactId) && version.equals(a.version),
* otherwise returns false.
*/
public boolean matchesModel( Model a )
{
if ( a == null )
{
throw new IllegalArgumentException( "a: null" );
}
if ( model == null )
{
try
{
model = getModel();
}
catch ( IOException e )
{
return false;
}
}
return a.getId().equals( this.getId() );
}
public String getId()
{
if ( id == null )
{
if ( model == null )
{
try
{
model = getModel();
}
catch ( IOException e )
{
return "";
}
}
String groupId = ( model.getGroupId() == null ) ? model.getParent().getGroupId() : model.getGroupId();
String artifactId =
( model.getArtifactId() == null ) ? model.getParent().getArtifactId() : model.getArtifactId();
String version = ( model.getVersion() == null ) ? model.getParent().getVersion() : model.getVersion();
id = groupId + ":" + artifactId + ":" + version;
}
return id;
}
public boolean matchesParent( Parent parent )
{
if ( parent == null )
{
throw new IllegalArgumentException( "parent: null" );
}
return getId().equals( parent.getGroupId() + ":" + parent.getArtifactId() + ":" + parent.getVersion() );
}
/**
* 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 "";
}
}
/**
* Returns maven model
*
* @return maven model
*/
public Model getModel()
throws IOException
{
if ( model != null )
{
return model;
}
try
{
return new MavenXpp3Reader().read( ReaderFactory.newXmlReader( new ByteArrayInputStream( inputBytes ) ) );
}
catch ( XmlPullParserException e )
{
e.printStackTrace();
throw new IOException( e.getMessage() );
}
}
/**
* @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 );
return new ByteArrayInputStream( copy );
}
/**
* @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;
}
/**
* 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 )
{
return o instanceof PomClassicDomainModel && getId().equals( ( (PomClassicDomainModel) o ).getId() );
}
}

View File

@ -0,0 +1,418 @@
package org.apache.maven.project.builder;
/*
* 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.io.xpp3.MavenXpp3Reader;
import org.apache.maven.shared.model.DomainModel;
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.ModelTransformer;
import org.apache.maven.shared.model.impl.DefaultModelDataSource;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
/**
* Provides methods for transforming model properties into a domain model for the pom classic format and vice versa.
*/
public final class PomClassicTransformer
implements ModelTransformer
{
/**
* The URIs this tranformer supports
*/
private final Set<String> uris;
private static Map<String, List<ModelProperty>> cache = new HashMap<String, List<ModelProperty>>();
//private static List<DomainModel> cache = new ArrayList<DomainModel>();
/**
* Default constructor
*/
public PomClassicTransformer()
{
this.uris = new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri,
ProjectUri.Build.PluginManagement.Plugins.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
ProjectUri.Build.Plugins.xUri,
ProjectUri.Build.Plugins.Plugin.configuration,
ProjectUri.Build.Plugins.Plugin.Dependencies.xUri,
ProjectUri.Build.Plugins.Plugin.Executions.xUri,
ProjectUri.Build.Resources.xUri,
ProjectUri.Build.Resources.Resource.includes,
ProjectUri.Build.Resources.Resource.excludes,
ProjectUri.Build.TestResources.xUri,
ProjectUri.CiManagement.Notifiers.xUri,
ProjectUri.Contributors.xUri,
ProjectUri.Dependencies.xUri,
ProjectUri.Dependencies.Dependency.Exclusions.xUri,
ProjectUri.DependencyManagement.Dependencies.xUri,
ProjectUri.DependencyManagement.Dependencies.Dependency.Exclusions.xUri,
ProjectUri.Developers.xUri,
ProjectUri.Developers.Developer.roles, ProjectUri.Licenses.xUri,
ProjectUri.MailingLists.xUri, ProjectUri.Modules.xUri,
ProjectUri.PluginRepositories.xUri,
ProjectUri.Profiles.xUri,
ProjectUri.Profiles.Profile.Build.Plugins.xUri,
ProjectUri.Profiles.Profile.Build.Plugins.Plugin.Dependencies.xUri,
ProjectUri.Profiles.Profile.Build.Resources.xUri,
ProjectUri.Profiles.Profile.Build.TestResources.xUri,
ProjectUri.Profiles.Profile.Dependencies.xUri,
ProjectUri.Profiles.Profile.Dependencies.Dependency.Exclusions.xUri,
ProjectUri.Profiles.Profile.DependencyManagement.Dependencies.xUri,
ProjectUri.Profiles.Profile.PluginRepositories.xUri,
ProjectUri.Profiles.Profile.Reporting.Plugins.xUri,
ProjectUri.Profiles.Profile.Repositories.xUri,
ProjectUri.Reporting.Plugins.xUri,
ProjectUri.Reporting.Plugins.Plugin.ReportSets.xUri,
ProjectUri.Repositories.xUri,
"http://apache.org/maven/project/profiles/profile/build/pluginManagement/plugins/plugin/dependencies#collection",
"http://apache.org/maven/project/profiles/profile/build/pluginManagement/plugins/plugin/dependencies/dependency/exclusions#collection",
"http://apache.org/maven/project/profiles/profile/build/pluginManagement/plugins/plugin/executions#collection",
"http://apache.org/maven/project/profiles/profile/build/pluginManagement/plugins#collection",
"http://apache.org/maven/project/profiles/profile/build/plugins/plugin/dependencies/dependency/exclusions#collection",
"http://apache.org/maven/project/profiles/profile/dependencyManagement/dependencies/dependency/exclusions#collection",
"http://apache.org/maven/project/profiles/profile/reporting/plugins/plugin/reportSets#collection",
"http://apache.org/maven/project/profiles/profile/build/plugins/plugin/executions#collection" ) );
}
/**
* @see ModelTransformer#transformToDomainModel(java.util.List)
*/
public DomainModel transformToDomainModel( List<ModelProperty> properties )
throws IOException
{
if ( properties == null )
{
throw new IllegalArgumentException( "properties: null" );
}
List<ModelProperty> props = new ArrayList<ModelProperty>();
for ( ModelProperty mp : properties )
{ //TODO: Resolved values
if ( mp.getValue() != null && ( mp.getValue().contains( "=" ) || mp.getValue().contains( "<" ) ) )
{
props.add( new ModelProperty( mp.getUri(), "<![CDATA[" + mp.getValue() + "]]>" ) );
}
else
{
props.add( mp );
}
}
String xml = null;
try
{
xml = ModelMarshaller.unmarshalModelPropertiesToXml( props, ProjectUri.baseUri );
return new PomClassicDomainModel( new MavenXpp3Reader().read( new StringReader( xml ) ) );
}
catch ( XmlPullParserException e )
{
throw new IOException( e + ":\r\n" + xml );
}
}
/**
* @see ModelTransformer#transformToModelProperties(java.util.List)
*/
public List<ModelProperty> transformToModelProperties( List<DomainModel> domainModels )
throws IOException
{
if ( domainModels == null || domainModels.isEmpty() )
{
throw new IllegalArgumentException( "domainModels: null or empty" );
}
List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
List<String> projectNames = new ArrayList<String>();
StringBuffer scmUrl = new StringBuffer();
StringBuffer scmConnectionUrl = new StringBuffer();
StringBuffer scmDeveloperUrl = new StringBuffer();
for ( DomainModel domainModel : domainModels )
{
if ( !( domainModel instanceof PomClassicDomainModel ) )
{
throw new IllegalArgumentException( "domainModels: Invalid domain model" );
}
PomClassicDomainModel pomDomainModel = (PomClassicDomainModel) domainModel;
if ( cache.containsKey( pomDomainModel.getId() ) )
{
System.out.println( "Found in cache: ID = " + pomDomainModel.getId() );
modelProperties.addAll( cache.get( pomDomainModel.getId() ) );
continue;
}
List<ModelProperty> tmp = ModelMarshaller.marshallXmlToModelProperties(
( (PomClassicDomainModel) domainModel ).getInputStream(), ProjectUri.baseUri, uris );
List clearedProperties = new ArrayList<ModelProperty>();
//Missing Version Rule
if ( getPropertyFor( ProjectUri.version, tmp ) == null )
{
ModelProperty parentVersion = getPropertyFor( ProjectUri.Parent.version, tmp );
if ( parentVersion != null )
{
tmp.add( new ModelProperty( ProjectUri.version, parentVersion.getValue() ) );
}
}
//Modules Not Inherited Rule
if ( domainModels.indexOf( domainModel ) != 0 )
{
ModelProperty modulesProperty = getPropertyFor( ProjectUri.Modules.xUri, tmp );
if ( modulesProperty != null )
{
tmp.remove( modulesProperty );
tmp.removeAll( getPropertiesFor( ProjectUri.Modules.module, tmp ) );
}
}
//Missing groupId, use parent one Rule
if ( getPropertyFor( ProjectUri.groupId, tmp ) == null )
{
ModelProperty parentGroupId = getPropertyFor( ProjectUri.Parent.groupId, tmp );
if ( parentGroupId != null )
{
tmp.add( new ModelProperty( ProjectUri.groupId, parentGroupId.getValue() ) );
}
}
//Not inherited plugin execution rule
if ( domainModels.indexOf( domainModel ) > 0 )
{
List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
ModelDataSource source = new DefaultModelDataSource();
source.init( tmp, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
List<ModelContainer> containers =
source.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
for ( ModelContainer container : containers )
{
for ( ModelProperty mp : container.getProperties() )
{
if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.Execution.inherited ) &&
mp.getValue() != null && mp.getValue().equals( "false" ) )
{
removeProperties.addAll( container.getProperties() );
for ( int j = tmp.indexOf( mp ); j >= 0; j-- )
{
if ( tmp.get( j ).getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.xUri ) )
{
removeProperties.add( tmp.get( j ) );
break;
}
}
break;
}
}
}
tmp.removeAll( removeProperties );
}
//Not inherited plugin rule
if ( domainModels.indexOf( domainModel ) > 0 )
{
List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
ModelDataSource source = new DefaultModelDataSource();
source.init( tmp, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
List<ModelContainer> containers = source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri );
for ( ModelContainer container : containers )
{
for ( ModelProperty mp : container.getProperties() )
{
if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.inherited ) && mp.getValue() != null &&
mp.getValue().equals( "false" ) )
{
removeProperties.addAll( container.getProperties() );
for ( int j = tmp.indexOf( mp ); j >= 0; j-- )
{
if ( tmp.get( j ).getUri().equals( ProjectUri.Build.Plugins.Plugin.xUri ) )
{
removeProperties.add( tmp.get( j ) );
break;
}
}
break;
}
}
}
tmp.removeAll( removeProperties );
}
//SCM Rule
ModelProperty scmUrlProperty = getPropertyFor( ProjectUri.Scm.url, tmp );
if ( scmUrl.length() == 0 && scmUrlProperty != null )
{
scmUrl.append( scmUrlProperty.getValue() );
for ( String projectName : projectNames )
{
scmUrl.append( "/" ).append( projectName );
}
int index = tmp.indexOf( scmUrlProperty );
tmp.remove( index );
tmp.add( index, new ModelProperty( ProjectUri.Scm.url, scmUrl.toString() ) );
}
//SCM Connection Rule
scmUrlProperty = getPropertyFor( ProjectUri.Scm.connection, tmp );
if ( scmConnectionUrl.length() == 0 && scmUrlProperty != null )
{
scmConnectionUrl.append( scmUrlProperty.getValue() );
for ( String projectName : projectNames )
{
scmConnectionUrl.append( "/" ).append( projectName );
}
int index = tmp.indexOf( scmUrlProperty );
tmp.remove( index );
tmp.add( index, new ModelProperty( ProjectUri.Scm.connection, scmConnectionUrl.toString() ) );
}
//SCM Developer Rule
scmUrlProperty = getPropertyFor( ProjectUri.Scm.developerConnection, tmp );
if ( scmDeveloperUrl.length() == 0 && scmUrlProperty != null )
{
scmDeveloperUrl.append( scmUrlProperty.getValue() );
for ( String projectName : projectNames )
{
scmDeveloperUrl.append( "/" ).append( projectName );
}
int index = tmp.indexOf( scmUrlProperty );
tmp.remove( index );
tmp.add( index, new ModelProperty( ProjectUri.Scm.developerConnection, scmDeveloperUrl.toString() ) );
}
//Remove Plugin Repository Inheritance Rule
//Project Name Inheritance Rule
//Packaging Inheritance Rule
//Build Resources Inheritence Rule
//Build Test Resources Inheritance Rule
//Profiles not inherited rule
for ( ModelProperty mp : tmp )
{
String uri = mp.getUri();
if ( domainModels.indexOf( domainModel ) > 0 && ( uri.equals( ProjectUri.name ) ||
uri.equals( ProjectUri.packaging ) || uri.startsWith( ProjectUri.Profiles.xUri ) ||
uri.startsWith( ProjectUri.Build.Resources.xUri ) ||
uri.startsWith( ProjectUri.Build.TestResources.xUri ) ||
uri.startsWith( ProjectUri.PluginRepositories.xUri ) ) )
{
clearedProperties.add( mp );
}
}
ModelProperty artifactId = getPropertyFor( ProjectUri.artifactId, tmp );
if ( artifactId != null )
{
projectNames.add( 0, artifactId.getValue() );
}
tmp.removeAll( clearedProperties );
modelProperties.addAll( tmp );
if ( domainModels.indexOf( domainModel ) > 0 )
{
//cache.put( pomDomainModel.getId(), modelProperties );
}
//Remove Parent Info
/*
for (ModelProperty mp : tmp) {
if (mp.getUri().startsWith(ProjectUri.Parent.xUri)) {
modelProperties.remove(mp);
}
}
*/
}
return modelProperties;
}
/**
* Returns the base uri of all model properties: http://apache.org/maven/project/
*
* @return Returns the base uri of all model properties: http://apache.org/maven/project/
*/
public String getBaseUri()
{
return ProjectUri.baseUri;
}
/**
* Returns all model properties containing the specified uri from the specified properties list.
*
* @param uri the uri to use in finding the returned model properties
* @param properties the model properties list to search
* @return all model properties containing the specified uri from the specified properties list
*/
private static List<ModelProperty> getPropertiesFor( String uri, List<ModelProperty> properties )
{
List<ModelProperty> modelProperties = new ArrayList<ModelProperty>();
for ( ModelProperty mp : properties )
{
if ( uri.equals( mp.getUri() ) )
{
modelProperties.add( mp );
}
}
return modelProperties;
}
/**
* Returns the first model property containing the specified uri from the specified properties list.
*
* @param uri the uri to use in finding the returned model property
* @param properties the model properties list to search
* @return the first model property containing the specified uri from the specified properties list.
*/
private static ModelProperty getPropertyFor( String uri, List<ModelProperty> properties )
{
for ( ModelProperty mp : properties )
{
if ( uri.equals( mp.getUri() ) )
{
return mp;
}
}
return null;
}
}

View File

@ -0,0 +1,56 @@
package org.apache.maven.project.builder;
/*
* 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.project.MavenProject;
import org.apache.maven.shared.model.InterpolatorProperty;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.List;
/**
* Provides services for building maven projects from models.
*/
public interface ProjectBuilder
{
String ROLE = ProjectBuilder.class.getName();
/**
* Returns a maven project for the specified input stream.
*
* @param pom input stream of the model
* @param inheritedModels list of models containing additional parent models in order from most to least specialized
* @param interpolatorProperties properties used for interpolation of properties within the model
* @param resolver artifact resolver used in resolving artifacts
* @param baseDirectory the base directory of the model
* @return a maven project for the specified input stream
* @throws IOException if there is a problem in the construction of the maven project
*/
MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedModels,
Collection<InterpolatorProperty> interpolatorProperties,
PomArtifactResolver resolver, File baseDirectory )
throws IOException;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,295 @@
package org.apache.maven.project.builder.impl;
/*
* 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.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.builder.ArtifactModelContainerFactory;
import org.apache.maven.project.builder.IdModelContainerFactory;
import org.apache.maven.project.builder.PomArtifactResolver;
import org.apache.maven.project.builder.PomClassicDomainModel;
import org.apache.maven.project.builder.PomClassicTransformer;
import org.apache.maven.project.builder.ProjectBuilder;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
import org.apache.maven.shared.model.DomainModel;
import org.apache.maven.shared.model.InterpolatorProperty;
import org.apache.maven.shared.model.ModelTransformerContext;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Default implementation of the project builder.
*/
public final class DefaultProjectBuilder
implements ProjectBuilder, LogEnabled
{
private ArtifactFactory artifactFactory;
/**
* Logger instance
*/
private Logger logger;
private ModelValidator validator;
/**
* Default constructor
*/
public DefaultProjectBuilder()
{
}
/**
* Constructor
*
* @param artifactFactory the artifact factory
*/
protected DefaultProjectBuilder( ArtifactFactory artifactFactory )
{
if ( artifactFactory == null )
{
throw new IllegalArgumentException( "artifactFactory: null" );
}
this.artifactFactory = artifactFactory;
}
/**
* @see ProjectBuilder#buildFromLocalPath(java.io.InputStream, java.util.List, java.util.Collection, org.apache.maven.project.builder.PomArtifactResolver, java.io.File)
*/
public MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedModels,
Collection<InterpolatorProperty> interpolatorProperties,
PomArtifactResolver resolver, File projectDirectory )
throws IOException
{
if ( pom == null )
{
throw new IllegalArgumentException( "pom: null" );
}
if ( resolver == null )
{
throw new IllegalArgumentException( "resolver: null" );
}
if ( projectDirectory == null )
{
throw new IllegalArgumentException( "projectDirectory: null" );
}
if ( inheritedModels == null )
{
inheritedModels = new ArrayList<Model>();
}
else
{
inheritedModels = new ArrayList<Model>( inheritedModels );
Collections.reverse( inheritedModels );
}
List<InterpolatorProperty> properties;
if ( interpolatorProperties == null )
{
properties = new ArrayList<InterpolatorProperty>();
}
else
{
properties = new ArrayList<InterpolatorProperty>( interpolatorProperties );
}
PomClassicDomainModel domainModel = new PomClassicDomainModel( pom );
List<DomainModel> domainModels = new ArrayList<DomainModel>();
domainModels.add( domainModel );
if ( domainModel.getModel().getParent() != null )
{
if ( isParentLocal( domainModel.getModel().getParent(), projectDirectory ) )
{
domainModels.addAll( getDomainModelParentsFromLocalPath( domainModel, resolver, projectDirectory ) );
}
else
{
domainModels.addAll( getDomainModelParentsFromRepository( domainModel, resolver ) );
}
}
for ( Model model : inheritedModels )
{
domainModels.add( new PomClassicDomainModel( model ) );
}
PomClassicTransformer transformer = new PomClassicTransformer();
ModelTransformerContext ctx = new ModelTransformerContext(
Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
PomClassicDomainModel transformedDomainModel =
( (PomClassicDomainModel) ctx.transform( domainModels, transformer, transformer, properties ) );
Model model = transformedDomainModel.getModel();
return new MavenProject( model );
}
private boolean isParentLocal( Parent parent, File projectDirectory )
{
try
{
File f = new File( projectDirectory, parent.getRelativePath() ).getCanonicalFile();
if ( f.isDirectory() )
{
f = new File( f, "pom.xml" );
}
return f.exists();
}
catch ( IOException e )
{
e.printStackTrace();
return false;
}
}
private List<DomainModel> getDomainModelParentsFromRepository( PomClassicDomainModel domainModel,
PomArtifactResolver artifactResolver )
throws IOException
{
if ( artifactFactory == null )
{
throw new IllegalArgumentException( "artifactFactory: not initialized" );
}
List<DomainModel> domainModels = new ArrayList<DomainModel>();
Parent parent = domainModel.getModel().getParent();
if ( parent == null )
{
return domainModels;
}
Artifact artifactParent =
artifactFactory.createParentArtifact( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
artifactResolver.resolve( artifactParent );
PomClassicDomainModel parentDomainModel =
new PomClassicDomainModel( new FileInputStream( artifactParent.getFile() ) );
if ( !parentDomainModel.matchesParent( domainModel.getModel().getParent() ) )
{
logger.warn( "Parent pom ids do not match: File = " + artifactParent.getFile().getAbsolutePath() );
return domainModels;
}
else
{
// logger.info("Adding pom to hierarchy: Group Id = " + parent.getGroupId() + ", Artifact Id ="
// + parent.getArtifactId() + ", Version = " + parent.getVersion() + ", File" + artifactParent.getFile());
}
domainModels.add( parentDomainModel );
domainModels.addAll( getDomainModelParentsFromRepository( parentDomainModel, artifactResolver ) );
return domainModels;
}
private List<DomainModel> getDomainModelParentsFromLocalPath( PomClassicDomainModel domainModel,
PomArtifactResolver artifactResolver,
File projectDirectory )
throws IOException
{
if ( artifactFactory == null )
{
throw new IllegalArgumentException( "artifactFactory: not initialized" );
}
List<DomainModel> domainModels = new ArrayList<DomainModel>();
Parent parent = domainModel.getModel().getParent();
if ( parent == null )
{
return domainModels;
}
Model model = domainModel.getModel();
File parentFile = new File( projectDirectory, model.getParent().getRelativePath() ).getCanonicalFile();
if ( parentFile.isDirectory() )
{
parentFile = new File( parentFile.getAbsolutePath(), "pom.xml" );
}
if ( !parentFile.exists() )
{
throw new IOException( "File does not exist: File =" + parentFile.getAbsolutePath() );
}
PomClassicDomainModel parentDomainModel = new PomClassicDomainModel( new FileInputStream( parentFile ) );
if ( !parentDomainModel.matchesParent( domainModel.getModel().getParent() ) )
{
logger.warn( "Parent pom ids do not match: File = " + parentFile.getAbsolutePath() );
}
domainModels.add( parentDomainModel );
if ( parentDomainModel.getModel().getParent() != null )
{
if ( isParentLocal( parentDomainModel.getModel().getParent(), parentFile.getParentFile() ) )
{
domainModels.addAll( getDomainModelParentsFromLocalPath( parentDomainModel, artifactResolver,
parentFile.getParentFile() ) );
}
else
{
domainModels.addAll( getDomainModelParentsFromRepository( parentDomainModel, artifactResolver ) );
}
}
return domainModels;
}
public void enableLogging( Logger logger )
{
this.logger = logger;
}
private void validateModel( Model model )
throws IOException
{
ModelValidationResult validationResult = validator.validate( model );
if ( validationResult.getMessageCount() > 0 )
{
throw new IOException( "Failed to validate: " + validationResult.toString() );
}
}
}

View File

@ -110,11 +110,24 @@ under the License.
|
|
-->
<component>
<role>org.apache.maven.project.builder.ProjectBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.builder.impl.DefaultProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.MavenProjectBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.project.builder.ProjectBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.project.workspace.ProjectWorkspace</role>
</requirement>

View File

@ -53,6 +53,6 @@ public abstract class AbstractProjectInheritanceTestCase
protected File getLocalRepositoryPath()
{
return getTestFile( "src/test/resources/inheritance-repo/" + getTestSeries() );
return getTestFile("src/test/resources/inheritance-repo/" + getTestSeries() );
}
}

View File

@ -69,12 +69,12 @@ public class ProjectInheritanceTest
System.out.println( "Child SCM developer connection is: "
+ project1.getScm().getDeveloperConnection() );
assertEquals( project1.getScm().getUrl(), project0.getScm().getUrl() + "/modules/p1" );
assertEquals( project1.getScm().getUrl(), project0.getScm().getUrl() + "/p1" );
assertEquals( project1.getScm().getConnection(), project0.getScm().getConnection()
+ "/modules/p1" );
+ "/p1" );
assertEquals( project1.getScm().getDeveloperConnection(), project0.getScm()
.getDeveloperConnection()
+ "/modules/p1" );
+ "/p1" );
}
public void testScmInfoCalculatedCorrectlyOnChildOnlyRead()
@ -93,10 +93,10 @@ public class ProjectInheritanceTest
System.out.println( "Child SCM developer connection is: "
+ project1.getScm().getDeveloperConnection() );
assertEquals( project1.getScm().getUrl(), "http://host/viewer?path=/p0/modules/p1" );
assertEquals( project1.getScm().getConnection(), "scm:svn:http://host/p0/modules/p1" );
assertEquals( project1.getScm().getUrl(), "http://host/viewer?path=/p0/p1" );
assertEquals( project1.getScm().getConnection(), "scm:svn:http://host/p0/p1" );
assertEquals( project1.getScm().getDeveloperConnection(),
"scm:svn:https://host/p0/modules/p1" );
"scm:svn:https://host/p0/p1" );
}
// public void testScmInfoCalculatedCorrectlyOnChildReadFromLocalRepository()

View File

@ -75,11 +75,24 @@ under the License.
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.builder.ProjectBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.builder.impl.DefaultProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.MavenProjectBuilder</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.TestProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.project.builder.ProjectBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.project.workspace.ProjectWorkspace</role>
</requirement>

View File

@ -73,11 +73,24 @@ under the License.
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.builder.ProjectBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.builder.impl.DefaultProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.MavenProjectBuilder</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.TestProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.project.builder.ProjectBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.project.workspace.ProjectWorkspace</role>
</requirement>

53
pom.xml
View File

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven</groupId>
@ -32,14 +32,15 @@
publication, and distribution publication are all controlled from
the declarative file. Maven can be extended by plugins to utilise a
number of other development tools for reporting or the build
process. </description>
process.
</description>
<url>http://maven.apache.org/</url>
<inceptionYear>2001</inceptionYear>
<issueManagement>
<system>jira</system>
<url>http://jira.codehaus.org/browse/MNG</url>
</issueManagement>
<!-- TODO: TAKE THIS OUT BEFORE WE RELEASE! -->
<repositories>
<repository>
@ -271,8 +272,10 @@
<plexusInterpolationVersion>1.1</plexusInterpolationVersion>
<plexusUtilsVersion>1.5.5</plexusUtilsVersion>
<wagonVersion>1.0-beta-3</wagonVersion>
<mavenSharedModel>1.0-SNAPSHOT</mavenSharedModel>
<woodstoxVersion>3.2.6</woodstoxVersion>
</properties>
<!--start-->
<dependencies>
<dependency>
@ -367,7 +370,7 @@
<artifactId>plexus-component-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<!-- Wagon -->
<dependency>
<groupId>org.apache.maven.wagon</groupId>
@ -404,6 +407,16 @@
<artifactId>doxia-sink-api</artifactId>
<version>${doxiaVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-model</artifactId>
<version>${mavenSharedModel}</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
<version>${woodstoxVersion}</version>
</dependency>
<dependency>
<groupId>easymock</groupId>
<artifactId>easymock</artifactId>
@ -424,7 +437,7 @@
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<!-- Needed for backward compat aspect. -->
<dependency>
<groupId>aspectj</groupId>