mirror of https://github.com/apache/maven.git
Merge of sisbell-maven-2.1-profile branch. Removes use of project lineage from builder.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@693332 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5fc59a2bd9
commit
6b96692a93
|
@ -38,7 +38,7 @@ under the License.
|
|||
<dependency>
|
||||
<groupId>org.apache.maven.its</groupId>
|
||||
<artifactId>core-integration-tests</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.apache.maven;
|
||||
|
||||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.project.ProjectSorter;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -9,7 +8,7 @@
|
|||
/**
|
||||
* Exception which occurs when creating a new {@link ReactorManager} instance,
|
||||
* due to failure to sort the current projects. The embedded {@link CycleDetectedException}
|
||||
* is thrown by the {@link ProjectSorter}, and context of this wrapped exception
|
||||
* is thrown by the ProjectSorter and context of this wrapped exception
|
||||
* includes the list of projects that contain the cycle, along with a friendly
|
||||
* rendering of the cycle message indicating that it comes from the current projects list.
|
||||
*
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.error.ProjectErrorReporter;
|
||||
import org.apache.maven.errors.ProjectErrorReporter;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.reactor.MavenExecutionException;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.apache.maven.errors;
|
||||
|
||||
import org.apache.maven.project.error.ProjectReporterManager;
|
||||
import org.apache.maven.errors.ProjectReporterManager;
|
||||
|
||||
public final class CoreReporterManager
|
||||
{
|
||||
|
|
|
@ -41,9 +41,9 @@
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.error.DefaultProjectErrorReporter;
|
||||
import org.apache.maven.project.error.ProjectErrorReporter;
|
||||
import org.apache.maven.project.error.ProjectReporterManager;
|
||||
import org.apache.maven.errors.DefaultProjectErrorReporter;
|
||||
import org.apache.maven.errors.ProjectErrorReporter;
|
||||
import org.apache.maven.errors.ProjectReporterManager;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.reactor.MavenExecutionException;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.error;
|
||||
package org.apache.maven.errors;
|
||||
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
@ -20,7 +20,7 @@
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.build.model.ModelAndFile;
|
||||
import org.apache.maven.project.ModelAndFile;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
@ -62,7 +62,7 @@ public DefaultProjectErrorReporter()
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#clearErrors()
|
||||
* @see ProjectErrorReporter#clearErrors()
|
||||
*/
|
||||
public void clearErrors()
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ public List getReportedExceptions()
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#hasInformationFor(java.lang.Throwable)
|
||||
* @see ProjectErrorReporter#hasInformationFor(java.lang.Throwable)
|
||||
*/
|
||||
public Throwable findReportedException( Throwable error )
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ else if ( error.getCause() != null )
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#getFormattedMessage(java.lang.Throwable)
|
||||
* @see ProjectErrorReporter#getFormattedMessage(java.lang.Throwable)
|
||||
*/
|
||||
public String getFormattedMessage( Throwable error )
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ public String getFormattedMessage( Throwable error )
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#getRealCause(java.lang.Throwable)
|
||||
* @see ProjectErrorReporter#getRealCause(java.lang.Throwable)
|
||||
*/
|
||||
public Throwable getRealCause( Throwable error )
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ protected void registerBuildError( Throwable error,
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorErrorWhileApplyingProfiles(org.apache.maven.profiles.activation.ProfileActivator, org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException)
|
||||
* @see ProjectErrorReporter#reportActivatorErrorWhileApplyingProfiles(org.apache.maven.profiles.activation.ProfileActivator, org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException)
|
||||
*/
|
||||
public void reportActivatorError( ProfileActivator activator,
|
||||
Model model,
|
||||
|
@ -179,7 +179,7 @@ public void reportActivatorError( ProfileActivator activator,
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupError(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
|
||||
* @see ProjectErrorReporter#reportActivatorLookupError(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
|
||||
*/
|
||||
public void reportActivatorLookupError( Model model,
|
||||
File pomFile,
|
||||
|
@ -213,7 +213,7 @@ public void reportActivatorLookupError( Model model,
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#reportErrorLoadingExternalProfilesFromFile(org.apache.maven.model.Model, java.io.File, java.io.File, java.io.IOException)
|
||||
* @see ProjectErrorReporter#reportErrorLoadingExternalProfilesFromFile(org.apache.maven.model.Model, java.io.File, java.io.File, java.io.IOException)
|
||||
*/
|
||||
public void reportErrorLoadingExternalProfilesFromFile( Model model,
|
||||
File pomFile,
|
||||
|
@ -242,7 +242,7 @@ public void reportErrorLoadingExternalProfilesFromFile( Model model,
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#reportErrorLoadingExternalProfilesFromFile(org.apache.maven.model.Model, java.io.File, java.io.File, org.codehaus.plexus.util.xml.pull.XmlPullParserException)
|
||||
* @see ProjectErrorReporter#reportErrorLoadingExternalProfilesFromFile(org.apache.maven.model.Model, java.io.File, java.io.File, org.codehaus.plexus.util.xml.pull.XmlPullParserException)
|
||||
*/
|
||||
public void reportErrorLoadingExternalProfilesFromFile( Model model,
|
||||
File pomFile,
|
||||
|
@ -278,7 +278,7 @@ public void reportErrorLoadingExternalProfilesFromFile( Model model,
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.error.ProjectErrorReporter#reportInvalidRepositoryWhileGettingRepositoriesFromProfiles(org.apache.maven.model.Repository, java.lang.String, java.io.File, org.apache.maven.artifact.InvalidRepositoryException)
|
||||
* @see ProjectErrorReporter#reportInvalidRepositoryWhileGettingRepositoriesFromProfiles(org.apache.maven.model.Repository, java.lang.String, java.io.File, org.apache.maven.artifact.InvalidRepositoryException)
|
||||
*/
|
||||
public void reportInvalidRepositoryWhileGettingRepositoriesFromProfiles( Repository repo,
|
||||
Model model,
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.error;
|
||||
package org.apache.maven.errors;
|
||||
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
|
@ -17,7 +17,7 @@
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.build.model.ModelAndFile;
|
||||
import org.apache.maven.project.ModelAndFile;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.error;
|
||||
package org.apache.maven.errors;
|
||||
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.model.Dependency;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.error;
|
||||
package org.apache.maven.errors;
|
||||
|
||||
public final class ProjectReporterManager
|
||||
{
|
|
@ -24,14 +24,15 @@
|
|||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.DuplicateProjectException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectSorter;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
import org.codehaus.plexus.util.dag.DAG;
|
||||
import org.codehaus.plexus.util.dag.TopologicalSorter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class ReactorManager
|
||||
{
|
||||
|
@ -188,4 +189,210 @@ public boolean executedMultipleProjects()
|
|||
{
|
||||
return buildFailuresByProject.size() + buildSuccessesByProject.size() > 1;
|
||||
}
|
||||
|
||||
protected static class ProjectSorter
|
||||
{
|
||||
private final DAG dag;
|
||||
|
||||
private final List sortedProjects;
|
||||
|
||||
private MavenProject topLevelProject;
|
||||
|
||||
/**
|
||||
* Sort a list of projects.
|
||||
* <ul>
|
||||
* <li>collect all the vertices for the projects that we want to build.</li>
|
||||
* <li>iterate through the deps of each project and if that dep is within
|
||||
* the set of projects we want to build then add an edge, otherwise throw
|
||||
* the edge away because that dependency is not within the set of projects
|
||||
* we are trying to build. we assume a closed set.</li>
|
||||
* <li>do a topo sort on the graph that remains.</li>
|
||||
* </ul>
|
||||
* @throws DuplicateProjectException if any projects are duplicated by id
|
||||
*/
|
||||
// MAVENAPI FIXME: the DAG used is NOT only used to represent the dependency relation,
|
||||
// but also for <parent>, <build><plugin>, <reports>. We need multiple DAG's
|
||||
// since a DAG can only handle 1 type of relationship properly.
|
||||
// Usecase: This is detected as a cycle:
|
||||
// org.apache.maven:maven-plugin-api -(PARENT)->
|
||||
// org.apache.maven:maven -(inherited REPORTING)->
|
||||
// org.apache.maven.plugins:maven-checkstyle-plugin -(DEPENDENCY)->
|
||||
// org.apache.maven:maven-plugin-api
|
||||
// In this case, both the verify and the report goals are called
|
||||
// in a different lifecycle. Though the compiler-plugin has a valid usecase, although
|
||||
// that seems to work fine. We need to take versions and lifecycle into account.
|
||||
public ProjectSorter( List projects )
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
{
|
||||
dag = new DAG();
|
||||
|
||||
Map projectMap = new HashMap();
|
||||
|
||||
for ( Iterator i = projects.iterator(); i.hasNext(); )
|
||||
{
|
||||
MavenProject project = (MavenProject) i.next();
|
||||
|
||||
String id = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
|
||||
|
||||
if ( dag.getVertex( id ) != null )
|
||||
{
|
||||
MavenProject conflictingProject = (MavenProject) projectMap.get( id );
|
||||
|
||||
throw new DuplicateProjectException( id,
|
||||
conflictingProject.getFile(),
|
||||
project.getFile(),
|
||||
"Project '"
|
||||
+ id
|
||||
+ "' is duplicated in the reactor" );
|
||||
}
|
||||
|
||||
dag.addVertex( id );
|
||||
|
||||
projectMap.put( id, project );
|
||||
}
|
||||
|
||||
for ( Iterator i = projects.iterator(); i.hasNext(); )
|
||||
{
|
||||
MavenProject project = (MavenProject) i.next();
|
||||
|
||||
String id = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
|
||||
|
||||
for ( Iterator j = project.getDependencies().iterator(); j.hasNext(); )
|
||||
{
|
||||
Dependency dependency = (Dependency) j.next();
|
||||
|
||||
String dependencyId = ArtifactUtils
|
||||
.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() );
|
||||
|
||||
if ( dag.getVertex( dependencyId ) != null )
|
||||
{
|
||||
project.addProjectReference( (MavenProject) projectMap.get( dependencyId ) );
|
||||
|
||||
dag.addEdge( id, dependencyId );
|
||||
}
|
||||
}
|
||||
|
||||
MavenProject parent = project.getParent();
|
||||
if ( parent != null )
|
||||
{
|
||||
String parentId = ArtifactUtils.versionlessKey( parent.getGroupId(), parent.getArtifactId() );
|
||||
if ( dag.getVertex( parentId ) != null )
|
||||
{
|
||||
// Parent is added as an edge, but must not cause a cycle - so we remove any other edges it has in conflict
|
||||
if ( dag.hasEdge( parentId, id ) )
|
||||
{
|
||||
dag.removeEdge( parentId, id );
|
||||
}
|
||||
dag.addEdge( id, parentId );
|
||||
}
|
||||
}
|
||||
|
||||
List buildPlugins = project.getBuildPlugins();
|
||||
if ( buildPlugins != null )
|
||||
{
|
||||
for ( Iterator j = buildPlugins.iterator(); j.hasNext(); )
|
||||
{
|
||||
Plugin plugin = (Plugin) j.next();
|
||||
String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() );
|
||||
if ( ( dag.getVertex( pluginId ) != null ) && !pluginId.equals( id ) )
|
||||
{
|
||||
addEdgeWithParentCheck( projectMap, pluginId, project, id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List reportPlugins = project.getReportPlugins();
|
||||
if ( reportPlugins != null )
|
||||
{
|
||||
for ( Iterator j = reportPlugins.iterator(); j.hasNext(); )
|
||||
{
|
||||
ReportPlugin plugin = (ReportPlugin) j.next();
|
||||
String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() );
|
||||
if ( ( dag.getVertex( pluginId ) != null ) && !pluginId.equals( id ) )
|
||||
{
|
||||
addEdgeWithParentCheck( projectMap, pluginId, project, id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( Iterator j = project.getBuildExtensions().iterator(); j.hasNext(); )
|
||||
{
|
||||
Extension extension = (Extension) j.next();
|
||||
String extensionId = ArtifactUtils.versionlessKey( extension.getGroupId(), extension.getArtifactId() );
|
||||
if ( dag.getVertex( extensionId ) != null )
|
||||
{
|
||||
addEdgeWithParentCheck( projectMap, extensionId, project, id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List sortedProjects = new ArrayList();
|
||||
|
||||
for ( Iterator i = TopologicalSorter.sort( dag ).iterator(); i.hasNext(); )
|
||||
{
|
||||
String id = (String) i.next();
|
||||
|
||||
sortedProjects.add( projectMap.get( id ) );
|
||||
}
|
||||
|
||||
this.sortedProjects = Collections.unmodifiableList( sortedProjects );
|
||||
}
|
||||
|
||||
private void addEdgeWithParentCheck( Map projectMap, String projectRefId, MavenProject project, String id )
|
||||
throws CycleDetectedException
|
||||
{
|
||||
MavenProject extProject = (MavenProject) projectMap.get( projectRefId );
|
||||
|
||||
if ( extProject == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
project.addProjectReference( extProject );
|
||||
|
||||
MavenProject extParent = extProject.getParent();
|
||||
if ( extParent != null )
|
||||
{
|
||||
String parentId = ArtifactUtils.versionlessKey( extParent.getGroupId(), extParent.getArtifactId() );
|
||||
// Don't add edge from parent to extension if a reverse edge already exists
|
||||
if ( !dag.hasEdge( projectRefId, id ) || !parentId.equals( id ) )
|
||||
{
|
||||
dag.addEdge( id, projectRefId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: !![jc; 28-jul-2005] check this; if we're using '-r' and there are aggregator tasks, this will result in weirdness.
|
||||
public MavenProject getTopLevelProject()
|
||||
{
|
||||
if ( topLevelProject == null )
|
||||
{
|
||||
for ( Iterator i = sortedProjects.iterator(); i.hasNext() && ( topLevelProject == null ); )
|
||||
{
|
||||
MavenProject project = (MavenProject) i.next();
|
||||
if ( project.isExecutionRoot() )
|
||||
{
|
||||
topLevelProject = project;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return topLevelProject;
|
||||
}
|
||||
|
||||
public List getSortedProjects()
|
||||
{
|
||||
return sortedProjects;
|
||||
}
|
||||
|
||||
public boolean hasMultipleProjects()
|
||||
{
|
||||
return sortedProjects.size() > 1;
|
||||
}
|
||||
|
||||
private List getDependents( String id )
|
||||
{
|
||||
return dag.getParentLabels( id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.build.model.ModelLineage;
|
||||
import org.apache.maven.project.build.model.ModelLineageBuilder;
|
||||
import org.apache.maven.project.build.model.ModelLineageIterator;
|
||||
import org.apache.maven.extension.lineage.ModelLineage;
|
||||
import org.apache.maven.extension.lineage.ModelLineageBuilder;
|
||||
import org.apache.maven.extension.lineage.ModelLineageIterator;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolator;
|
||||
import org.apache.maven.reactor.MissingModuleException;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
package org.apache.maven.extension.lineage;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -28,7 +28,7 @@
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineage
|
||||
* @see ModelLineage
|
||||
*/
|
||||
public class DefaultModelLineage
|
||||
implements ModelLineage
|
||||
|
@ -37,7 +37,7 @@ public class DefaultModelLineage
|
|||
private List tuples = new ArrayList();
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineage#addParent(org.apache.maven.model.Model, java.io.File, java.util.List)
|
||||
* @see ModelLineage#addParent(org.apache.maven.model.Model, java.io.File, java.util.List)
|
||||
*/
|
||||
public void addParent( Model model, File pomFile, List artifactRepositories, boolean validProfilesXmlLocation )
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ public void addParent( Model model, File pomFile, List artifactRepositories, boo
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineage#artifactRepositoryListIterator()
|
||||
* @see ModelLineage#artifactRepositoryListIterator()
|
||||
*/
|
||||
public Iterator artifactRepositoryListIterator()
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ public void remove()
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineage#fileIterator()
|
||||
* @see ModelLineage#fileIterator()
|
||||
*/
|
||||
public Iterator fileIterator()
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ public void remove()
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineage#getArtifactRepositories(org.apache.maven.model.Model)
|
||||
* @see ModelLineage#getArtifactRepositories(org.apache.maven.model.Model)
|
||||
*/
|
||||
public List getArtifactRepositories( Model model )
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ public List getArtifactRepositoryListsInDescendingOrder()
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineage#getFile(org.apache.maven.model.Model)
|
||||
* @see ModelLineage#getFile(org.apache.maven.model.Model)
|
||||
*/
|
||||
public File getFile( Model model )
|
||||
{
|
||||
|
@ -277,7 +277,7 @@ public boolean isDeepestAncestorUsingProfilesXml()
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineage#modelIterator()
|
||||
* @see ModelLineage#modelIterator()
|
||||
*/
|
||||
public Iterator modelIterator()
|
||||
{
|
||||
|
@ -315,7 +315,7 @@ public void setOrigin( Model model, File pomFile, List artifactRepositories, boo
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineage#size()
|
||||
* @see ModelLineage#size()
|
||||
*/
|
||||
public int size()
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
package org.apache.maven.extension.lineage;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -34,6 +34,7 @@
|
|||
import org.apache.maven.profiles.build.ProfileAdvisor;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.ModelAndFile;
|
||||
import org.apache.maven.project.workspace.ProjectWorkspace;
|
||||
import org.codehaus.plexus.logging.LogEnabled;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
@ -52,7 +53,7 @@
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineageBuilder
|
||||
* @see ModelLineageBuilder
|
||||
*/
|
||||
public class DefaultModelLineageBuilder
|
||||
implements ModelLineageBuilder, LogEnabled
|
||||
|
@ -84,7 +85,7 @@ public DefaultModelLineageBuilder( ArtifactResolver resolver,
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.project.build.model.ModelLineageBuilder#buildModelLineage(java.io.File, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List)
|
||||
* @see ModelLineageBuilder#buildModelLineage(java.io.File, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List)
|
||||
*/
|
||||
public ModelLineage buildModelLineage( File pom,
|
||||
ProjectBuilderConfiguration config,
|
||||
|
@ -139,57 +140,6 @@ public ModelLineage buildModelLineage( File pom,
|
|||
return lineage;
|
||||
}
|
||||
|
||||
public void resumeBuildingModelLineage( ModelLineage lineage,
|
||||
ProjectBuilderConfiguration config,
|
||||
boolean allowStubs,
|
||||
boolean isReactorProject )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( lineage.size() == 0 )
|
||||
{
|
||||
throw new ProjectBuildingException( "unknown",
|
||||
"Cannot resume a ModelLineage that doesn't contain at least one Model instance." );
|
||||
}
|
||||
|
||||
List currentRemoteRepositories = lineage.getDeepestAncestorArtifactRepositoryList();
|
||||
|
||||
if ( currentRemoteRepositories == null )
|
||||
{
|
||||
currentRemoteRepositories = new ArrayList();
|
||||
}
|
||||
|
||||
ModelAndFile current = new ModelAndFile( lineage.getDeepestAncestorModel(),
|
||||
lineage.getDeepestAncestorFile(),
|
||||
lineage.isDeepestAncestorUsingProfilesXml() );
|
||||
|
||||
// use the above information to re-bootstrap the resolution chain...
|
||||
current = resolveParentPom( current,
|
||||
currentRemoteRepositories,
|
||||
config,
|
||||
allowStubs,
|
||||
isReactorProject);
|
||||
|
||||
while ( current != null )
|
||||
{
|
||||
lineage.addParent( current.getModel(),
|
||||
current.getFile(),
|
||||
currentRemoteRepositories,
|
||||
current.isValidProfilesXmlLocation() );
|
||||
|
||||
currentRemoteRepositories = updateRepositorySet( current.getModel(),
|
||||
currentRemoteRepositories,
|
||||
current.getFile(),
|
||||
config,
|
||||
current.isValidProfilesXmlLocation() );
|
||||
|
||||
current = resolveParentPom( current,
|
||||
currentRemoteRepositories,
|
||||
config,
|
||||
allowStubs,
|
||||
isReactorProject );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the Model instance from the given POM file. Skip caching the Model on this call, since
|
||||
* it's meant for diagnostic purposes (to determine a parent match).
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
package org.apache.maven.extension.lineage;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
package org.apache.maven.extension.lineage;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -61,25 +61,4 @@ ModelLineage buildModelLineage( File pom,
|
|||
boolean isReactorProject )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
/**
|
||||
* Resume the process of constructing a lineage of inherited models, picking up using the deepest
|
||||
* parent already in the lineage.
|
||||
*
|
||||
* @param lineage The ModelLineage instance in progress, which should be completed.
|
||||
*
|
||||
* @param config The project-building configuration to use, which contains the global profile manager,
|
||||
* local repository, and execution- and user-level properties.
|
||||
*
|
||||
* @param allowStubs Whether stubbed-out Model instances should be constructed in the event that
|
||||
* a parent-POM cannot be resolved.
|
||||
*
|
||||
* @param isReactorProject Whether the model being built is part of the build we're trying to execute,
|
||||
* or if it's actually being read from the repository.
|
||||
*/
|
||||
void resumeBuildingModelLineage( ModelLineage lineage,
|
||||
ProjectBuilderConfiguration config,
|
||||
boolean allowStubs,
|
||||
boolean isReactorProject )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
package org.apache.maven.extension.lineage;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -302,11 +302,11 @@ private String resolveMetaVersion( String groupId,
|
|||
|
||||
version = artifactVersion;
|
||||
}
|
||||
|
||||
if ( version != null )
|
||||
if( version == null )
|
||||
{
|
||||
getLogger().info( "Using version: " + version + " of plugin: " + groupId + ":" + artifactId );
|
||||
version = artifactVersion;
|
||||
}
|
||||
getLogger().info( "Using version: " + version + " of plugin: " + groupId + ":" + artifactId );
|
||||
|
||||
return version;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ under the License.
|
|||
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
|
||||
<role>org.apache.maven.extension.lineage.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
|
@ -204,6 +204,30 @@ under the License.
|
|||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.extension.lineage.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.extension.lineage.DefaultModelLineageBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.workspace.ProjectWorkspace</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.MavenTools</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.ArtifactFilterManager</role>
|
||||
<implementation>org.apache.maven.DefaultArtifactFilterManager</implementation>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project;
|
||||
package org.apache.maven.execution;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -24,6 +24,8 @@
|
|||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.project.DuplicateProjectException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,7 +36,7 @@
|
|||
* Test sorting projects by dependencies.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
* @version $Id: ProjectSorterTest.java 513038 2007-02-28 22:54:19Z jvanzyl $
|
||||
*/
|
||||
public class ProjectSorterTest
|
||||
extends TestCase
|
||||
|
@ -62,7 +64,7 @@ public void testShouldNotFailWhenProjectReferencesNonExistentProject()
|
|||
|
||||
build.addExtension( extension );
|
||||
|
||||
new ProjectSorter( Collections.singletonList( project ) );
|
||||
new ReactorManager.ProjectSorter( Collections.singletonList( project ) );
|
||||
}
|
||||
|
||||
public void testMatchingArtifactIdsDifferentGroupIds()
|
||||
|
@ -75,7 +77,7 @@ public void testMatchingArtifactIdsDifferentGroupIds()
|
|||
projects.add( project2 );
|
||||
project1.getDependencies().add( createDependency( project2 ) );
|
||||
|
||||
projects = new ProjectSorter( projects ).getSortedProjects();
|
||||
projects = new ReactorManager.ProjectSorter( projects ).getSortedProjects();
|
||||
|
||||
assertEquals( project2, projects.get( 0 ) );
|
||||
assertEquals( project1, projects.get( 1 ) );
|
||||
|
@ -91,7 +93,7 @@ public void testMatchingGroupIdsDifferentArtifactIds()
|
|||
projects.add( project2 );
|
||||
project1.getDependencies().add( createDependency( project2 ) );
|
||||
|
||||
projects = new ProjectSorter( projects ).getSortedProjects();
|
||||
projects = new ReactorManager.ProjectSorter( projects ).getSortedProjects();
|
||||
|
||||
assertEquals( project2, projects.get( 0 ) );
|
||||
assertEquals( project1, projects.get( 1 ) );
|
||||
|
@ -108,7 +110,7 @@ public void testMatchingIdsAndVersions()
|
|||
|
||||
try
|
||||
{
|
||||
projects = new ProjectSorter( projects ).getSortedProjects();
|
||||
projects = new ReactorManager.ProjectSorter( projects ).getSortedProjects();
|
||||
fail( "Duplicate projects should fail" );
|
||||
}
|
||||
catch ( DuplicateProjectException e )
|
||||
|
@ -129,7 +131,7 @@ public void testMatchingIdsAndDifferentVersions()
|
|||
|
||||
try
|
||||
{
|
||||
projects = new ProjectSorter( projects ).getSortedProjects();
|
||||
projects = new ReactorManager.ProjectSorter( projects ).getSortedProjects();
|
||||
fail( "Duplicate projects should fail" );
|
||||
}
|
||||
catch ( DuplicateProjectException e )
|
|
@ -11,14 +11,14 @@
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.build.model.DefaultModelLineage;
|
||||
import org.apache.maven.project.build.model.ModelLineage;
|
||||
import org.apache.maven.project.build.model.ModelLineageBuilder;
|
||||
import org.apache.maven.extension.lineage.ModelLineageBuilder;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolator;
|
||||
import org.apache.maven.reactor.MissingModuleException;
|
||||
import org.apache.maven.shared.tools.easymock.MockManager;
|
||||
import org.apache.maven.shared.tools.easymock.TestFileManager;
|
||||
import org.apache.maven.extension.lineage.DefaultModelLineage;
|
||||
import org.apache.maven.extension.lineage.ModelLineage;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||
import org.easymock.ArgumentsMatcher;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
package org.apache.maven.extension.lineage;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
package org.apache.maven.extension.lineage;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -34,8 +34,8 @@
|
|||
import org.apache.maven.profiles.activation.ProfileActivationContext;
|
||||
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.error.ProjectErrorReporter;
|
||||
import org.apache.maven.project.error.ProjectReporterManager;
|
||||
import org.apache.maven.errors.ProjectErrorReporter;
|
||||
import org.apache.maven.errors.ProjectReporterManager;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
@ -577,91 +577,4 @@ private Model createModel( String groupId,
|
|||
return model;
|
||||
}
|
||||
|
||||
public void testReadPOMWithParentMissingFromRepository()
|
||||
throws IOException
|
||||
{
|
||||
File localRepoDirectory = File.createTempFile( "DefaultModelLineageBuilder.localRepository.",
|
||||
"" );
|
||||
|
||||
localRepoDirectory.delete();
|
||||
localRepoDirectory.mkdirs();
|
||||
|
||||
deleteDirOnExit( localRepoDirectory );
|
||||
|
||||
Model current = createModel( "group", "current", "1" );
|
||||
|
||||
Parent currentParent = new Parent();
|
||||
currentParent.setGroupId( "group" );
|
||||
currentParent.setArtifactId( "parent" );
|
||||
currentParent.setVersion( "1" );
|
||||
|
||||
current.setParent( currentParent );
|
||||
|
||||
File currentPOM = File.createTempFile( "DefaultModelLineageBuilder.test.", ".pom" );
|
||||
currentPOM.deleteOnExit();
|
||||
|
||||
writeModel( current, currentPOM );
|
||||
|
||||
ArtifactRepository localRepository = new DefaultArtifactRepository(
|
||||
"local",
|
||||
localRepoDirectory.toURL()
|
||||
.toExternalForm(),
|
||||
defaultLayout );
|
||||
|
||||
try
|
||||
{
|
||||
modelLineageBuilder.buildModelLineage( currentPOM,
|
||||
new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ),
|
||||
Collections.EMPTY_LIST,
|
||||
false,
|
||||
true );
|
||||
|
||||
fail( "should have thrown an ArtifactNotFoundException" );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
assertTrue( ( e.getCause() instanceof ArtifactNotFoundException ) );
|
||||
|
||||
ProjectErrorReporter reporter = ProjectReporterManager.getReporter();
|
||||
Throwable reportedCause = reporter.findReportedException( e );
|
||||
assertNotNull( reportedCause );
|
||||
System.out.println( reporter.getFormattedMessage( reportedCause ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testReadPOM_HandleErrorWhenFileDoesntExist()
|
||||
throws IOException
|
||||
{
|
||||
File localRepoDirectory = new File( "localRepo" ).getAbsoluteFile();
|
||||
File currentPOM = new File( "pom/pom/pom/pom.xml" );
|
||||
|
||||
ArtifactRepository localRepository = new DefaultArtifactRepository(
|
||||
"local",
|
||||
localRepoDirectory.toURL()
|
||||
.toExternalForm(),
|
||||
defaultLayout );
|
||||
|
||||
try
|
||||
{
|
||||
modelLineageBuilder.buildModelLineage( currentPOM,
|
||||
new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ),
|
||||
Collections.EMPTY_LIST,
|
||||
false,
|
||||
true );
|
||||
|
||||
fail( "should have thrown an IOException" );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
assertTrue( ( e.getCause() instanceof IOException ) );
|
||||
|
||||
ProjectErrorReporter reporter = ProjectReporterManager.getReporter();
|
||||
Throwable reportedCause = reporter.findReportedException( e );
|
||||
assertNotNull( reportedCause );
|
||||
System.out.println( reporter.getFormattedMessage( reportedCause ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
package org.apache.maven.extension.lineage;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
@ -1,603 +0,0 @@
|
|||
package org.apache.maven.error;
|
||||
|
||||
import org.apache.maven.NoGoalsSpecifiedException;
|
||||
import org.apache.maven.ProjectCycleException;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.UnknownRepositoryLayoutException;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
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.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.errors.DefaultCoreErrorReporter;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.extension.ExtensionManagerException;
|
||||
import org.apache.maven.lifecycle.LifecycleException;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
||||
import org.apache.maven.lifecycle.LifecycleLoaderException;
|
||||
import org.apache.maven.lifecycle.LifecycleSpecificationException;
|
||||
import org.apache.maven.lifecycle.TaskValidationResult;
|
||||
import org.apache.maven.lifecycle.model.MojoBinding;
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Parent;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.PluginConfigurationException;
|
||||
import org.apache.maven.plugin.PluginExecutionException;
|
||||
import org.apache.maven.plugin.PluginManagerException;
|
||||
import org.apache.maven.plugin.PluginNotFoundException;
|
||||
import org.apache.maven.plugin.PluginParameterException;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
import org.apache.maven.plugin.loader.PluginLoaderException;
|
||||
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
|
||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationContext;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||
import org.apache.maven.profiles.activation.ProfileActivator;
|
||||
import org.apache.maven.project.DuplicateProjectException;
|
||||
import org.apache.maven.project.InvalidProjectModelException;
|
||||
import org.apache.maven.project.InvalidProjectVersionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.build.model.ModelAndFile;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.reactor.MavenExecutionException;
|
||||
import org.apache.maven.realm.RealmManagementException;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DummyCoreErrorReporter
|
||||
extends DefaultCoreErrorReporter
|
||||
{
|
||||
|
||||
public void handleSuperPomBuildingError( ProjectBuildingException exception )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportAggregatedMojoFailureException( MavenSession session,
|
||||
MojoBinding binding,
|
||||
MojoFailureException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportAttemptToOverrideUneditableMojoParameter( Parameter currentParameter,
|
||||
MojoBinding binding,
|
||||
MavenProject project,
|
||||
MavenSession session,
|
||||
MojoExecution exec,
|
||||
PathTranslator translator,
|
||||
Logger logger,
|
||||
PluginConfigurationException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorApplyingMojoConfiguration( MojoBinding binding,
|
||||
MavenProject project,
|
||||
PlexusConfiguration config,
|
||||
PluginConfigurationException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorConfiguringExtensionPluginRealm( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
PluginManagerException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorFormulatingBuildPlan( List tasks,
|
||||
MavenProject configuringProject,
|
||||
String targetDescription,
|
||||
LifecycleException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorInterpolatingModel( Model model,
|
||||
Map inheritedValues,
|
||||
File pomFile,
|
||||
MavenExecutionRequest request,
|
||||
ModelInterpolationException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorLoadingPlugin( MojoBinding binding,
|
||||
MavenProject project,
|
||||
PluginLoaderException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorManagingRealmForExtension( Artifact extensionArtifact,
|
||||
Artifact projectArtifact,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
RealmManagementException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorManagingRealmForExtensionPlugin( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
RealmManagementException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorResolvingExtensionDependencies( Artifact extensionArtifact,
|
||||
Artifact projectArtifact,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
ArtifactResolutionResult resolutionResult,
|
||||
ExtensionManagerException err )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorResolvingExtensionDirectDependencies( Artifact extensionArtifact,
|
||||
Artifact projectArtifact,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
ArtifactMetadataRetrievalException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
String requiredMavenVersion,
|
||||
String currentMavenVersion,
|
||||
InvalidVersionSpecificationException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportExtensionPluginArtifactNotFound( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
PluginNotFoundException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportExtensionPluginVersionNotFound( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
PluginVersionNotFoundException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportIncompatibleMavenVersionForExtensionPlugin( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
String requiredMavenVersion,
|
||||
String currentMavenVersion,
|
||||
PluginVersionResolutionException err )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
InvalidDependencyVersionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportInvalidMavenVersion( MavenProject project,
|
||||
ArtifactVersion mavenVersion,
|
||||
MavenExecutionException err )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportInvalidPluginExecutionEnvironment( MojoBinding binding,
|
||||
MavenProject project,
|
||||
PluginExecutionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportLifecycleLoaderErrorWhileValidatingTask( MavenSession session,
|
||||
MavenProject rootProject,
|
||||
LifecycleLoaderException cause,
|
||||
TaskValidationResult result )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportLifecycleSpecErrorWhileValidatingTask( MavenSession session,
|
||||
MavenProject rootProject,
|
||||
LifecycleSpecificationException cause,
|
||||
TaskValidationResult result )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
ArtifactNotFoundException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportMissingPluginDescriptor( MojoBinding binding,
|
||||
MavenProject project,
|
||||
LifecycleExecutionException err )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportMissingRequiredMojoParameter( MojoBinding binding,
|
||||
MavenProject project,
|
||||
List invalidParameters,
|
||||
PluginParameterException err )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportMojoExecutionException( MojoBinding binding,
|
||||
MavenProject project,
|
||||
MojoExecutionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportMojoLookupError( MojoBinding binding,
|
||||
MavenProject project,
|
||||
ComponentLookupException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportNoGoalsSpecifiedException( MavenProject rootProject,
|
||||
NoGoalsSpecifiedException error )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportPluginErrorWhileValidatingTask( MavenSession session,
|
||||
MavenProject rootProject,
|
||||
PluginLoaderException cause,
|
||||
TaskValidationResult result )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportPomFileCanonicalizationError( File pomFile,
|
||||
IOException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportPomFileScanningError( File basedir,
|
||||
String includes,
|
||||
String excludes,
|
||||
IOException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportProjectCycle( ProjectCycleException error )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportProjectDependenciesNotFound( MavenProject project,
|
||||
String scope,
|
||||
ArtifactNotFoundException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportProjectDependenciesUnresolvable( MavenProject project,
|
||||
String scope,
|
||||
ArtifactResolutionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportProjectDependencyArtifactNotFound( MavenProject project,
|
||||
Artifact artifact,
|
||||
ArtifactNotFoundException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportProjectDependencyArtifactUnresolvable( MavenProject project,
|
||||
Artifact artifact,
|
||||
ArtifactResolutionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportProjectMojoFailureException( MavenSession session,
|
||||
MojoBinding binding,
|
||||
MojoFailureException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportReflectionErrorWhileEvaluatingMojoParameter( Parameter currentParameter,
|
||||
MojoBinding binding,
|
||||
MavenProject project,
|
||||
String expression,
|
||||
Exception cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportUnresolvableArtifactWhileAddingExtensionPlugin( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
ArtifactResolutionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportUnresolvableExtensionPluginPOM( Plugin plugin,
|
||||
Model originModel,
|
||||
List remoteRepos,
|
||||
MavenExecutionRequest request,
|
||||
ArtifactMetadataRetrievalException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportUseOfBannedMojoParameter( Parameter currentParameter,
|
||||
MojoBinding binding,
|
||||
MavenProject project,
|
||||
String expression,
|
||||
String altExpression,
|
||||
ExpressionEvaluationException err )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportActivatorError( ProfileActivator activator,
|
||||
String projectId,
|
||||
File pomFile,
|
||||
Profile profile,
|
||||
ProfileActivationContext context,
|
||||
ProfileActivationException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportActivatorLookupError( String projectId,
|
||||
File pomFile,
|
||||
Profile profile,
|
||||
ComponentLookupException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportBadDependencyVersion( MavenProject project,
|
||||
File pomFile,
|
||||
InvalidDependencyVersionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportBadManagedDependencyVersion( MavenProject projectBeingBuilt,
|
||||
File pomFile,
|
||||
InvalidDependencyVersionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportBadNonDependencyProjectArtifactVersion( MavenProject project,
|
||||
File pomFile,
|
||||
InvalidProjectVersionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorCreatingArtifactRepository( MavenProject project,
|
||||
File pomFile,
|
||||
Repository repo,
|
||||
UnknownRepositoryLayoutException cause,
|
||||
boolean isPluginRepo )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorCreatingDeploymentArtifactRepository( MavenProject project,
|
||||
File pomFile,
|
||||
DeploymentRepository repo,
|
||||
UnknownRepositoryLayoutException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorInterpolatingModel( MavenProject project,
|
||||
File pomFile,
|
||||
ModelInterpolationException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorLoadingExternalProfilesFromFile( Model model,
|
||||
File pomFile,
|
||||
File projectDir,
|
||||
IOException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorLoadingExternalProfilesFromFile( Model model,
|
||||
File pomFile,
|
||||
File projectDir,
|
||||
XmlPullParserException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorParsingParentProjectModel( ModelAndFile childInfo,
|
||||
File parentPomFile,
|
||||
XmlPullParserException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorParsingParentProjectModel( ModelAndFile childInfo,
|
||||
File parentPomFile,
|
||||
IOException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorParsingProjectModel( String projectId,
|
||||
File pomFile,
|
||||
XmlPullParserException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportErrorParsingProjectModel( String projectId,
|
||||
File pomFile,
|
||||
IOException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportInvalidRepositoryWhileGettingRepositoriesFromProfiles( Repository repo,
|
||||
String projectId,
|
||||
File pomFile,
|
||||
InvalidRepositoryException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportParentPomArtifactNotFound( Parent parentRef,
|
||||
ArtifactRepository localRepo,
|
||||
List remoteRepos,
|
||||
String childId,
|
||||
File childPomFile,
|
||||
ArtifactNotFoundException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportParentPomArtifactUnresolvable( Parent parentRef,
|
||||
ArtifactRepository localRepo,
|
||||
List remoteRepos,
|
||||
String childId,
|
||||
File childPomFile,
|
||||
ArtifactResolutionException cause )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportProjectCollision( List allProjectInstances,
|
||||
DuplicateProjectException err )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reportProjectValidationFailure( MavenProject project,
|
||||
File pomFile,
|
||||
InvalidProjectModelException error )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -31,7 +31,7 @@ under the License.
|
|||
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
|
||||
<role>org.apache.maven.extension.lineage.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
|
@ -44,6 +44,30 @@ under the License.
|
|||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.extension.lineage.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.extension.lineage.DefaultModelLineageBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.workspace.ProjectWorkspace</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.MavenTools</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.ArtifactFilterManager</role>
|
||||
<implementation>org.apache.maven.DefaultArtifactFilterManager</implementation>
|
||||
|
|
|
@ -23,15 +23,9 @@ under the License.
|
|||
<role>org.apache.maven.project.MavenProjectBuilder</role>
|
||||
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.inheritance.ModelInheritanceAssembler</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.validation.ModelValidator</role>
|
||||
</requirement>
|
||||
|
|
|
@ -73,9 +73,9 @@ under the License.
|
|||
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
|
||||
<role>org.apache.maven.extension.lineage.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.project.build.model.DefaultModelLineageBuilder</implementation>
|
||||
<implementation>org.apache.maven.extension.lineage.DefaultModelLineageBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
|
||||
|
@ -97,6 +97,30 @@ under the License.
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.extension.lineage.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.extension.lineage.DefaultModelLineageBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.workspace.ProjectWorkspace</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.MavenTools</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<!--
|
||||
|
|
||||
|
|
||||
|
@ -120,15 +144,7 @@ under the License.
|
|||
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
|
||||
<implementation>org.apache.maven.project.interpolation.RegexBasedModelInterpolator</implementation>
|
||||
</component>
|
||||
<!--
|
||||
|
|
||||
|
|
||||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
|
||||
<implementation>org.apache.maven.project.injection.DefaultModelDefaultsInjector</implementation>
|
||||
</component>
|
||||
|
||||
<!--
|
||||
|
|
||||
|
|
||||
|
@ -147,10 +163,6 @@ under the License.
|
|||
<role>org.apache.maven.project.MavenProjectBuilder</role>
|
||||
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
|
||||
<role-hint>default</role-hint>
|
||||
|
@ -158,15 +170,9 @@ under the License.
|
|||
<requirement>
|
||||
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.inheritance.ModelInheritanceAssembler</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.validation.ModelValidator</role>
|
||||
</requirement>
|
||||
|
|
|
@ -81,7 +81,7 @@ under the License.
|
|||
<implementation>org.apache.maven.project.TestProjectBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
|
||||
<role>org.apache.maven.extension.lineage.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
|
@ -91,9 +91,6 @@ under the License.
|
|||
<requirement>
|
||||
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
|
||||
</requirement>
|
||||
|
@ -121,5 +118,28 @@ under the License.
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.extension.lineage.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.extension.lineage.DefaultModelLineageBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.workspace.ProjectWorkspace</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.MavenTools</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
</components>
|
||||
</plexus>
|
||||
|
|
|
@ -78,10 +78,6 @@ under the License.
|
|||
<role-hint>test</role-hint>
|
||||
<implementation>org.apache.maven.project.TestProjectBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
|
||||
<role-hint>default</role-hint>
|
||||
|
@ -89,15 +85,9 @@ under the License.
|
|||
<requirement>
|
||||
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.inheritance.ModelInheritanceAssembler</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.validation.ModelValidator</role>
|
||||
</requirement>
|
||||
|
|
|
@ -78,21 +78,4 @@ under the License.
|
|||
<artifactId>maven-shared-model</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>aspectj-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile-aspects</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package org.apache.maven.project.aspect;
|
||||
|
||||
import org.apache.maven.project.error.ProjectErrorReporter;
|
||||
import org.apache.maven.project.error.ProjectReporterManager;
|
||||
|
||||
public abstract aspect AbstractProjectErrorReporterAspect issingleton()
|
||||
{
|
||||
|
||||
protected pointcut notWithinAspect():
|
||||
!within( org.apache.maven.project.aspect.*+ );
|
||||
|
||||
protected ProjectErrorReporter getReporter()
|
||||
{
|
||||
return ProjectReporterManager.getReporter();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,262 +0,0 @@
|
|||
package org.apache.maven.project.aspect;
|
||||
|
||||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.profiles.build.DefaultProfileAdvisor;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.InvalidProjectVersionException;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.MavenTools;
|
||||
import org.apache.maven.DefaultMavenTools;
|
||||
import org.apache.maven.project.build.model.DefaultModelLineageBuilder;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.DefaultMavenProjectBuilder;
|
||||
import org.apache.maven.project.InvalidProjectModelException;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
public privileged aspect PBEDerivativeReporterAspect
|
||||
extends AbstractProjectErrorReporterAspect
|
||||
{
|
||||
|
||||
// UnknownRepositoryLayoutException
|
||||
|
||||
private pointcut mavenTools_buildDeploymentArtifactRepository( DeploymentRepository repo ):
|
||||
call( ArtifactRepository MavenTools+.buildDeploymentArtifactRepository( DeploymentRepository ) )
|
||||
&& args( repo );
|
||||
|
||||
private pointcut pbldr_processProjectLogic( MavenProject project, File pomFile ):
|
||||
execution( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) )
|
||||
&& args( project, pomFile, .. );
|
||||
|
||||
private pointcut within_pbldr_processProjectLogic( MavenProject project, File pomFile ):
|
||||
withincode( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) )
|
||||
&& args( project, pomFile, .. );
|
||||
|
||||
private pointcut within_DefaultMavenProjectBuilder():
|
||||
!withincode( * DefaultProfileAdvisor.*( .. ) )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultMavenProjectBuilder.buildFromRepository(..)
|
||||
// DefaultMavenProjectBuilder.build(..)
|
||||
// --> DefaultMavenProjectBuilder.buildFromSourceFileInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.buildInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.processProjectLogic(..) (private)
|
||||
// --> DefaultMavenTools.buildDeploymentArtifactRepository(..)
|
||||
// <-- UnknownRepositoryLayoutException
|
||||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
|
||||
after( MavenProject project, File pomFile, DeploymentRepository repo ) throwing( InvalidRepositoryException cause ):
|
||||
mavenTools_buildDeploymentArtifactRepository( repo ) &&
|
||||
cflow( pbldr_processProjectLogic( project, pomFile ) )
|
||||
&& within_DefaultMavenProjectBuilder()
|
||||
{
|
||||
getReporter().reportErrorCreatingDeploymentArtifactRepository( project, pomFile, repo, cause );
|
||||
}
|
||||
|
||||
private pointcut mavenTools_buildArtifactRepository( Repository repo ):
|
||||
execution( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) )
|
||||
&& args( repo );
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultMavenProjectBuilder.buildFromRepository(..)
|
||||
// DefaultMavenProjectBuilder.build(..)
|
||||
// --> DefaultMavenProjectBuilder.buildFromSourceFileInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.buildInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.processProjectLogic(..) (private)
|
||||
// --> DefaultMavenTools.buildArtifactRepositories(..)
|
||||
// --> DefaultMavenTools.buildArtifactRepository(..)
|
||||
// <------ UnknownRepositoryLayoutException
|
||||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( MavenProject project, File pomFile, Repository repo ) throwing( InvalidRepositoryException cause ):
|
||||
mavenTools_buildArtifactRepository( repo )
|
||||
&& cflow( pbldr_processProjectLogic( project, pomFile ) )
|
||||
{
|
||||
getReporter().reportErrorCreatingArtifactRepository( project.getId(), pomFile, repo, cause );
|
||||
}
|
||||
|
||||
private pointcut mlbldr_updateRepositorySet( Model model, File pomFile ):
|
||||
execution( List DefaultModelLineageBuilder.updateRepositorySet( Model, *, File, .. ) )
|
||||
&& args( model, *, pomFile, .. );
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultModelLineageBuilder.buildModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.resumeBuildingModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.updateRepositorySet(..) (private)
|
||||
// --> DefaultMavenTools.buildArtifactRepositories(..)
|
||||
// --> DefaultMavenTools.buildArtifactRepository(..)
|
||||
// <------ UnknownRepositoryLayoutException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( Model model, File pomFile, Repository repo ) throwing( InvalidRepositoryException cause ):
|
||||
mavenTools_buildArtifactRepository( repo )
|
||||
&& cflow( mlbldr_updateRepositorySet( model, pomFile ) )
|
||||
{
|
||||
getReporter().reportErrorCreatingArtifactRepository( model.getId(), pomFile, repo, cause );
|
||||
}
|
||||
|
||||
// ModelInterpolationException
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultMavenProjectBuilder.buildFromRepository(..)
|
||||
// DefaultMavenProjectBuilder.build(..)
|
||||
// --> DefaultMavenProjectBuilder.buildFromSourceFileInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.buildInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.processProjectLogic(..) (private)
|
||||
// --> ModelInterpolator.interpolate(..)
|
||||
// <-- ModelInterpolationException
|
||||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( MavenProject project, File pomFile ) throwing( ModelInterpolationException cause ):
|
||||
pbldr_processProjectLogic( project, pomFile )
|
||||
{
|
||||
getReporter().reportErrorInterpolatingModel( project, pomFile, cause );
|
||||
}
|
||||
|
||||
// InvalidProjectVersionException
|
||||
|
||||
private pointcut pbldr_createNonDependencyArtifacts():
|
||||
( call( protected * DefaultMavenProjectBuilder.createPluginArtifacts( .. ) )
|
||||
|| call( protected * DefaultMavenProjectBuilder.createReportArtifacts( .. ) )
|
||||
|| call( protected * DefaultMavenProjectBuilder.createExtensionArtifacts( .. ) ) )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultMavenProjectBuilder.buildFromRepository(..)
|
||||
// DefaultMavenProjectBuilder.build(..)
|
||||
// --> DefaultMavenProjectBuilder.buildFromSourceFileInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.buildInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.processProjectLogic(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.createPluginArtifacts(..)
|
||||
// --> DefaultMavenProjectBuilder.createReportArtifacts(..)
|
||||
// --> DefaultMavenProjectBuilder.createExtensionArtifacts(..)
|
||||
// <-- InvalidProjectVersionException
|
||||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( MavenProject project, File pomFile ) throwing( ProjectBuildingException cause ):
|
||||
cflow( pbldr_processProjectLogic( project, pomFile ) )
|
||||
&& pbldr_createNonDependencyArtifacts()
|
||||
&& within_DefaultMavenProjectBuilder()
|
||||
{
|
||||
if ( cause instanceof InvalidProjectVersionException )
|
||||
{
|
||||
getReporter().reportBadNonDependencyProjectArtifactVersion( project, pomFile, (InvalidProjectVersionException) cause );
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultMavenProjectBuilder.buildFromRepository(..)
|
||||
// DefaultMavenProjectBuilder.build(..)
|
||||
// --> DefaultMavenProjectBuilder.buildFromSourceFileInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.buildInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.processProjectLogic(..) (private)
|
||||
// --> (model validator result)
|
||||
// <-- InvalidProjectModelException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( MavenProject project, File pomFile ) throwing( InvalidProjectModelException cause ):
|
||||
cflow( pbldr_processProjectLogic( project, pomFile ) )
|
||||
&& within_DefaultMavenProjectBuilder()
|
||||
&& execution( void DefaultMavenProjectBuilder.validateModel( .. ) )
|
||||
{
|
||||
getReporter().reportProjectValidationFailure( project, pomFile, cause );
|
||||
}
|
||||
|
||||
|
||||
// InvalidDependencyVersionException
|
||||
|
||||
private pointcut pbldr_buildInternal():
|
||||
execution( * DefaultMavenProjectBuilder.buildInternal( .. ) );
|
||||
|
||||
private MavenProject projectBeingBuilt;
|
||||
|
||||
after( MavenProject project ):
|
||||
cflow( pbldr_buildInternal() )
|
||||
&& !cflowbelow( pbldr_buildInternal() )
|
||||
&& within_DefaultMavenProjectBuilder()
|
||||
&& call( DependencyManagement MavenProject.getDependencyManagement() )
|
||||
&& target( project )
|
||||
{
|
||||
projectBeingBuilt = project;
|
||||
}
|
||||
|
||||
after(): pbldr_buildInternal()
|
||||
{
|
||||
projectBeingBuilt = null;
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultMavenProjectBuilder.buildFromRepository(..)
|
||||
// DefaultMavenProjectBuilder.build(..)
|
||||
// --> DefaultMavenProjectBuilder.buildFromSourceFileInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.buildInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.createManagedVersionMap(..) (private)
|
||||
// <-- InvalidDependencyVersionException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( File pomFile ) throwing( ProjectBuildingException cause ):
|
||||
cflow( pbldr_buildInternal() )
|
||||
&& within_DefaultMavenProjectBuilder()
|
||||
&& execution( * DefaultMavenProjectBuilder.createManagedVersionMap( .., File ) )
|
||||
&& args( .., pomFile )
|
||||
{
|
||||
if ( cause instanceof InvalidDependencyVersionException )
|
||||
{
|
||||
getReporter().reportBadManagedDependencyVersion( projectBeingBuilt, pomFile, (InvalidDependencyVersionException) cause );
|
||||
}
|
||||
}
|
||||
|
||||
protected pointcut mms_createArtifacts( MavenProject project ):
|
||||
call( public static Set MavenMetadataSource.createArtifacts( .., MavenProject ) )
|
||||
&& args( .., project )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> MavenProject.createArtifacts(..)
|
||||
// --> MavenMetadataSource.createArtifacts(..)
|
||||
// <-- InvalidDependencyVersionException
|
||||
// <-- ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( MavenProject project ) throwing( InvalidDependencyVersionException cause ):
|
||||
cflow( execution( * MavenProject.createArtifacts( .. ) ) )
|
||||
&& mms_createArtifacts( project )
|
||||
{
|
||||
getReporter().reportBadDependencyVersion( project, project.getFile(), cause );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,223 +0,0 @@
|
|||
package org.apache.maven.project.aspect;
|
||||
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.profiles.activation.ProfileActivator;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationContext;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||
import org.apache.maven.profiles.build.DefaultProfileAdvisor;
|
||||
import org.apache.maven.profiles.build.ProfileAdvisor;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.profiles.DefaultProfileManager;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
import org.apache.maven.profiles.MavenProfilesBuilder;
|
||||
import org.apache.maven.profiles.ProfilesRoot;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.MavenTools;
|
||||
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Error reporting advice to handle {@link ProjectBuildingException} instances
|
||||
* coming from {@link DefaultProfileAdvisor}.
|
||||
*/
|
||||
public privileged aspect ProfileErrorReporterAspect
|
||||
extends AbstractProjectErrorReporterAspect
|
||||
{
|
||||
|
||||
private pointcut within_pMgr_isActiveExec( Profile profile, ProfileActivationContext context ):
|
||||
withincode( boolean DefaultProfileManager.isActive( Profile, ProfileActivationContext ) )
|
||||
&& args( profile, context );
|
||||
|
||||
private pointcut pMgr_isActiveExec( Profile profile, ProfileActivationContext context ):
|
||||
execution( boolean DefaultProfileManager.isActive( Profile, ProfileActivationContext ) )
|
||||
&& args( profile, context );
|
||||
|
||||
private pointcut pAdv_applyActivatedProfiles( Model model, File pomFile ):
|
||||
execution( private List DefaultProfileAdvisor.applyActivatedProfiles( Model, File, .. ) )
|
||||
&& args( model, pomFile, .. )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// DefaultProfileAdvisor.applyActivatedProfiles(..)
|
||||
// DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
|
||||
// --> DefaultProfileAdvisor.applyActivatedProfiles(..) (private)
|
||||
// --> DefaultProfileManager.getActiveProfiles(..)
|
||||
// --> DefaultProfileManager.isActive(..) (private)
|
||||
// --> PlexusContainer.lookupList(..)
|
||||
// <-- ComponentLookupException
|
||||
// <-- ProfileActivationException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( Model model, File pomFile, Profile profile, ProfileActivationContext context )
|
||||
throwing( ComponentLookupException cause ):
|
||||
call( List PlexusContainer+.lookupList( .. ) )
|
||||
&& cflow( pAdv_applyActivatedProfiles( model, pomFile ) )
|
||||
&& cflow( pMgr_isActiveExec( profile, context ) )
|
||||
{
|
||||
getReporter().reportActivatorLookupError( model, pomFile, profile, context, cause );
|
||||
}
|
||||
|
||||
private pointcut pAdv_getArtifactRepositoriesFromActiveProfiles_1( Model model, File pomFile ):
|
||||
execution( LinkedHashSet ProfileAdvisor+.getArtifactRepositoriesFromActiveProfiles( Model, File, ProfileManager ) )
|
||||
&& args( model, pomFile, * );
|
||||
|
||||
private pointcut pAdv_getArtifactRepositoriesFromActiveProfiles_2( Model model, File pomFile ):
|
||||
execution( LinkedHashSet ProfileAdvisor+.getArtifactRepositoriesFromActiveProfiles( Model, File, boolean, ProfileActivationContext ) )
|
||||
&& args( model, pomFile, *, * );
|
||||
|
||||
private pointcut pAdv_getArtifactRepos( Model model, File pomFile ):
|
||||
pAdv_getArtifactRepositoriesFromActiveProfiles_1( model, pomFile )
|
||||
|| pAdv_getArtifactRepositoriesFromActiveProfiles_2( model, pomFile );
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// DefaultProfileAdvisor.applyActivatedProfiles(..)
|
||||
// DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
|
||||
// --> DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
|
||||
// --> DefaultProfileManager.getActiveProfiles(..)
|
||||
// --> DefaultProfileManager.isActive(..) (private)
|
||||
// --> PlexusContainer.lookupList(..)
|
||||
// <-- ComponentLookupException
|
||||
// <-- ProfileActivationException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( Model model, File pomFile, Profile profile, ProfileActivationContext context )
|
||||
throwing( ComponentLookupException cause ):
|
||||
call( List PlexusContainer+.lookupList( .. ) )
|
||||
&& cflow( pAdv_getArtifactRepos( model, pomFile ) )
|
||||
&& cflow( pMgr_isActiveExec( profile, context ) )
|
||||
{
|
||||
getReporter().reportActivatorLookupError( model, pomFile, profile, context, cause );
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// DefaultProfileAdvisor.applyActivatedProfiles(..)
|
||||
// DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
|
||||
// --> DefaultProfileAdvisor.applyActivatedProfiles(..) (private)
|
||||
// --> DefaultProfileManager.getActiveProfiles(..)
|
||||
// --> DefaultProfileManager.isActive(..) (private)
|
||||
// --> ProfileActivator.canDetermineActivation(..)
|
||||
// --> ProfileActivator.isActive(..)
|
||||
// <------ ProfileActivationException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( ProfileActivator activator, Model model, File pomFile, Profile profile, ProfileActivationContext context )
|
||||
throwing( ProfileActivationException cause ):
|
||||
call( * ProfileActivator+.*( .. ) )
|
||||
&& target( activator )
|
||||
&& cflow( pAdv_applyActivatedProfiles( model, pomFile ) )
|
||||
&& cflow( pMgr_isActiveExec( profile, context ) )
|
||||
{
|
||||
getReporter().reportActivatorError( activator, model, pomFile, profile, context, cause );
|
||||
}
|
||||
|
||||
private pointcut pAdv_loadExternalProjectProfiles( Model model, File pomFile ):
|
||||
execution( private void DefaultProfileAdvisor.loadExternalProjectProfiles( *, Model, File ) )
|
||||
&& args( *, model, pomFile )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// DefaultProfileAdvisor.applyActivatedProfiles(..)
|
||||
// DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
|
||||
// --> DefaultProfileAdvisor.buildProfileManager(..) (private)
|
||||
// --> DefaultProfileAdvisor.loadExternalProjectProfiles(..) (private)
|
||||
// --> MavenProfilesBuilder.buildProfiles(..)
|
||||
// <-- IOException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( Model model, File pomFile, File projectDir )
|
||||
throwing( IOException cause ):
|
||||
call( ProfilesRoot MavenProfilesBuilder+.buildProfiles( File ) )
|
||||
&& cflow( pAdv_loadExternalProjectProfiles( model, pomFile ) )
|
||||
&& args( projectDir )
|
||||
{
|
||||
getReporter().reportErrorLoadingExternalProfilesFromFile( model, pomFile, projectDir, cause );
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// DefaultProfileAdvisor.applyActivatedProfiles(..)
|
||||
// DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
|
||||
// --> DefaultProfileAdvisor.buildProfileManager(..) (private)
|
||||
// --> DefaultProfileAdvisor.loadExternalProjectProfiles(..) (private)
|
||||
// --> MavenProfilesBuilder.buildProfiles(..)
|
||||
// <-- XmlPullParserException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( Model model, File pomFile, File projectDir )
|
||||
throwing( XmlPullParserException cause ):
|
||||
call( ProfilesRoot MavenProfilesBuilder+.buildProfiles( File ) )
|
||||
&& cflow( pAdv_loadExternalProjectProfiles( model, pomFile ) )
|
||||
&& args( projectDir )
|
||||
{
|
||||
getReporter().reportErrorLoadingExternalProfilesFromFile( model, pomFile, projectDir, cause );
|
||||
}
|
||||
|
||||
private pointcut pAdv_getArtifactRepositoriesFromActiveProfiles( String projectId, File pomFile ):
|
||||
execution( LinkedHashSet DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles( *, File, String ) )
|
||||
&& args( *, pomFile, projectId )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// DefaultProfileAdvisor.applyActivatedProfiles(..)
|
||||
// DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
|
||||
// --> DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
|
||||
// --> DefaultProfileManager.getActiveProfiles(..)
|
||||
// --> DefaultProfileManager.isActive(..) (private)
|
||||
// --> ProfileActivator.canDetermineActivation(..)
|
||||
// --> ProfileActivator.isActive(..)
|
||||
// <------ ProfileActivationException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( ProfileActivator activator, Model model, File pomFile, Profile profile, ProfileActivationContext context )
|
||||
throwing( ProfileActivationException cause ):
|
||||
call( * ProfileActivator+.*( .. ) )
|
||||
&& target( activator )
|
||||
&& cflow( pAdv_getArtifactRepos( model, pomFile ) )
|
||||
&& cflow( pMgr_isActiveExec( profile, context ) )
|
||||
&& within( DefaultProfileManager )
|
||||
{
|
||||
getReporter().reportActivatorError( activator, model, pomFile, profile, context, cause );
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// DefaultProfileAdvisor.applyActivatedProfiles(..)
|
||||
// DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
|
||||
// --> DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
|
||||
// --> MavenTools.buildArtifactRepository(..)
|
||||
// <-- InvalidRepositoryException
|
||||
// <-- ProjectBuildingException
|
||||
// =========================================================================
|
||||
after( Repository repo, Model model, File pomFile )
|
||||
throwing( InvalidRepositoryException cause ):
|
||||
call( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) )
|
||||
&& args( repo )
|
||||
&& cflow( pAdv_getArtifactRepos( model, pomFile ) )
|
||||
&& within( DefaultProfileAdvisor )
|
||||
{
|
||||
getReporter().reportInvalidRepositoryWhileGettingRepositoriesFromProfiles( repo, model, pomFile, cause );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package org.apache.maven.project.aspect;
|
||||
|
||||
import org.apache.maven.project.build.model.DefaultModelLineageBuilder;
|
||||
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.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.model.Parent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public privileged aspect ProjectArtifactErrorReporterAspect
|
||||
extends AbstractProjectErrorReporterAspect
|
||||
{
|
||||
|
||||
private pointcut mlbldr_resolveParentFromRepositories( Parent parentRef, ProjectBuilderConfiguration config,
|
||||
List remoteRepos, String childId, File childPomFile ):
|
||||
execution( private File DefaultModelLineageBuilder.resolveParentFromRepositories( Parent, ProjectBuilderConfiguration, List, String, File ) )
|
||||
&& args( parentRef, config, remoteRepos, childId, childPomFile );
|
||||
|
||||
private pointcut mlbldr_parentArtifactNotFound( Parent parentRef, ProjectBuilderConfiguration config, List remoteRepos, String childId, File childPomFile, ArtifactNotFoundException cause ):
|
||||
cflow( mlbldr_resolveParentFromRepositories( parentRef, config, remoteRepos, childId, childPomFile ) )
|
||||
&& call( ProjectBuildingException.new( .., ArtifactNotFoundException ) )
|
||||
&& within( DefaultModelLineageBuilder )
|
||||
&& args( .., cause )
|
||||
&& notWithinAspect();
|
||||
|
||||
private pointcut mlbldr_parentArtifactUnresolvable( Parent parentRef, ProjectBuilderConfiguration config, List remoteRepos, String childId, File childPomFile, ArtifactResolutionException cause ):
|
||||
cflow( mlbldr_resolveParentFromRepositories( parentRef, config, remoteRepos, childId, childPomFile ) )
|
||||
&& call( ProjectBuildingException.new( .., ArtifactResolutionException ) )
|
||||
&& within( DefaultModelLineageBuilder )
|
||||
&& args( .., cause )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultModelLineageBuilder.buildModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.resolveParentPom(..) (private)
|
||||
// --> DefaultModelLineageBuilder.resolveParentFromRepository(..) (private)
|
||||
// --> thrown ArtifactNotFoundException
|
||||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
before( Parent parentRef, ProjectBuilderConfiguration config, List remoteRepos, String childId, File childPomFile, ArtifactNotFoundException cause ):
|
||||
mlbldr_parentArtifactNotFound( parentRef, config, remoteRepos, childId, childPomFile, cause )
|
||||
{
|
||||
getReporter().reportParentPomArtifactNotFound( parentRef, config, remoteRepos, childId, childPomFile, cause );
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultModelLineageBuilder.buildModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.resolveParentPom(..) (private)
|
||||
// --> DefaultModelLineageBuilder.resolveParentFromRepository(..) (private)
|
||||
// --> thrown ArtifactResolutionException
|
||||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
before( Parent parentRef, ProjectBuilderConfiguration config, List remoteRepos, String childId, File childPomFile, ArtifactResolutionException cause ):
|
||||
mlbldr_parentArtifactUnresolvable( parentRef, config, remoteRepos, childId, childPomFile, cause )
|
||||
{
|
||||
getReporter().reportParentPomArtifactUnresolvable( parentRef, config, remoteRepos, childId, childPomFile, cause );
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package org.apache.maven.project.aspect;
|
||||
|
||||
import org.apache.maven.project.DuplicateProjectException;
|
||||
import org.apache.maven.project.ProjectSorter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public aspect ProjectCollisionReporterAspect
|
||||
extends AbstractProjectErrorReporterAspect
|
||||
{
|
||||
|
||||
/**
|
||||
* <b>Call Stack:</b>
|
||||
* <br/>
|
||||
* <pre>
|
||||
* MavenEmbedder.execute(MavenExecutionRequest)
|
||||
* MavenEmbedder.readProjectWithDependencies(MavenExecutionRequest)
|
||||
* --> DefaultMaven.execute(MavenExecutionRequest)
|
||||
* --> DefaultMaven.createReactorManager(MavenExecutionRequest, MavenExecutionResult)
|
||||
* --> new ReactorManager(List, String)
|
||||
* --> new ProjectSorter(List)
|
||||
* <----------------------- DuplicateProjectException
|
||||
* </pre>
|
||||
*/
|
||||
after( List allProjectInstances ) throwing( DuplicateProjectException err ):
|
||||
execution( ProjectSorter.new( List ) )
|
||||
&& args( allProjectInstances )
|
||||
{
|
||||
getReporter().reportProjectCollision( allProjectInstances, err );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package org.apache.maven.project.aspect;
|
||||
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.DefaultMavenProjectBuilder;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public privileged aspect ProjectDebugAspect
|
||||
{
|
||||
|
||||
// before( String dir, MavenProject project ):
|
||||
// cflow( execution( * DefaultMavenProjectBuilder.buildInternal( .. ) ) )
|
||||
// && call( void MavenProject.addScriptSourceRoot( String ) )
|
||||
// && args( dir )
|
||||
// && target( project )
|
||||
// {
|
||||
// System.out.println( "Setting script-source-root from POM to: " + dir + " in project: " + project.getId() );
|
||||
// }
|
||||
//
|
||||
// after( MavenProject project ) returning( List scriptSourceRoots ):
|
||||
// execution( List MavenProject.getScriptSourceRoots() )
|
||||
// && this( project )
|
||||
// {
|
||||
// System.out.println( "Using script-source-roots:\n\n" + StringUtils.join( scriptSourceRoots.iterator(), "\nfrom project: " + project.getId() ) );
|
||||
// }
|
||||
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
package org.apache.maven.project.aspect;
|
||||
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.project.DefaultMavenProjectBuilder;
|
||||
import org.apache.maven.project.build.model.ModelAndFile;
|
||||
import org.apache.maven.project.build.model.DefaultModelLineageBuilder;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public privileged aspect ProjectIOErrorReporterAspect
|
||||
extends AbstractProjectErrorReporterAspect
|
||||
{
|
||||
|
||||
private pointcut pbldr_readModel( String projectId, File pomFile ):
|
||||
execution( Model DefaultMavenProjectBuilder.readModel( String, File, boolean ) )
|
||||
&& args( projectId, pomFile, * );
|
||||
|
||||
private pointcut within_pbldr_readModel( String projectId, File pomFile ):
|
||||
within( DefaultMavenProjectBuilder )
|
||||
&& cflow( pbldr_readModel( projectId, pomFile ) )
|
||||
&& !cflowbelow( pbldr_readModel( String, File ) )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultMavenProjectBuilder.buildFromRepository(..)
|
||||
// --> DefaultMavenProjectBuilder.findModelFromRepository(..) (private)
|
||||
// DefaultMavenProjectBuilder.build(..)
|
||||
// --> DefaultMavenProjectBuilder.buildFromSourceFileInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.readModel(..) (private)
|
||||
// --> thrown XmlPullParserException
|
||||
// <------ InvalidProjectModelException
|
||||
// =========================================================================
|
||||
before( String projectId, File pomFile, XmlPullParserException cause ):
|
||||
within_pbldr_readModel( projectId, pomFile )
|
||||
&& call( ProjectBuildingException.new( .., XmlPullParserException ))
|
||||
&& args( .., cause )
|
||||
{
|
||||
getReporter().reportErrorParsingProjectModel( projectId, pomFile, cause );
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultMavenProjectBuilder.buildFromRepository(..)
|
||||
// --> DefaultMavenProjectBuilder.findModelFromRepository(..) (private)
|
||||
// DefaultMavenProjectBuilder.build(..)
|
||||
// --> DefaultMavenProjectBuilder.buildFromSourceFileInternal(..) (private)
|
||||
// --> DefaultMavenProjectBuilder.readModel(..) (private)
|
||||
// --> thrown IOException
|
||||
// <------ InvalidProjectModelException
|
||||
// =========================================================================
|
||||
before( String projectId, File pomFile, IOException cause ):
|
||||
within_pbldr_readModel( projectId, pomFile )
|
||||
&& call( ProjectBuildingException.new( .., IOException ))
|
||||
&& args( .., cause )
|
||||
{
|
||||
getReporter().reportErrorParsingProjectModel( projectId, pomFile, cause );
|
||||
}
|
||||
|
||||
private pointcut mlbldr_resolveParentPom( ModelAndFile childInfo ):
|
||||
execution( ModelAndFile DefaultModelLineageBuilder.resolveParentPom( ModelAndFile, .. ) )
|
||||
&& args( childInfo, .. );
|
||||
|
||||
private pointcut mlbldr_readModel( File pomFile ):
|
||||
execution( * DefaultModelLineageBuilder.readModel( File ) )
|
||||
&& args( pomFile );
|
||||
|
||||
private pointcut within_mlbldr_readModel( File pomFile ):
|
||||
cflow( mlbldr_readModel( pomFile ) )
|
||||
&& within( DefaultModelLineageBuilder )
|
||||
&& notWithinAspect();
|
||||
|
||||
private pointcut mlbldr_errorParsingParentPom( ModelAndFile childInfo, File parentPomFile, XmlPullParserException cause ):
|
||||
cflowbelow( mlbldr_resolveParentPom( childInfo ) )
|
||||
&& within_mlbldr_readModel( parentPomFile )
|
||||
&& call( ProjectBuildingException.new( .., XmlPullParserException ) )
|
||||
&& args( .., cause );
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultModelLineageBuilder.buildModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.resumeBuildingModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.resolveParentPom(..) (private)
|
||||
// [--> DefaultModelLineageBuilder.resolveParentWithRelativePath(..) (private)
|
||||
// --> DefaultModelLineageBuilder.readModel(..) (private)
|
||||
// --> thrown XmlPullParserException
|
||||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
before( ModelAndFile childInfo, File parentPomFile, XmlPullParserException cause ):
|
||||
mlbldr_errorParsingParentPom( childInfo, parentPomFile, cause )
|
||||
{
|
||||
getReporter().reportErrorParsingParentProjectModel( childInfo, parentPomFile, cause );
|
||||
}
|
||||
|
||||
private pointcut mlbldr_errorReadingParentPom( ModelAndFile childInfo, File parentPomFile, IOException cause ):
|
||||
cflow( mlbldr_resolveParentPom( childInfo ) )
|
||||
&& within_mlbldr_readModel( parentPomFile )
|
||||
&& call( ProjectBuildingException.new( .., IOException ))
|
||||
&& args( .., cause );
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultModelLineageBuilder.buildModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.resumeBuildingModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.resolveParentPom(..) (private)
|
||||
// [--> DefaultModelLineageBuilder.resolveParentWithRelativePath(..) (private)
|
||||
// --> DefaultModelLineageBuilder.readModel(..) (private)
|
||||
// --> thrown XmlPullParserException
|
||||
// <---------- ProjectBuildingException
|
||||
// =========================================================================
|
||||
before( ModelAndFile childInfo, File parentPomFile, IOException cause ):
|
||||
mlbldr_errorReadingParentPom( childInfo, parentPomFile, cause )
|
||||
{
|
||||
getReporter().reportErrorParsingParentProjectModel( childInfo, parentPomFile, cause );
|
||||
}
|
||||
|
||||
private pointcut mlbldr_errorParsingNonParentPom( File pomFile, XmlPullParserException cause ):
|
||||
!cflow( mlbldr_resolveParentPom( ModelAndFile ) )
|
||||
&& cflow( mlbldr_readModel( pomFile ) )
|
||||
&& call( ProjectBuildingException.new( .., XmlPullParserException ))
|
||||
&& args( .., cause )
|
||||
&& within( DefaultModelLineageBuilder )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultModelLineageBuilder.buildModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.readModel(..) (private)
|
||||
// --> thrown XmlPullParserException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
before( File pomFile, XmlPullParserException cause ):
|
||||
mlbldr_errorParsingNonParentPom( pomFile, cause )
|
||||
{
|
||||
getReporter().reportErrorParsingProjectModel( "unknown", pomFile, cause );
|
||||
}
|
||||
|
||||
private pointcut mlbldr_errorReadingNonParentPom( File pomFile, IOException cause ):
|
||||
!cflow( mlbldr_resolveParentPom( ModelAndFile ) )
|
||||
&& cflow( mlbldr_readModel( pomFile ) )
|
||||
&& call( ProjectBuildingException.new( .., IOException ))
|
||||
&& args( .., cause )
|
||||
&& within( DefaultModelLineageBuilder )
|
||||
&& notWithinAspect();
|
||||
|
||||
// =========================================================================
|
||||
// Call Stack:
|
||||
// =========================================================================
|
||||
// ...
|
||||
// --> DefaultModelLineageBuilder.buildModelLineage(..)
|
||||
// --> DefaultModelLineageBuilder.readModel(..) (private)
|
||||
// --> thrown XmlPullParserException
|
||||
// <------ ProjectBuildingException
|
||||
// =========================================================================
|
||||
before( File pomFile, IOException cause ):
|
||||
mlbldr_errorReadingNonParentPom( pomFile, cause )
|
||||
{
|
||||
getReporter().reportErrorParsingProjectModel( "unknown", pomFile, cause );
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package org.apache.maven.project.aspect;
|
||||
|
||||
import org.apache.maven.project.error.ProjectErrorReporter;
|
||||
import org.apache.maven.project.error.DefaultProjectErrorReporter;
|
||||
import org.aspectj.lang.reflect.SourceLocation;
|
||||
|
||||
public privileged aspect ProjectReporterDebugAspect
|
||||
{
|
||||
|
||||
// before( Throwable key, String message, DefaultProjectErrorReporter reporter ):
|
||||
// call( void DefaultProjectErrorReporter.registerBuildError( Throwable, String, .. ) )
|
||||
// && args( key, message, .. )
|
||||
// && target( reporter )
|
||||
// {
|
||||
// SourceLocation location = thisJoinPoint.getSourceLocation();
|
||||
// System.out.println( "Registering: " + key + "\nfrom: " + location.getFileName() + ", line: " + location.getLine() + "\nreporter is: " + reporter + "\n\nMessage:\n\n" + message );
|
||||
// }
|
||||
//
|
||||
// before():
|
||||
// execution( void DefaultProjectErrorReporter.clearErrors() )
|
||||
// {
|
||||
// System.out.println( "WARNING: CLEARING ALL ERROR REPORTS." );
|
||||
// }
|
||||
//
|
||||
// after() returning( Throwable key ):
|
||||
// execution( Throwable ProjectErrorReporter+.findReportedException( Throwable ) )
|
||||
// {
|
||||
// if ( key != null )
|
||||
// {
|
||||
// System.out.println( "Found reported exception: " + key );
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
package org.apache.maven.project.aspect.compat;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.project.build.model.ModelLineage;
|
||||
import org.apache.maven.project.build.model.ModelLineageIterator;
|
||||
import org.apache.maven.project.build.model.ModelLineageBuilder;
|
||||
import org.apache.maven.project.DefaultMavenProjectBuilder;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.profiles.build.DefaultProfileAdvisor;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
public privileged aspect Maven20xProjectCompatAspect
|
||||
{
|
||||
|
||||
// FIXME: Re-enable this when we're closer to a 2.1 release.
|
||||
// private pointcut reactorProjectBuilds():
|
||||
// cflow( execution( * DefaultMavenProjectBuilder.buildFromSourceFileInternal( .. ) ) )
|
||||
// && !cflow( execution( * MavenMetadataSource.*( .. ) ) );
|
||||
//
|
||||
// private pointcut lineageBuildResumed( DefaultMavenProjectBuilder projectBuilder, ModelLineage lineage ):
|
||||
// call( * ModelLineageBuilder.resumeBuildingModelLineage( ModelLineage, .. ) )
|
||||
// && this( projectBuilder )
|
||||
// && args( lineage, .. );
|
||||
//
|
||||
// after( DefaultMavenProjectBuilder projectBuilder, ModelLineage lineage ):
|
||||
// reactorProjectBuilds()
|
||||
// && lineageBuildResumed( projectBuilder, lineage )
|
||||
// {
|
||||
// for ( ModelLineageIterator it = lineage.lineageIterator(); it.hasNext(); )
|
||||
// {
|
||||
// Model model = (Model) it.next();
|
||||
// List pluginRepos = model.getPluginRepositories();
|
||||
//
|
||||
// if ( pluginRepos != null && !pluginRepos.isEmpty() )
|
||||
// {
|
||||
// StringBuffer message = new StringBuffer();
|
||||
// message.append( "The <pluginRepositories/> section of the POM has been deprecated. Please update your POM (" );
|
||||
// message.append( model.getId() );
|
||||
// message.append( ")." );
|
||||
//
|
||||
// projectBuilder.logger.warn( message.toString() );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private pointcut externalProfilesApplied( DefaultProfileAdvisor advisor, ProfileManager profileManager ):
|
||||
// execution( * DefaultProfileAdvisor.applyActivatedExternalProfiles( .., ProfileManager+ ) )
|
||||
// && this( advisor )
|
||||
// && args( .., profileManager );
|
||||
//
|
||||
//
|
||||
// private boolean settingsProfilesChecked = false;
|
||||
//
|
||||
// before( DefaultProfileAdvisor advisor, ProfileManager profileManager ):
|
||||
// reactorProjectBuilds()
|
||||
// && externalProfilesApplied( advisor, profileManager )
|
||||
// {
|
||||
// if ( profileManager == null )
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Map profilesById = profileManager.getProfilesById();
|
||||
// Set invalidProfiles = new HashSet();
|
||||
//
|
||||
// boolean settingsProfilesEncountered = false;
|
||||
// for ( Iterator it = profilesById.values().iterator(); it.hasNext(); )
|
||||
// {
|
||||
// Profile profile = (Profile) it.next();
|
||||
//
|
||||
// if ( "settings.xml".equals( profile.getSource() ) )
|
||||
// {
|
||||
// settingsProfilesEncountered = true;
|
||||
//
|
||||
// if ( settingsProfilesChecked )
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List pluginRepos = profile.getPluginRepositories();
|
||||
// if ( pluginRepos != null && !pluginRepos.isEmpty() )
|
||||
// {
|
||||
// invalidProfiles.add( profile );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if ( !invalidProfiles.isEmpty() )
|
||||
// {
|
||||
// StringBuffer message = new StringBuffer();
|
||||
// message.append( "The <pluginRepositories/> section of the POM has been deprecated. Please update the following profiles:\n" );
|
||||
//
|
||||
// for ( Iterator it = invalidProfiles.iterator(); it.hasNext(); )
|
||||
// {
|
||||
// Profile profile = (Profile) it.next();
|
||||
// message.append( "\n- " ).append( profile.getId() ).append( " (source: " ).append( profile.getSource() ).append( ")" );
|
||||
// }
|
||||
//
|
||||
// message.append( "\n" );
|
||||
//
|
||||
// advisor.logger.warn( message.toString() );
|
||||
// }
|
||||
//
|
||||
// settingsProfilesChecked = settingsProfilesChecked || settingsProfilesEncountered;
|
||||
// }
|
||||
|
||||
}
|
|
@ -32,7 +32,9 @@
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/** @author Jason van Zyl */
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
*/
|
||||
public class DefaultMavenTools
|
||||
implements MavenTools
|
||||
{
|
||||
|
@ -94,7 +96,8 @@ public ArtifactRepository buildArtifactRepository( Repository repo )
|
|||
|
||||
if ( url == null || url.trim().length() < 1 )
|
||||
{
|
||||
throw new MissingRepositoryElementException( "Repository URL must not be empty (ID is: " + id + ").", id );
|
||||
throw new MissingRepositoryElementException( "Repository URL must not be empty (ID is: " + id + ").",
|
||||
id );
|
||||
}
|
||||
|
||||
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
|
||||
|
|
|
@ -54,7 +54,6 @@ public class DefaultProfileManager
|
|||
/**
|
||||
* the properties passed to the profile manager are the props that
|
||||
* are passed to maven, possibly containing profile activator properties
|
||||
*
|
||||
*/
|
||||
public DefaultProfileManager( PlexusContainer container, ProfileActivationContext profileActivationContext )
|
||||
{
|
||||
|
@ -185,7 +184,7 @@ public void explicitlyDeactivate( List profileIds )
|
|||
public List getActiveProfiles()
|
||||
throws ProfileActivationException
|
||||
{
|
||||
return getActiveProfiles( null );
|
||||
return getActiveProfiles( null );
|
||||
}
|
||||
|
||||
public List getActiveProfiles( Model model )
|
||||
|
@ -198,7 +197,8 @@ public List getActiveProfiles( Model model )
|
|||
|
||||
if ( ( model != null ) && ( realmManager != null ) )
|
||||
{
|
||||
projectRealm = realmManager.getProjectRealm( ModelUtils.getGroupId( model ), model.getArtifactId(), ModelUtils.getVersion( model ) );
|
||||
projectRealm = realmManager.getProjectRealm( ModelUtils.getGroupId( model ), model.getArtifactId(),
|
||||
ModelUtils.getVersion( model ) );
|
||||
oldLookupRealm = container.setLookupRealm( projectRealm );
|
||||
}
|
||||
|
||||
|
@ -241,18 +241,18 @@ else if ( isActive( profile, profileActivationContext ) )
|
|||
{
|
||||
List defaultIds = profileActivationContext.getActiveByDefaultProfileIds();
|
||||
|
||||
List deactivatedIds = profileActivationContext.getExplicitlyInactiveProfileIds();
|
||||
List deactivatedIds = profileActivationContext.getExplicitlyInactiveProfileIds();
|
||||
|
||||
for ( Iterator it = defaultIds.iterator(); it.hasNext(); )
|
||||
{
|
||||
String profileId = (String) it.next();
|
||||
|
||||
// If this profile was excluded, don't add it back in
|
||||
// Fixes MNG-3545
|
||||
if (deactivatedIds.contains(profileId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// If this profile was excluded, don't add it back in
|
||||
// Fixes MNG-3545
|
||||
if ( deactivatedIds.contains( profileId ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Profile profile = (Profile) profilesById.get( profileId );
|
||||
|
||||
if ( profile != null )
|
||||
|
@ -295,7 +295,8 @@ private boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
{
|
||||
if ( activator.isActive( profile, context ) )
|
||||
{
|
||||
container.getLogger().debug( "Profile: " + profile.getId() + " is active. (source: " + profile.getSource() + ")" );
|
||||
container.getLogger().debug(
|
||||
"Profile: " + profile.getId() + " is active. (source: " + profile.getSource() + ")" );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -309,7 +310,7 @@ private boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
}
|
||||
finally
|
||||
{
|
||||
container.getContext().put("SystemProperties", null);
|
||||
container.getContext().put( "SystemProperties", null );
|
||||
if ( activators != null )
|
||||
{
|
||||
try
|
||||
|
|
|
@ -90,8 +90,9 @@ private ProfileActivator loadProfileActivator( ActivationCustom custom, ProfileA
|
|||
{
|
||||
if ( !context.isCustomActivatorFailureSuppressed() )
|
||||
{
|
||||
throw new ProfileActivationException( "Cannot find custom ProfileActivator: " + type
|
||||
+ ". \nPerhaps you're missing a build extension?", e );
|
||||
throw new ProfileActivationException(
|
||||
"Cannot find custom ProfileActivator: " + type + ". \nPerhaps you're missing a build extension?",
|
||||
e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,8 +108,7 @@ private ProfileActivator loadProfileActivator( ActivationCustom custom, ProfileA
|
|||
{
|
||||
if ( !context.isCustomActivatorFailureSuppressed() )
|
||||
{
|
||||
throw new ProfileActivationException( "Failed to configure custom ProfileActivator: " + type
|
||||
+ ".", e );
|
||||
throw new ProfileActivationException( "Failed to configure custom ProfileActivator: " + type + ".", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
package org.apache.maven.profiles.activation;
|
||||
|
||||
/*
|
||||
* 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.realm.MavenRealmManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -12,13 +31,19 @@ public class DefaultProfileActivationContext
|
|||
{
|
||||
|
||||
private boolean isCustomActivatorFailureSuppressed;
|
||||
|
||||
private final Properties executionProperties;
|
||||
|
||||
List explicitlyActive;
|
||||
|
||||
List explicitlyInactive;
|
||||
|
||||
private final MavenRealmManager realmManager;
|
||||
|
||||
private List activeByDefault;
|
||||
|
||||
public DefaultProfileActivationContext( MavenRealmManager realmManager, Properties executionProperties, boolean isCustomActivatorFailureSuppressed )
|
||||
public DefaultProfileActivationContext( MavenRealmManager realmManager, Properties executionProperties,
|
||||
boolean isCustomActivatorFailureSuppressed )
|
||||
{
|
||||
this.realmManager = realmManager;
|
||||
this.executionProperties = executionProperties;
|
||||
|
|
|
@ -76,11 +76,13 @@ public boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
{
|
||||
if ( logger.isDebugEnabled() )
|
||||
{
|
||||
logger.debug( "Failed to interpolate exists file location for profile activator: " + fileString, e );
|
||||
logger.debug( "Failed to interpolate exists file location for profile activator: " + fileString,
|
||||
e );
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn( "Failed to interpolate exists file location for profile activator: " + fileString + ". Run in debug mode (-X) for more information." );
|
||||
logger.warn( "Failed to interpolate exists file location for profile activator: " + fileString +
|
||||
". Run in debug mode (-X) for more information." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +90,8 @@ public boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
|
||||
if ( logger != null )
|
||||
{
|
||||
logger.debug( "FileProfileActivator: Checking file existence for: " + fileString + ". Result: " + result );
|
||||
logger.debug(
|
||||
"FileProfileActivator: Checking file existence for: " + fileString + ". Result: " + result );
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -107,11 +110,13 @@ public boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
{
|
||||
if ( logger.isDebugEnabled() )
|
||||
{
|
||||
logger.debug( "Failed to interpolate missing file location for profile activator: " + fileString, e );
|
||||
logger.debug(
|
||||
"Failed to interpolate missing file location for profile activator: " + fileString, e );
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn( "Failed to interpolate missing file location for profile activator: " + fileString + ". Run in debug mode (-X) for more information." );
|
||||
logger.warn( "Failed to interpolate missing file location for profile activator: " +
|
||||
fileString + ". Run in debug mode (-X) for more information." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +124,8 @@ public boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
|
||||
if ( logger != null )
|
||||
{
|
||||
logger.debug( "FileProfileActivator: Checking file is missing for: " + fileString + ". Result: " + result );
|
||||
logger.debug(
|
||||
"FileProfileActivator: Checking file is missing for: " + fileString + ". Result: " + result );
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -43,7 +43,8 @@ public boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
String javaVersion = props.getProperty( JDK_VERSION );
|
||||
if ( javaVersion == null )
|
||||
{
|
||||
getLogger().warn( "Cannot locate java version property: " + JDK_VERSION + ". NOT enabling profile: " + profile.getId() );
|
||||
getLogger().warn(
|
||||
"Cannot locate java version property: " + JDK_VERSION + ". NOT enabling profile: " + profile.getId() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -100,7 +101,8 @@ private static void parseNum( List pList, StringBuffer pBuffer )
|
|||
}
|
||||
}
|
||||
|
||||
/** This method transforms a string like "1.5.0_06" into
|
||||
/**
|
||||
* This method transforms a string like "1.5.0_06" into
|
||||
* new int[]{1, 5, 0, 6}.
|
||||
*/
|
||||
private static int[] asIntArray( String pVersion )
|
||||
|
@ -129,7 +131,8 @@ private static int[] asIntArray( String pVersion )
|
|||
return result;
|
||||
}
|
||||
|
||||
/** This method compares to integer arrays, as created
|
||||
/**
|
||||
* This method compares to integer arrays, as created
|
||||
* by {@link #asIntArray(String)}.
|
||||
*/
|
||||
private static int compareTo( int[] pVersion1, int[] pVersion2 )
|
||||
|
|
|
@ -62,7 +62,8 @@ public boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
|
||||
private boolean ensureAtLeastOneNonNull( ActivationOS os )
|
||||
{
|
||||
return ( os.getArch() != null ) || ( os.getFamily() != null ) || ( os.getName() != null ) || ( os.getVersion() != null );
|
||||
return ( os.getArch() != null ) || ( os.getFamily() != null ) || ( os.getName() != null ) ||
|
||||
( os.getVersion() != null );
|
||||
}
|
||||
|
||||
private boolean determineVersionMatch( String version )
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
package org.apache.maven.profiles.activation;
|
||||
|
||||
/*
|
||||
* 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.realm.MavenRealmManager;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -25,8 +25,10 @@ public interface ProfileActivator
|
|||
{
|
||||
static final String ROLE = ProfileActivator.class.getName();
|
||||
|
||||
boolean canDetermineActivation( Profile profile, ProfileActivationContext context ) throws ProfileActivationException;
|
||||
boolean canDetermineActivation( Profile profile, ProfileActivationContext context )
|
||||
throws ProfileActivationException;
|
||||
|
||||
boolean isActive( Profile profile, ProfileActivationContext context ) throws ProfileActivationException;
|
||||
boolean isActive( Profile profile, ProfileActivationContext context )
|
||||
throws ProfileActivationException;
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public boolean isActive( Profile profile, ProfileActivationContext context )
|
|||
String name = property.getName();
|
||||
boolean reverseName = false;
|
||||
|
||||
if ( name.startsWith("!") )
|
||||
if ( name.startsWith( "!" ) )
|
||||
{
|
||||
reverseName = true;
|
||||
name = name.substring( 1 );
|
||||
|
|
|
@ -67,25 +67,18 @@ public class DefaultProfileAdvisor
|
|||
|
||||
private Logger logger;
|
||||
|
||||
public List applyActivatedProfiles( Model model,
|
||||
File pomFile,
|
||||
boolean useProfilesXml,
|
||||
public List applyActivatedProfiles( Model model, File pomFile, boolean useProfilesXml,
|
||||
ProfileActivationContext activationContext )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
// logger.debug( "Building profile manager for model: " + model.getId() + " with pom file: "
|
||||
// + pomFile );
|
||||
ProfileManager profileManager = buildProfileManager( model,
|
||||
pomFile,
|
||||
useProfilesXml,
|
||||
activationContext );
|
||||
ProfileManager profileManager = buildProfileManager( model, pomFile, useProfilesXml, activationContext );
|
||||
|
||||
return applyActivatedProfiles( model, pomFile, profileManager );
|
||||
}
|
||||
|
||||
public List applyActivatedExternalProfiles( Model model,
|
||||
File projectDir,
|
||||
ProfileManager externalProfileManager )
|
||||
public List applyActivatedExternalProfiles( Model model, File projectDir, ProfileManager externalProfileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( externalProfileManager == null )
|
||||
|
@ -99,9 +92,7 @@ public List applyActivatedExternalProfiles( Model model,
|
|||
return applyActivatedProfiles( model, projectDir, externalProfileManager );
|
||||
}
|
||||
|
||||
private List applyActivatedProfiles( Model model,
|
||||
File pomFile,
|
||||
ProfileManager profileManager )
|
||||
private List applyActivatedProfiles( Model model, File pomFile, ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
List activeProfiles;
|
||||
|
@ -146,9 +137,7 @@ private List applyActivatedProfiles( Model model,
|
|||
return activeProfiles;
|
||||
}
|
||||
|
||||
private ProfileManager buildProfileManager( Model model,
|
||||
File pomFile,
|
||||
boolean useProfilesXml,
|
||||
private ProfileManager buildProfileManager( Model model, File pomFile, boolean useProfilesXml,
|
||||
ProfileActivationContext profileActivationContext )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
@ -164,8 +153,7 @@ private ProfileManager buildProfileManager( Model model,
|
|||
return profileManager;
|
||||
}
|
||||
|
||||
public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model,
|
||||
File pomFile,
|
||||
public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File pomFile,
|
||||
ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
@ -183,8 +171,7 @@ public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model,
|
|||
}
|
||||
catch ( ProfileActivationException e )
|
||||
{
|
||||
throw new ProjectBuildingException(
|
||||
model.getId(),
|
||||
throw new ProjectBuildingException( model.getId(),
|
||||
"Failed to compute active profiles for repository aggregation.",
|
||||
pomFile, e );
|
||||
}
|
||||
|
@ -196,7 +183,8 @@ public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model,
|
|||
Profile externalProfile = (Profile) i.next();
|
||||
if ( externalProfile.getRepositories() != null )
|
||||
{
|
||||
for ( Iterator repoIterator = externalProfile.getRepositories().iterator(); repoIterator.hasNext(); )
|
||||
for ( Iterator repoIterator = externalProfile.getRepositories().iterator();
|
||||
repoIterator.hasNext(); )
|
||||
{
|
||||
Repository mavenRepo = (Repository) repoIterator.next();
|
||||
|
||||
|
@ -219,23 +207,16 @@ public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model,
|
|||
}
|
||||
}
|
||||
|
||||
public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model,
|
||||
File pomFile,
|
||||
boolean useProfilesXml,
|
||||
public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File pomFile, boolean useProfilesXml,
|
||||
ProfileActivationContext activationContext )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
ProfileManager profileManager = buildProfileManager( model,
|
||||
pomFile,
|
||||
useProfilesXml,
|
||||
activationContext );
|
||||
ProfileManager profileManager = buildProfileManager( model, pomFile, useProfilesXml, activationContext );
|
||||
|
||||
return getArtifactRepositoriesFromActiveProfiles( model, pomFile, profileManager );
|
||||
}
|
||||
|
||||
private void loadExternalProjectProfiles( ProfileManager profileManager,
|
||||
Model model,
|
||||
File pomFile )
|
||||
private void loadExternalProjectProfiles( ProfileManager profileManager, Model model, File pomFile )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( pomFile != null )
|
||||
|
@ -268,14 +249,14 @@ private void loadExternalProjectProfiles( ProfileManager profileManager,
|
|||
catch ( IOException e )
|
||||
{
|
||||
throw new ProjectBuildingException( model.getId(),
|
||||
"Cannot read profiles.xml resource from directory: "
|
||||
+ projectDir, pomFile, e );
|
||||
"Cannot read profiles.xml resource from directory: " + projectDir,
|
||||
pomFile, e );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new ProjectBuildingException( model.getId(),
|
||||
"Cannot parse profiles.xml resource from directory: "
|
||||
+ projectDir, pomFile, e );
|
||||
"Cannot parse profiles.xml resource from directory: " + projectDir,
|
||||
pomFile, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,35 +29,25 @@
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jdcasey
|
||||
*
|
||||
*/
|
||||
public interface ProfileAdvisor
|
||||
{
|
||||
|
||||
String ROLE = ProfileAdvisor.class.getName();
|
||||
|
||||
LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model,
|
||||
File pomFile,
|
||||
ProfileManager profileManager )
|
||||
LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File pomFile, ProfileManager profileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model,
|
||||
File pomFile,
|
||||
boolean useProfilesXml,
|
||||
LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File pomFile, boolean useProfilesXml,
|
||||
ProfileActivationContext profileActivationContext )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
List applyActivatedProfiles( Model model,
|
||||
File pomFile,
|
||||
boolean useProfilesXml,
|
||||
List applyActivatedProfiles( Model model, File pomFile, boolean useProfilesXml,
|
||||
ProfileActivationContext activationContext )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
List applyActivatedExternalProfiles( Model model,
|
||||
File pomFile,
|
||||
ProfileManager externalProfileManager )
|
||||
List applyActivatedExternalProfiles( Model model, File pomFile, ProfileManager externalProfileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
}
|
||||
|
|
|
@ -49,11 +49,11 @@
|
|||
/**
|
||||
* Inject profile data into a Model, using the profile as the dominant data source, and
|
||||
* persisting results of the injection in the Model.
|
||||
*
|
||||
* <p/>
|
||||
* This will look similar to the ModelUtils/DefaultModelInheritanceAssembler code, but
|
||||
* they are distinct. In model inheritance, the child provides data dominance AND persists
|
||||
* the results of the merge...sort of a 'merge-out' system.
|
||||
*
|
||||
* <p/>
|
||||
* In this system, the profile is dominant, but the model receives the merge result...sort
|
||||
* of a 'merge-in' system. The two pieces of code look like they could be combined with a
|
||||
* set of flags to determine which direction to merge 'to', but there are enough differences
|
||||
|
@ -142,15 +142,15 @@ private void injectBuild( Profile profile, Model model )
|
|||
|
||||
/**
|
||||
* This should be the resulting ordering of plugins after injection:
|
||||
*
|
||||
* <p/>
|
||||
* Given:
|
||||
*
|
||||
* model: X -> A -> B -> D -> E
|
||||
* profile: Y -> A -> C -> D -> F
|
||||
*
|
||||
* <p/>
|
||||
* model: X -> A -> B -> D -> E
|
||||
* profile: Y -> A -> C -> D -> F
|
||||
* <p/>
|
||||
* Result:
|
||||
*
|
||||
* X -> Y -> A -> B -> C -> D -> E -> F
|
||||
* <p/>
|
||||
* X -> Y -> A -> B -> C -> D -> E -> F
|
||||
*/
|
||||
protected void injectPlugins( PluginContainer profileContainer, PluginContainer modelContainer )
|
||||
{
|
||||
|
@ -214,7 +214,8 @@ private void injectPluginDefinition( Plugin profilePlugin, Plugin modelPlugin )
|
|||
modelPlugin.setVersion( profilePlugin.getVersion() );
|
||||
}
|
||||
|
||||
modelPlugin.setDependencies( injectDependencies( profilePlugin.getDependencies(), modelPlugin.getDependencies() ) );
|
||||
modelPlugin.setDependencies(
|
||||
injectDependencies( profilePlugin.getDependencies(), modelPlugin.getDependencies() ) );
|
||||
|
||||
// merge the lists of goals that are not attached to an <execution/>
|
||||
injectConfigurationContainer( profilePlugin, modelPlugin );
|
||||
|
@ -297,13 +298,13 @@ private void injectPluginDefinition( Plugin profilePlugin, Plugin modelPlugin )
|
|||
|
||||
/**
|
||||
* Merge two DOMs. Copy the dominant DOM so the original one is left unchanged.
|
||||
* <p>
|
||||
* <p/>
|
||||
* Use this method instead of a direct call to {@link Xpp3Dom#mergeXpp3Dom(Xpp3Dom, Xpp3Dom)}.
|
||||
* Profiles are dominant, thus they are merge targets, but they may be merged in several times
|
||||
* (e.g. if they are inherited). So with the second merge, you don't get the profile's original
|
||||
* DOM, but an already merged one.
|
||||
*
|
||||
* @param dominant Dominant DOM
|
||||
* @param dominant Dominant DOM
|
||||
* @param recessive Recessive DOM
|
||||
* @return Merged DOM
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,13 +20,19 @@
|
|||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.DefaultArtifact;
|
||||
import org.apache.maven.artifact.InvalidArtifactRTException;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.project.artifact.AttachedArtifact;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultMavenProjectHelper
|
||||
|
@ -36,7 +42,8 @@ public class DefaultMavenProjectHelper
|
|||
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile )
|
||||
public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier,
|
||||
File artifactFile )
|
||||
{
|
||||
String type = artifactType;
|
||||
|
||||
|
@ -57,7 +64,7 @@ public void attachArtifact( MavenProject project, String artifactType, String ar
|
|||
artifact.setFile( artifactFile );
|
||||
artifact.setResolved( true );
|
||||
|
||||
attachArtifact(project, artifact);
|
||||
attachArtifact( project, artifact );
|
||||
}
|
||||
|
||||
public void attachArtifact( MavenProject project, String artifactType, File artifactFile )
|
||||
|
@ -69,33 +76,34 @@ public void attachArtifact( MavenProject project, String artifactType, File arti
|
|||
artifact.setFile( artifactFile );
|
||||
artifact.setResolved( true );
|
||||
|
||||
attachArtifact(project, artifact);
|
||||
attachArtifact( project, artifact );
|
||||
}
|
||||
|
||||
public void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier )
|
||||
{
|
||||
Artifact projectArtifact = project.getArtifact();
|
||||
|
||||
Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier, projectArtifact.getArtifactHandler() );
|
||||
Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier,
|
||||
projectArtifact.getArtifactHandler() );
|
||||
|
||||
artifact.setFile( artifactFile );
|
||||
artifact.setResolved( true );
|
||||
|
||||
attachArtifact(project, artifact);
|
||||
attachArtifact( project, artifact );
|
||||
}
|
||||
|
||||
public void attachArtifact(MavenProject project, Artifact artifact)
|
||||
public void attachArtifact( MavenProject project, Artifact artifact )
|
||||
{
|
||||
try
|
||||
{
|
||||
project.addAttachedArtifact( artifact );
|
||||
project.addAttachedArtifact( artifact );
|
||||
}
|
||||
catch (DuplicateArtifactAttachmentException dae)
|
||||
catch ( DuplicateArtifactAttachmentException dae )
|
||||
{
|
||||
getLogger().warn(dae.getMessage());
|
||||
getLogger().warn( dae.getMessage() );
|
||||
|
||||
// We can throw this because it's unchecked, and won't change the MavenProjectHelper API, which would break backward compat if it did.
|
||||
throw dae;
|
||||
// We can throw this because it's unchecked, and won't change the MavenProjectHelper API, which would break backward compat if it did.
|
||||
throw dae;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,4 +127,140 @@ public void addTestResource( MavenProject project, String resourceDirectory, Lis
|
|||
project.addTestResource( resource );
|
||||
}
|
||||
|
||||
private static class AttachedArtifact
|
||||
extends DefaultArtifact
|
||||
{
|
||||
|
||||
private final Artifact parent;
|
||||
|
||||
public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler )
|
||||
{
|
||||
super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
|
||||
classifier, artifactHandler, parent.isOptional() );
|
||||
|
||||
setDependencyTrail( Collections.singletonList( parent.getId() ) );
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
if ( getId().equals( parent.getId() ) )
|
||||
{
|
||||
throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(),
|
||||
parent.getType(),
|
||||
"An attached artifact must have a different ID than its corresponding main artifact." );
|
||||
}
|
||||
}
|
||||
|
||||
public AttachedArtifact( Artifact parent, String type, ArtifactHandler artifactHandler )
|
||||
{
|
||||
this( parent, type, null, artifactHandler );
|
||||
}
|
||||
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public List getAvailableVersions()
|
||||
{
|
||||
return parent.getAvailableVersions();
|
||||
}
|
||||
|
||||
public void setAvailableVersions( List availableVersions )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getBaseVersion()
|
||||
{
|
||||
return parent.getBaseVersion();
|
||||
}
|
||||
|
||||
public void setBaseVersion( String baseVersion )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getDownloadUrl()
|
||||
{
|
||||
return parent.getDownloadUrl();
|
||||
}
|
||||
|
||||
public void setDownloadUrl( String downloadUrl )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public ArtifactRepository getRepository()
|
||||
{
|
||||
return parent.getRepository();
|
||||
}
|
||||
|
||||
public void setRepository( ArtifactRepository repository )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getScope()
|
||||
{
|
||||
return parent.getScope();
|
||||
}
|
||||
|
||||
public void setScope( String scope )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return parent.getVersion();
|
||||
}
|
||||
|
||||
public void setVersion( String version )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public VersionRange getVersionRange()
|
||||
{
|
||||
return parent.getVersionRange();
|
||||
}
|
||||
|
||||
public void setVersionRange( VersionRange range )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public boolean isRelease()
|
||||
{
|
||||
return parent.isRelease();
|
||||
}
|
||||
|
||||
public void setRelease( boolean release )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public boolean isSnapshot()
|
||||
{
|
||||
return parent.isSnapshot();
|
||||
}
|
||||
|
||||
public void addMetadata( ArtifactMetadata metadata )
|
||||
{
|
||||
// ignore. The parent artifact will handle metadata.
|
||||
// we must fail silently here to avoid problems with the artifact transformers.
|
||||
}
|
||||
|
||||
public Collection getMetadataList()
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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.repository.ArtifactRepository;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
|
||||
|
|
|
@ -0,0 +1,405 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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.MavenTools;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactStatus;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationContext;
|
||||
import org.apache.maven.profiles.build.ProfileAdvisor;
|
||||
import org.codehaus.plexus.logging.LogEnabled;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
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.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This is a temporary class. These methods are originally from the DefaultMavenProjectHelper. This class will be
|
||||
* eliminated when Mercury is integrated.
|
||||
*/
|
||||
public class DefaultRepositoryHelper
|
||||
implements RepositoryHelper, Initializable, LogEnabled
|
||||
{
|
||||
|
||||
private Logger logger;
|
||||
|
||||
public static final String MAVEN_MODEL_VERSION = "4.0.0";
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
private ArtifactResolver artifactResolver;
|
||||
|
||||
private MavenTools mavenTools;
|
||||
|
||||
private ProfileAdvisor profileAdvisor;
|
||||
|
||||
private MavenXpp3Reader modelReader;
|
||||
|
||||
private Logger getLogger()
|
||||
{
|
||||
return logger;
|
||||
}
|
||||
|
||||
public Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
||||
String projectId = safeVersionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
|
||||
remoteArtifactRepositories = normalizeToArtifactRepositories( remoteArtifactRepositories, projectId );
|
||||
|
||||
Artifact projectArtifact;
|
||||
|
||||
// if the artifact is not a POM, we need to construct a POM artifact based on the artifact parameter given.
|
||||
if ( "pom".equals( artifact.getType() ) )
|
||||
{
|
||||
projectArtifact = artifact;
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().warn( "Attempting to build MavenProject instance for Artifact (" + artifact.getGroupId() + ":" +
|
||||
artifact.getArtifactId() + ":" + artifact.getVersion() + ") of type: " + artifact.getType() +
|
||||
"; constructing POM artifact instead." );
|
||||
|
||||
projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
|
||||
artifact.getVersion(), artifact.getScope() );
|
||||
}
|
||||
|
||||
Model legacy_model;
|
||||
try
|
||||
{
|
||||
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
|
||||
|
||||
File file = projectArtifact.getFile();
|
||||
artifact.setFile( file );
|
||||
legacy_model = readModelLegacy( projectId, file, false );
|
||||
|
||||
String downloadUrl = null;
|
||||
|
||||
ArtifactStatus status = ArtifactStatus.NONE;
|
||||
|
||||
DistributionManagement distributionManagement = legacy_model.getDistributionManagement();
|
||||
|
||||
if ( distributionManagement != null )
|
||||
{
|
||||
downloadUrl = distributionManagement.getDownloadUrl();
|
||||
|
||||
status = ArtifactStatus.valueOf( distributionManagement.getStatus() );
|
||||
}
|
||||
|
||||
checkStatusAndUpdate( projectArtifact, status, file, remoteArtifactRepositories, localRepository );
|
||||
|
||||
// TODO: this is gross. Would like to give it the whole model, but maven-artifact shouldn't depend on that
|
||||
// Can a maven-core implementation of the Artifact interface store it, and be used in the exceptions?
|
||||
if ( downloadUrl != null )
|
||||
{
|
||||
projectArtifact.setDownloadUrl( downloadUrl );
|
||||
}
|
||||
else
|
||||
{
|
||||
projectArtifact.setDownloadUrl( legacy_model.getUrl() );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new ProjectBuildingException( projectId, "Error getting POM for '" + projectId +
|
||||
"' from the repository: " + e.getMessage(), e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new ProjectBuildingException( projectId,
|
||||
"POM '" + projectId + "' not found in repository: " + e.getMessage(),
|
||||
e );
|
||||
}
|
||||
|
||||
return legacy_model;
|
||||
}
|
||||
|
||||
public List buildArtifactRepositories( Model model )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
try
|
||||
{
|
||||
return mavenTools.buildArtifactRepositories( model.getRepositories() );
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||
|
||||
throw new ProjectBuildingException( projectId, e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Order is:
|
||||
*
|
||||
* 1. model profile repositories
|
||||
* 2. model repositories
|
||||
* 3. superModel profile repositories
|
||||
* 4. superModel repositories
|
||||
* 5. parentSearchRepositories
|
||||
*/
|
||||
public LinkedHashSet collectInitialRepositories( Model model, Model superModel, List parentSearchRepositories,
|
||||
File pomFile, boolean validProfilesXmlLocation,
|
||||
ProfileActivationContext profileActivationContext )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
LinkedHashSet collected = new LinkedHashSet();
|
||||
|
||||
collectInitialRepositoriesFromModel( collected, model, pomFile, validProfilesXmlLocation,
|
||||
profileActivationContext );
|
||||
|
||||
collectInitialRepositoriesFromModel( collected, superModel, null, validProfilesXmlLocation,
|
||||
profileActivationContext );
|
||||
|
||||
if ( ( parentSearchRepositories != null ) && !parentSearchRepositories.isEmpty() )
|
||||
{
|
||||
collected.addAll( parentSearchRepositories );
|
||||
}
|
||||
|
||||
return collected;
|
||||
}
|
||||
|
||||
private List normalizeToArtifactRepositories( List remoteArtifactRepositories, String projectId )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
List normalized = new ArrayList( remoteArtifactRepositories.size() );
|
||||
|
||||
boolean normalizationNeeded = false;
|
||||
for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
|
||||
{
|
||||
Object item = it.next();
|
||||
|
||||
if ( item instanceof ArtifactRepository )
|
||||
{
|
||||
normalized.add( item );
|
||||
}
|
||||
else if ( item instanceof Repository )
|
||||
{
|
||||
Repository repo = (Repository) item;
|
||||
try
|
||||
{
|
||||
item = mavenTools.buildArtifactRepository( repo );
|
||||
|
||||
normalized.add( item );
|
||||
normalizationNeeded = true;
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
throw new ProjectBuildingException( projectId,
|
||||
"Error building artifact repository for id: " + repo.getId(),
|
||||
e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ProjectBuildingException( projectId,
|
||||
"Error building artifact repository from non-repository information item: " +
|
||||
item );
|
||||
}
|
||||
}
|
||||
|
||||
if ( normalizationNeeded )
|
||||
{
|
||||
return normalized;
|
||||
}
|
||||
else
|
||||
{
|
||||
return remoteArtifactRepositories;
|
||||
}
|
||||
}
|
||||
|
||||
private String safeVersionlessKey( String groupId, String artifactId )
|
||||
{
|
||||
String gid = groupId;
|
||||
|
||||
if ( StringUtils.isEmpty( gid ) )
|
||||
{
|
||||
gid = "unknown";
|
||||
}
|
||||
|
||||
String aid = artifactId;
|
||||
|
||||
if ( StringUtils.isEmpty( aid ) )
|
||||
{
|
||||
aid = "unknown";
|
||||
}
|
||||
|
||||
return ArtifactUtils.versionlessKey( gid, aid );
|
||||
}
|
||||
|
||||
private void checkModelVersion( String modelSource, String projectId, File file )
|
||||
throws InvalidProjectModelException
|
||||
{
|
||||
if ( modelSource.indexOf( "<modelVersion>4.0.0" ) < 0 )
|
||||
{
|
||||
throw new InvalidProjectModelException( projectId, "Not a v" + MAVEN_MODEL_VERSION + " POM.", file );
|
||||
}
|
||||
}
|
||||
|
||||
private Model readModelLegacy( String projectId, File file, boolean strict )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Reader reader = null;
|
||||
try
|
||||
{
|
||||
reader = ReaderFactory.newXmlReader( file );
|
||||
|
||||
String modelSource = IOUtil.toString( reader );
|
||||
|
||||
checkModelVersion( modelSource, projectId, file );
|
||||
|
||||
StringReader sReader = new StringReader( modelSource );
|
||||
|
||||
try
|
||||
{
|
||||
return new MavenXpp3Reader().read( sReader, strict );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new InvalidProjectModelException( projectId, "Parse error reading POM. Reason: " + e.getMessage(),
|
||||
file, e );
|
||||
}
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
throw new ProjectBuildingException( projectId,
|
||||
"Could not find the model file '" + file.getAbsolutePath() + "'.", file,
|
||||
e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ProjectBuildingException( projectId, "Failed to build model from file '" +
|
||||
file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", file, e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( reader );
|
||||
}
|
||||
}
|
||||
|
||||
private void collectInitialRepositoriesFromModel( LinkedHashSet collected, Model model, File pomFile,
|
||||
boolean validProfilesXmlLocation,
|
||||
ProfileActivationContext profileActivationContext )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
||||
Set reposFromProfiles = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model, pomFile,
|
||||
validProfilesXmlLocation,
|
||||
profileActivationContext );
|
||||
|
||||
if ( ( reposFromProfiles != null ) && !reposFromProfiles.isEmpty() )
|
||||
{
|
||||
collected.addAll( reposFromProfiles );
|
||||
}
|
||||
|
||||
List modelRepos = model.getRepositories();
|
||||
|
||||
if ( ( modelRepos != null ) && !modelRepos.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
collected.addAll( mavenTools.buildArtifactRepositories( modelRepos ) );
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
throw new ProjectBuildingException( safeVersionlessKey( model.getGroupId(), model.getArtifactId() ),
|
||||
"Failed to construct ArtifactRepository instances for repositories declared in: " +
|
||||
model.getId(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkStatusAndUpdate( Artifact projectArtifact, ArtifactStatus status, File file,
|
||||
List remoteArtifactRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactNotFoundException
|
||||
{
|
||||
// TODO: configurable actions dependant on status
|
||||
if ( !projectArtifact.isSnapshot() && ( status.compareTo( ArtifactStatus.DEPLOYED ) < 0 ) )
|
||||
{
|
||||
// use default policy (enabled, daily update, warn on bad checksum)
|
||||
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy();
|
||||
// TODO: re-enable [MNG-798/865]
|
||||
policy.setUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER );
|
||||
|
||||
if ( policy.checkOutOfDate( new Date( file.lastModified() ) ) )
|
||||
{
|
||||
getLogger().info(
|
||||
projectArtifact.getArtifactId() + ": updating metadata due to status of '" + status + "'" );
|
||||
try
|
||||
{
|
||||
projectArtifact.setResolved( false );
|
||||
artifactResolver.resolveAlways( projectArtifact, remoteArtifactRepositories, localRepository );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
getLogger().warn( "Error updating POM - using existing version" );
|
||||
getLogger().debug( "Cause", e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
getLogger().warn( "Error updating POM - not found. Removing local copy." );
|
||||
getLogger().debug( "Cause", e );
|
||||
file.delete();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
modelReader = new MavenXpp3Reader();
|
||||
}
|
||||
|
||||
public void enableLogging( Logger logger )
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
}
|
|
@ -27,9 +27,8 @@
|
|||
*
|
||||
* @author pgier
|
||||
* @author jdcasey
|
||||
*
|
||||
* @todo Make this a checked exception, and modify the API of MavenProjectHelper.
|
||||
* Currently, this modification would create compatibility problems for existing plugins.
|
||||
* Currently, this modification would create compatibility problems for existing plugins.
|
||||
*/
|
||||
public class DuplicateArtifactAttachmentException
|
||||
extends RuntimeException
|
||||
|
@ -48,8 +47,7 @@ public DuplicateArtifactAttachmentException( MavenProject project, Artifact arti
|
|||
this.artifact = artifact;
|
||||
}
|
||||
|
||||
private static String constructMessage( MavenProject project,
|
||||
Artifact artifact )
|
||||
private static String constructMessage( MavenProject project, Artifact artifact )
|
||||
{
|
||||
return DEFAULT_MESSAGE + " (project: " + project.getId() + "; illegal attachment: " + artifact.getId() + ")";
|
||||
}
|
||||
|
|
|
@ -55,9 +55,7 @@ public DuplicateProjectException( String message, Exception e )
|
|||
this.conflictingProjectFile = null;
|
||||
}
|
||||
|
||||
public DuplicateProjectException( String projectId,
|
||||
File existingProjectFile,
|
||||
File conflictingProjectFile,
|
||||
public DuplicateProjectException( String projectId, File existingProjectFile, File conflictingProjectFile,
|
||||
String message )
|
||||
{
|
||||
super( message );
|
||||
|
|
|
@ -37,11 +37,11 @@ public InvalidProjectModelException( String projectId, String message, File pomL
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link File} constructor for pomLocation
|
||||
* @param projectId
|
||||
* @param pomLocation absolute path of the pom file
|
||||
* @param pomLocation absolute path of the pom file
|
||||
* @param message
|
||||
* @param validationResult
|
||||
* @deprecated use {@link File} constructor for pomLocation
|
||||
*/
|
||||
public InvalidProjectModelException( String projectId, String pomLocation, String message,
|
||||
ModelValidationResult validationResult )
|
||||
|
@ -58,10 +58,10 @@ public InvalidProjectModelException( String projectId, String message, File pomF
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link File} constructor for pomLocation
|
||||
* @param projectId
|
||||
* @param pomLocation absolute path of the pom file
|
||||
* @param message
|
||||
* @deprecated use {@link File} constructor for pomLocation
|
||||
*/
|
||||
public InvalidProjectModelException( String projectId, String pomLocation, String message )
|
||||
{
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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.versioning.InvalidVersionSpecificationException;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -9,21 +28,22 @@ public class InvalidProjectVersionException
|
|||
{
|
||||
|
||||
private final String locationInPom;
|
||||
|
||||
private final String offendingVersion;
|
||||
|
||||
public InvalidProjectVersionException( String projectId, String locationInPom, String offendingVersion, File pomFile, InvalidVersionSpecificationException cause )
|
||||
public InvalidProjectVersionException( String projectId, String locationInPom, String offendingVersion,
|
||||
File pomFile, InvalidVersionSpecificationException cause )
|
||||
{
|
||||
super( projectId, formatMessage( projectId, locationInPom, offendingVersion, cause ), pomFile, cause );
|
||||
this.locationInPom = locationInPom;
|
||||
this.offendingVersion = offendingVersion;
|
||||
}
|
||||
|
||||
private static String formatMessage( String projectId,
|
||||
String locationInPom,
|
||||
String offendingVersion,
|
||||
private static String formatMessage( String projectId, String locationInPom, String offendingVersion,
|
||||
InvalidVersionSpecificationException cause )
|
||||
{
|
||||
return "Invalid version: " + offendingVersion + " found for: " + locationInPom + " in project: " + projectId + ". Reason: " + cause.getMessage();
|
||||
return "Invalid version: " + offendingVersion + " found for: " + locationInPom + " in project: " + projectId +
|
||||
". Reason: " + cause.getMessage();
|
||||
}
|
||||
|
||||
public String getOffendingVersion()
|
||||
|
|
|
@ -19,13 +19,18 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.MavenTools;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.artifact.versioning.ManagedVersionMap;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.CiManagement;
|
||||
import org.apache.maven.model.Contributor;
|
||||
|
@ -33,11 +38,14 @@
|
|||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.model.Developer;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.IssueManagement;
|
||||
import org.apache.maven.model.License;
|
||||
import org.apache.maven.model.MailingList;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Organization;
|
||||
import org.apache.maven.model.Parent;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.model.PluginManagement;
|
||||
|
@ -51,6 +59,7 @@
|
|||
import org.apache.maven.project.artifact.ActiveProjectArtifact;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -59,7 +68,9 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -153,6 +164,28 @@ public class MavenProject
|
|||
|
||||
private Stack previousExecutionProjects = new Stack();
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
private MavenTools mavenTools;
|
||||
|
||||
private RepositoryHelper repositoryHelper;
|
||||
|
||||
private MavenProjectBuilder mavenProjectBuilder;
|
||||
|
||||
private ProjectBuilderConfiguration projectBuilderConfiguration;
|
||||
|
||||
private File parentFile;
|
||||
|
||||
public File getParentFile()
|
||||
{
|
||||
return parentFile;
|
||||
}
|
||||
|
||||
public void setParentFile( File parentFile )
|
||||
{
|
||||
this.parentFile = parentFile;
|
||||
}
|
||||
|
||||
public MavenProject()
|
||||
{
|
||||
Model model = new Model();
|
||||
|
@ -169,6 +202,53 @@ public MavenProject( Model model )
|
|||
setModel( model );
|
||||
}
|
||||
|
||||
public MavenProject( Model model, ArtifactFactory artifactFactory, MavenTools mavenTools,
|
||||
RepositoryHelper repositoryHelper, MavenProjectBuilder mavenProjectBuilder,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
throws InvalidRepositoryException
|
||||
{
|
||||
setModel( model );
|
||||
this.artifactFactory = artifactFactory;
|
||||
this.mavenTools = mavenTools;
|
||||
this.repositoryHelper = repositoryHelper;
|
||||
this.mavenProjectBuilder = mavenProjectBuilder;
|
||||
this.projectBuilderConfiguration = projectBuilderConfiguration;
|
||||
originalModel = ModelUtils.cloneModel( model );
|
||||
DistributionManagement dm = model.getDistributionManagement();
|
||||
|
||||
if ( dm != null )
|
||||
{
|
||||
ArtifactRepository repo = mavenTools.buildDeploymentArtifactRepository( dm.getRepository() );
|
||||
setReleaseArtifactRepository( repo );
|
||||
|
||||
if ( dm.getSnapshotRepository() != null )
|
||||
{
|
||||
repo = mavenTools.buildDeploymentArtifactRepository( dm.getSnapshotRepository() );
|
||||
setSnapshotArtifactRepository( repo );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
LinkedHashSet repoSet = new LinkedHashSet();
|
||||
if ( ( model.getRepositories() != null ) && !model.getRepositories().isEmpty() )
|
||||
{
|
||||
repoSet.addAll( model.getRepositories() );
|
||||
}
|
||||
|
||||
if ( ( model.getPluginRepositories() != null ) && !model.getPluginRepositories().isEmpty() )
|
||||
{
|
||||
repoSet.addAll( model.getPluginRepositories() );
|
||||
}
|
||||
|
||||
setRemoteArtifactRepositories( mavenTools.buildArtifactRepositories( new ArrayList( repoSet ) ) );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #clone()} so subclasses can provide a copy of the same class
|
||||
*/
|
||||
|
@ -178,7 +258,8 @@ public MavenProject( MavenProject project )
|
|||
deepCopy( project );
|
||||
}
|
||||
|
||||
private final void deepCopy(MavenProject project){
|
||||
private final void deepCopy( MavenProject project )
|
||||
{
|
||||
// disown the parent
|
||||
|
||||
// copy fields
|
||||
|
@ -196,11 +277,16 @@ private final void deepCopy(MavenProject project){
|
|||
setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) );
|
||||
}
|
||||
|
||||
if ( project.getPluginArtifacts() != null )
|
||||
if ( project.getParentFile() != null )
|
||||
{
|
||||
setPluginArtifacts( Collections.unmodifiableSet( project.getPluginArtifacts() ) );
|
||||
parentFile = new File( project.getParentFile().getAbsolutePath() );
|
||||
}
|
||||
|
||||
// if ( project.getPluginArtifacts() != null )
|
||||
// {
|
||||
// setPluginArtifacts( Collections.unmodifiableSet( project.getPluginArtifacts() ) );
|
||||
// }
|
||||
|
||||
if ( project.getReportArtifacts() != null )
|
||||
{
|
||||
setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) );
|
||||
|
@ -220,7 +306,8 @@ private final void deepCopy(MavenProject project){
|
|||
|
||||
if ( project.getPluginArtifactRepositories() != null )
|
||||
{
|
||||
setPluginArtifactRepositories( ( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ) );
|
||||
setPluginArtifactRepositories(
|
||||
( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ) );
|
||||
}
|
||||
|
||||
if ( project.getCollectedProjects() != null )
|
||||
|
@ -293,24 +380,24 @@ private final void deepCopy(MavenProject project){
|
|||
if ( dynamicRoots != null )
|
||||
{
|
||||
setDynamicCompileSourceRoots( new ArrayList( dynamicRoots ) );
|
||||
setOriginalInterpolatedCompileSourceRoots( new ArrayList(
|
||||
project.getOriginalInterpolatedCompileSourceRoots() ) );
|
||||
setOriginalInterpolatedCompileSourceRoots(
|
||||
new ArrayList( project.getOriginalInterpolatedCompileSourceRoots() ) );
|
||||
}
|
||||
|
||||
dynamicRoots = project.getDynamicTestCompileSourceRoots();
|
||||
if ( dynamicRoots != null )
|
||||
{
|
||||
setDynamicTestCompileSourceRoots( new ArrayList( dynamicRoots ) );
|
||||
setOriginalInterpolatedTestCompileSourceRoots( new ArrayList(
|
||||
project.getOriginalInterpolatedTestCompileSourceRoots() ) );
|
||||
setOriginalInterpolatedTestCompileSourceRoots(
|
||||
new ArrayList( project.getOriginalInterpolatedTestCompileSourceRoots() ) );
|
||||
}
|
||||
|
||||
dynamicRoots = project.getDynamicScriptSourceRoots();
|
||||
if ( dynamicRoots != null )
|
||||
{
|
||||
setDynamicScriptSourceRoots( new ArrayList( dynamicRoots ) );
|
||||
setOriginalInterpolatedScriptSourceRoots( new ArrayList(
|
||||
project.getOriginalInterpolatedScriptSourceRoots() ) );
|
||||
setOriginalInterpolatedScriptSourceRoots(
|
||||
new ArrayList( project.getOriginalInterpolatedScriptSourceRoots() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +406,8 @@ private final void deepCopy(MavenProject project){
|
|||
|
||||
// TODO: Find a way to use <relativePath/> here...it's tricky, because the moduleProject
|
||||
// usually doesn't have a file associated with it yet.
|
||||
public String getModulePathAdjustment( MavenProject moduleProject ) throws IOException
|
||||
public String getModulePathAdjustment( MavenProject moduleProject )
|
||||
throws IOException
|
||||
{
|
||||
// FIXME: This is hacky. What if module directory doesn't match artifactid, and parent
|
||||
// is coming from the repository??
|
||||
|
@ -396,6 +484,43 @@ public Model getModel()
|
|||
|
||||
public MavenProject getParent()
|
||||
{
|
||||
if ( parent == null )
|
||||
{
|
||||
if ( parentFile != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
parent = mavenProjectBuilder.build( parentFile, projectBuilderConfiguration );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if ( model.getParent() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
parent = mavenProjectBuilder.buildFromRepository( getParentArtifact(),
|
||||
this.remoteArtifactRepositories,
|
||||
projectBuilderConfiguration.getLocalRepository() );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
try {
|
||||
parent = mavenProjectBuilder.buildStandaloneSuperProject(projectBuilderConfiguration);
|
||||
} catch (ProjectBuildingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
@ -1144,6 +1269,7 @@ public void setArtifacts( Set artifacts )
|
|||
* All dependencies that this project has, including transitive ones.
|
||||
* Contents are lazily populated, so depending on what phases have run dependencies in some scopes won't be included.
|
||||
* eg. if only compile phase has run, dependencies with scope test won't be included.
|
||||
*
|
||||
* @return {@link Set} < {@link Artifact} >
|
||||
* @see #getDependencyArtifacts() to get only direct dependencies
|
||||
*/
|
||||
|
@ -1162,25 +1288,55 @@ public Map getArtifactMap()
|
|||
return artifactMap;
|
||||
}
|
||||
|
||||
public void setPluginArtifacts( Set pluginArtifacts )
|
||||
{
|
||||
this.pluginArtifacts = pluginArtifacts;
|
||||
|
||||
pluginArtifactMap = null;
|
||||
}
|
||||
|
||||
public Set getPluginArtifacts()
|
||||
{
|
||||
if ( pluginArtifacts != null )
|
||||
{
|
||||
return pluginArtifacts;
|
||||
}
|
||||
Set pa = new HashSet();
|
||||
if ( artifactFactory != null )
|
||||
{
|
||||
List plugins = getBuildPlugins();
|
||||
for ( Iterator i = plugins.iterator(); i.hasNext(); )
|
||||
{
|
||||
Plugin p = (Plugin) i.next();
|
||||
|
||||
String version;
|
||||
if ( StringUtils.isEmpty( p.getVersion() ) )
|
||||
{
|
||||
version = "RELEASE";
|
||||
}
|
||||
else
|
||||
{
|
||||
version = p.getVersion();
|
||||
}
|
||||
|
||||
Artifact artifact;
|
||||
try
|
||||
{
|
||||
artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
|
||||
VersionRange.createFromVersionSpec( version ) );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
return pa;
|
||||
}
|
||||
|
||||
if ( artifact != null )
|
||||
{
|
||||
pa.add( artifact );
|
||||
}
|
||||
}
|
||||
}
|
||||
pluginArtifacts = pa;
|
||||
pluginArtifactMap = null;
|
||||
return pluginArtifacts;
|
||||
}
|
||||
|
||||
public Map getPluginArtifactMap()
|
||||
{
|
||||
if ( pluginArtifactMap == null )
|
||||
{
|
||||
pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() );
|
||||
}
|
||||
|
||||
pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() );
|
||||
return pluginArtifactMap;
|
||||
}
|
||||
|
||||
|
@ -1193,6 +1349,42 @@ public void setReportArtifacts( Set reportArtifacts )
|
|||
|
||||
public Set getReportArtifacts()
|
||||
{
|
||||
Set pluginArtifacts = new HashSet();
|
||||
List reports = getReportPlugins();
|
||||
if ( reports != null )
|
||||
{
|
||||
for ( Iterator i = reports.iterator(); i.hasNext(); )
|
||||
{
|
||||
ReportPlugin p = (ReportPlugin) i.next();
|
||||
|
||||
String version;
|
||||
if ( StringUtils.isEmpty( p.getVersion() ) )
|
||||
{
|
||||
version = "RELEASE";
|
||||
}
|
||||
else
|
||||
{
|
||||
version = p.getVersion();
|
||||
}
|
||||
|
||||
Artifact artifact = null;
|
||||
try
|
||||
{
|
||||
artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
|
||||
VersionRange.createFromVersionSpec( version ) );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
//throw new InvalidProjectVersionException( projectId, "Report plugin: " + p.getKey(), version, pomLocation, e );
|
||||
}
|
||||
|
||||
if ( artifact != null )
|
||||
{
|
||||
pluginArtifacts.add( artifact );
|
||||
}
|
||||
}
|
||||
}
|
||||
reportArtifactMap = null;
|
||||
return reportArtifacts;
|
||||
}
|
||||
|
||||
|
@ -1215,6 +1407,43 @@ public void setExtensionArtifacts( Set extensionArtifacts )
|
|||
|
||||
public Set getExtensionArtifacts()
|
||||
{
|
||||
Set extensionArtifacts = new HashSet();
|
||||
List extensions = getBuildExtensions();
|
||||
if ( extensions != null )
|
||||
{
|
||||
for ( Iterator i = extensions.iterator(); i.hasNext(); )
|
||||
{
|
||||
Extension ext = (Extension) i.next();
|
||||
|
||||
String version;
|
||||
if ( StringUtils.isEmpty( ext.getVersion() ) )
|
||||
{
|
||||
version = "RELEASE";
|
||||
}
|
||||
else
|
||||
{
|
||||
version = ext.getVersion();
|
||||
}
|
||||
|
||||
Artifact artifact = null;
|
||||
try
|
||||
{
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( version );
|
||||
artifact =
|
||||
artifactFactory.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(), versionRange );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if ( artifact != null )
|
||||
{
|
||||
extensionArtifacts.add( artifact );
|
||||
}
|
||||
}
|
||||
}
|
||||
extensionArtifactMap = null;
|
||||
return extensionArtifacts;
|
||||
}
|
||||
|
||||
|
@ -1235,6 +1464,11 @@ public void setParentArtifact( Artifact parentArtifact )
|
|||
|
||||
public Artifact getParentArtifact()
|
||||
{
|
||||
if ( parentArtifact == null && model.getParent() != null )
|
||||
{
|
||||
Parent p = model.getParent();
|
||||
parentArtifact = artifactFactory.createParentArtifact( p.getGroupId(), p.getArtifactId(), p.getVersion() );
|
||||
}
|
||||
return parentArtifact;
|
||||
}
|
||||
|
||||
|
@ -1357,7 +1591,8 @@ public List getPluginArtifactRepositories()
|
|||
|
||||
public ArtifactRepository getDistributionManagementArtifactRepository()
|
||||
{
|
||||
return getArtifact().isSnapshot() && ( getSnapshotArtifactRepository() != null ) ? getSnapshotArtifactRepository()
|
||||
return getArtifact().isSnapshot() && ( getSnapshotArtifactRepository() != null )
|
||||
? getSnapshotArtifactRepository()
|
||||
: getReleaseArtifactRepository();
|
||||
}
|
||||
|
||||
|
@ -1527,6 +1762,7 @@ public void writeOriginalModel( Writer writer )
|
|||
|
||||
/**
|
||||
* Direct dependencies that this project has.
|
||||
*
|
||||
* @return {@link Set} < {@link Artifact} >
|
||||
* @see #getArtifacts() to get all transitive dependencies
|
||||
*/
|
||||
|
@ -1567,6 +1803,77 @@ public void setManagedVersionMap( Map map )
|
|||
|
||||
public Map getManagedVersionMap()
|
||||
{
|
||||
if ( managedVersionMap != null )
|
||||
{
|
||||
return managedVersionMap;
|
||||
}
|
||||
|
||||
Map map = null;
|
||||
if ( artifactFactory != null )
|
||||
{
|
||||
|
||||
List deps;
|
||||
DependencyManagement dependencyManagement = getDependencyManagement();
|
||||
if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) &&
|
||||
( deps.size() > 0 ) )
|
||||
{
|
||||
map = new ManagedVersionMap( map );
|
||||
for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); )
|
||||
{
|
||||
Dependency d = (Dependency) i.next();
|
||||
|
||||
try
|
||||
{
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
|
||||
|
||||
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||
versionRange, d.getType(),
|
||||
d.getClassifier(), d.getScope(),
|
||||
d.isOptional() );
|
||||
|
||||
if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && ( d.getSystemPath() != null ) )
|
||||
{
|
||||
artifact.setFile( new File( d.getSystemPath() ) );
|
||||
}
|
||||
|
||||
// If the dependencyManagement section listed exclusions,
|
||||
// add them to the managed artifacts here so that transitive
|
||||
// dependencies will be excluded if necessary.
|
||||
|
||||
if ( ( null != d.getExclusions() ) && !d.getExclusions().isEmpty() )
|
||||
{
|
||||
List exclusions = new ArrayList();
|
||||
|
||||
for ( Iterator j = d.getExclusions().iterator(); j.hasNext(); )
|
||||
{
|
||||
Exclusion e = (Exclusion) j.next();
|
||||
|
||||
exclusions.add( e.getGroupId() + ":" + e.getArtifactId() );
|
||||
}
|
||||
|
||||
ExcludesArtifactFilter eaf = new ExcludesArtifactFilter( exclusions );
|
||||
|
||||
artifact.setDependencyFilter( eaf );
|
||||
}
|
||||
else
|
||||
{
|
||||
artifact.setDependencyFilter( null );
|
||||
}
|
||||
|
||||
map.put( d.getManagementKey(), artifact );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
map = Collections.EMPTY_MAP;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( map == null )
|
||||
{
|
||||
map = Collections.EMPTY_MAP;
|
||||
}
|
||||
}
|
||||
managedVersionMap = map;
|
||||
return managedVersionMap;
|
||||
}
|
||||
|
||||
|
@ -1609,8 +1916,8 @@ public List getBuildExtensions()
|
|||
}
|
||||
|
||||
/**
|
||||
* @todo the lazy initialisation of this makes me uneasy.
|
||||
* @return {@link Set} < {@link Artifact} >
|
||||
* @todo the lazy initialisation of this makes me uneasy.
|
||||
*/
|
||||
public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedScope,
|
||||
ArtifactFilter dependencyFilter )
|
||||
|
@ -1622,7 +1929,8 @@ public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedSco
|
|||
|
||||
public void addProjectReference( MavenProject project )
|
||||
{
|
||||
projectReferences.put( getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
|
||||
projectReferences.put(
|
||||
getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
|
||||
}
|
||||
|
||||
private static String getProjectReferenceId( String groupId, String artifactId, String version )
|
||||
|
@ -1708,7 +2016,8 @@ public Artifact replaceWithActiveArtifact( Artifact pluginArtifact )
|
|||
{
|
||||
if ( ( getProjectReferences() != null ) && !getProjectReferences().isEmpty() )
|
||||
{
|
||||
String refId = getProjectReferenceId( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(), pluginArtifact.getVersion() );
|
||||
String refId = getProjectReferenceId( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(),
|
||||
pluginArtifact.getVersion() );
|
||||
MavenProject ref = (MavenProject) getProjectReferences().get( refId );
|
||||
if ( ( ref != null ) && ( ref.getArtifact() != null ) )
|
||||
{
|
||||
|
@ -1732,9 +2041,11 @@ public Artifact replaceWithActiveArtifact( Artifact pluginArtifact )
|
|||
}
|
||||
|
||||
Iterator itr = ref.getAttachedArtifacts().iterator();
|
||||
while(itr.hasNext()) {
|
||||
while ( itr.hasNext() )
|
||||
{
|
||||
Artifact attached = (Artifact) itr.next();
|
||||
if( attached.getDependencyConflictId().equals(pluginArtifact.getDependencyConflictId()) ) {
|
||||
if ( attached.getDependencyConflictId().equals( pluginArtifact.getDependencyConflictId() ) )
|
||||
{
|
||||
/* TODO: if I use the original, I get an exception below:
|
||||
java.lang.UnsupportedOperationException: Cannot change the download information for an attached artifact. It is derived from the main artifact.
|
||||
at org.apache.maven.project.artifact.AttachedArtifact.setDownloadUrl(AttachedArtifact.java:89)
|
||||
|
@ -1756,8 +2067,8 @@ public Artifact replaceWithActiveArtifact( Artifact pluginArtifact )
|
|||
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
|
||||
at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
|
||||
*/
|
||||
Artifact resultArtifact=ArtifactUtils.copyArtifact(attached);
|
||||
resultArtifact.setScope(pluginArtifact.getScope());
|
||||
Artifact resultArtifact = ArtifactUtils.copyArtifact( attached );
|
||||
resultArtifact.setScope( pluginArtifact.getScope() );
|
||||
return resultArtifact;
|
||||
}
|
||||
}
|
||||
|
@ -1780,9 +2091,7 @@ public Artifact replaceWithActiveArtifact( Artifact pluginArtifact )
|
|||
( pluginArtifact.getType().equals( "ejb-client" ) ) &&
|
||||
( ( ref.getArtifact().getFile() != null ) && ref.getArtifact().getFile().exists() ) )
|
||||
{
|
||||
pluginArtifact = new ActiveProjectArtifact(
|
||||
ref,
|
||||
pluginArtifact );
|
||||
pluginArtifact = new ActiveProjectArtifact( ref, pluginArtifact );
|
||||
return pluginArtifact;
|
||||
}
|
||||
}
|
||||
|
@ -1790,7 +2099,8 @@ public Artifact replaceWithActiveArtifact( Artifact pluginArtifact )
|
|||
return pluginArtifact;
|
||||
}
|
||||
|
||||
private void addArtifactPath(Artifact a, List list) throws DependencyResolutionRequiredException
|
||||
private void addArtifactPath( Artifact a, List list )
|
||||
throws DependencyResolutionRequiredException
|
||||
{
|
||||
String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId(), a.getVersion() );
|
||||
MavenProject project = (MavenProject) projectReferences.get( refId );
|
||||
|
@ -1798,7 +2108,7 @@ private void addArtifactPath(Artifact a, List list) throws DependencyResolutionR
|
|||
boolean projectDirFound = false;
|
||||
if ( project != null )
|
||||
{
|
||||
if (a.getType().equals("test-jar"))
|
||||
if ( a.getType().equals( "test-jar" ) )
|
||||
{
|
||||
File testOutputDir = new File( project.getBuild().getTestOutputDirectory() );
|
||||
if ( testOutputDir.exists() )
|
||||
|
@ -1813,7 +2123,7 @@ private void addArtifactPath(Artifact a, List list) throws DependencyResolutionR
|
|||
projectDirFound = true;
|
||||
}
|
||||
}
|
||||
if ( ! projectDirFound )
|
||||
if ( !projectDirFound )
|
||||
{
|
||||
File file = a.getFile();
|
||||
if ( file == null )
|
||||
|
@ -1840,13 +2150,14 @@ public Plugin getPlugin( String pluginKey )
|
|||
{
|
||||
return (Plugin) getBuild().getPluginsAsMap().get( pluginKey );
|
||||
}
|
||||
|
||||
/**
|
||||
* Default toString
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer(30);
|
||||
StringBuffer sb = new StringBuffer( 30 );
|
||||
sb.append( "MavenProject: " );
|
||||
sb.append( getGroupId() );
|
||||
sb.append( ":" );
|
||||
|
@ -1859,7 +2170,7 @@ public String toString()
|
|||
{
|
||||
sb.append( getFile().getPath() );
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
catch ( NullPointerException e )
|
||||
{
|
||||
//don't log it.
|
||||
}
|
||||
|
|
|
@ -43,21 +43,17 @@ public interface MavenProjectBuilder
|
|||
* @deprecated Use {@link MavenProjectBuilder#build(File, ProjectBuilderConfiguration)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
MavenProject build( File project,
|
||||
ArtifactRepository localRepository,
|
||||
ProfileManager globalProfileManager )
|
||||
MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject build( File project, ProjectBuilderConfiguration configuration )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject buildWithDependencies( File project,
|
||||
ArtifactRepository localRepository,
|
||||
MavenProject buildWithDependencies( File project, ArtifactRepository localRepository,
|
||||
ProfileManager globalProfileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project,
|
||||
ProjectBuilderConfiguration config )
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project, ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
|
||||
|
@ -65,23 +61,21 @@ MavenProjectBuildingResult buildProjectWithDependencies( File project,
|
|||
* @deprecated Use {@link MavenProjectBuilder#buildProjectWithDependencies(File, ProjectBuilderConfiguration)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project,
|
||||
ArtifactRepository localRepository,
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project, ArtifactRepository localRepository,
|
||||
ProfileManager globalProfileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
|
||||
MavenProject buildFromRepository( Artifact artifact,
|
||||
List remoteArtifactRepositories,
|
||||
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
/** @deprecated We do not want to allow projects to not have POMs. Maven 1.x repositories be damned. */
|
||||
/**
|
||||
* @deprecated We do not want to allow projects to not have POMs. Maven 1.x repositories be damned.
|
||||
*/
|
||||
@Deprecated
|
||||
MavenProject buildFromRepository( Artifact artifact,
|
||||
List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository,
|
||||
boolean allowStub )
|
||||
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository, boolean allowStub )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
/**
|
||||
|
@ -105,11 +99,9 @@ MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
|
|||
// API BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void calculateConcreteState( MavenProject project,
|
||||
ProjectBuilderConfiguration config )
|
||||
void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException;
|
||||
|
||||
void restoreDynamicState( MavenProject project,
|
||||
ProjectBuilderConfiguration config )
|
||||
void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,7 @@ public class MavenProjectBuildingResult
|
|||
|
||||
private ArtifactResolutionResult artifactResolutionResult;
|
||||
|
||||
public MavenProjectBuildingResult( MavenProject project,
|
||||
ArtifactResolutionResult artifactResolutionResult )
|
||||
public MavenProjectBuildingResult( MavenProject project, ArtifactResolutionResult artifactResolutionResult )
|
||||
{
|
||||
this.project = project;
|
||||
|
||||
|
|
|
@ -0,0 +1,527 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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.Build;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolator;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
final class MavenProjectRestorer
|
||||
{
|
||||
|
||||
private ModelInterpolator modelInterpolator;
|
||||
|
||||
private PathTranslator pathTranslator;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
MavenProjectRestorer( PathTranslator pathTranslator, ModelInterpolator modelInterpolator, Logger logger )
|
||||
{
|
||||
this.pathTranslator = pathTranslator;
|
||||
this.modelInterpolator = modelInterpolator;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
Logger getLogger()
|
||||
{
|
||||
return logger;
|
||||
}
|
||||
|
||||
void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
if ( !project.isConcrete() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
restoreBuildRoots( project, config );
|
||||
if ( project.getBuild() != null )
|
||||
{
|
||||
restoreModelBuildSection( project, config );
|
||||
}
|
||||
restoreDynamicProjectReferences( project, config );
|
||||
|
||||
MavenProject executionProject = project.getExecutionProject();
|
||||
if ( executionProject != null && executionProject != project )
|
||||
{
|
||||
restoreDynamicState( executionProject, config );
|
||||
}
|
||||
|
||||
project.setConcrete( false );
|
||||
}
|
||||
|
||||
void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
if ( project.isConcrete() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Build build = project.getBuild();
|
||||
if ( build != null )
|
||||
{
|
||||
initResourceMergeIds( build.getResources() );
|
||||
initResourceMergeIds( build.getTestResources() );
|
||||
}
|
||||
|
||||
Model model = ModelUtils.cloneModel( project.getModel() );
|
||||
|
||||
File basedir = project.getBasedir();
|
||||
|
||||
model = modelInterpolator.interpolate( model, basedir, config, getLogger().isDebugEnabled() );
|
||||
|
||||
List originalInterpolatedCompileSourceRoots =
|
||||
interpolateListOfStrings( project.getCompileSourceRoots(), model, project.getBasedir(), config );
|
||||
|
||||
project.preserveCompileSourceRoots( originalInterpolatedCompileSourceRoots );
|
||||
|
||||
project.setCompileSourceRoots( originalInterpolatedCompileSourceRoots == null
|
||||
? null
|
||||
: translateListOfPaths( originalInterpolatedCompileSourceRoots, basedir ) );
|
||||
|
||||
List originalInterpolatedTestCompileSourceRoots =
|
||||
interpolateListOfStrings( project.getTestCompileSourceRoots(), model, project.getBasedir(), config );
|
||||
|
||||
project.preserveTestCompileSourceRoots( originalInterpolatedTestCompileSourceRoots );
|
||||
project.setTestCompileSourceRoots( originalInterpolatedTestCompileSourceRoots == null
|
||||
? null
|
||||
: translateListOfPaths( originalInterpolatedTestCompileSourceRoots, basedir ) );
|
||||
|
||||
List originalInterpolatedScriptSourceRoots =
|
||||
interpolateListOfStrings( project.getScriptSourceRoots(), model, project.getBasedir(), config );
|
||||
|
||||
project.preserveScriptSourceRoots( originalInterpolatedScriptSourceRoots );
|
||||
project.setScriptSourceRoots( originalInterpolatedScriptSourceRoots == null
|
||||
? null
|
||||
: translateListOfPaths( originalInterpolatedScriptSourceRoots, basedir ) );
|
||||
|
||||
Model model2 = ModelUtils.cloneModel( model );
|
||||
|
||||
pathTranslator.alignToBaseDirectory( model, basedir );
|
||||
|
||||
project.preserveBuild( model2.getBuild() );
|
||||
project.setBuild( model.getBuild() );
|
||||
|
||||
calculateConcreteProjectReferences( project, config );
|
||||
|
||||
MavenProject executionProject = project.getExecutionProject();
|
||||
if ( executionProject != null && executionProject != project )
|
||||
{
|
||||
calculateConcreteState( executionProject, config );
|
||||
}
|
||||
|
||||
project.setConcrete( true );
|
||||
}
|
||||
|
||||
|
||||
private void restoreDynamicProjectReferences( MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
Map projectRefs = project.getProjectReferences();
|
||||
if ( projectRefs != null )
|
||||
{
|
||||
for ( Iterator it = projectRefs.values().iterator(); it.hasNext(); )
|
||||
{
|
||||
MavenProject projectRef = (MavenProject) it.next();
|
||||
restoreDynamicState( projectRef, config );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreBuildRoots( MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
project.setCompileSourceRoots( restoreListOfStrings( project.getDynamicCompileSourceRoots(),
|
||||
project.getOriginalInterpolatedCompileSourceRoots(),
|
||||
project.getCompileSourceRoots(), project, config ) );
|
||||
|
||||
project.setTestCompileSourceRoots( restoreListOfStrings( project.getDynamicTestCompileSourceRoots(),
|
||||
project.getOriginalInterpolatedTestCompileSourceRoots(),
|
||||
project.getTestCompileSourceRoots(), project,
|
||||
config ) );
|
||||
|
||||
project.setScriptSourceRoots( restoreListOfStrings( project.getDynamicScriptSourceRoots(),
|
||||
project.getOriginalInterpolatedScriptSourceRoots(),
|
||||
project.getScriptSourceRoots(), project, config ) );
|
||||
|
||||
project.clearRestorableRoots();
|
||||
}
|
||||
|
||||
private void restoreModelBuildSection( MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
Build changedBuild = project.getBuild();
|
||||
Build dynamicBuild = project.getDynamicBuild();
|
||||
Build originalInterpolatedBuild = project.getOriginalInterpolatedBuild();
|
||||
|
||||
dynamicBuild.setResources( restoreResources( dynamicBuild.getResources(),
|
||||
originalInterpolatedBuild.getResources(),
|
||||
changedBuild.getResources(), project, config ) );
|
||||
|
||||
dynamicBuild.setTestResources( restoreResources( dynamicBuild.getTestResources(),
|
||||
originalInterpolatedBuild.getTestResources(),
|
||||
changedBuild.getTestResources(), project, config ) );
|
||||
|
||||
dynamicBuild.setFilters( restoreListOfStrings( dynamicBuild.getFilters(),
|
||||
originalInterpolatedBuild.getFilters(),
|
||||
changedBuild.getFilters(), project, config ) );
|
||||
|
||||
dynamicBuild.setFinalName( restoreString( dynamicBuild.getFinalName(), originalInterpolatedBuild.getFinalName(),
|
||||
changedBuild.getFinalName(), project, config ) );
|
||||
|
||||
dynamicBuild.setDefaultGoal( restoreString( dynamicBuild.getDefaultGoal(),
|
||||
originalInterpolatedBuild.getDefaultGoal(),
|
||||
changedBuild.getDefaultGoal(), project, config ) );
|
||||
|
||||
dynamicBuild.setSourceDirectory( restoreString( dynamicBuild.getSourceDirectory(),
|
||||
originalInterpolatedBuild.getSourceDirectory(),
|
||||
changedBuild.getSourceDirectory(), project, config ) );
|
||||
|
||||
dynamicBuild.setTestSourceDirectory( restoreString( dynamicBuild.getTestSourceDirectory(),
|
||||
originalInterpolatedBuild.getTestSourceDirectory(),
|
||||
changedBuild.getTestSourceDirectory(), project, config ) );
|
||||
|
||||
dynamicBuild.setScriptSourceDirectory( restoreString( dynamicBuild.getScriptSourceDirectory(),
|
||||
originalInterpolatedBuild.getScriptSourceDirectory(),
|
||||
changedBuild.getScriptSourceDirectory(), project,
|
||||
config ) );
|
||||
|
||||
dynamicBuild.setOutputDirectory( restoreString( dynamicBuild.getOutputDirectory(),
|
||||
originalInterpolatedBuild.getOutputDirectory(),
|
||||
changedBuild.getOutputDirectory(), project, config ) );
|
||||
|
||||
dynamicBuild.setTestOutputDirectory( restoreString( dynamicBuild.getTestOutputDirectory(),
|
||||
originalInterpolatedBuild.getTestOutputDirectory(),
|
||||
changedBuild.getTestOutputDirectory(), project, config ) );
|
||||
|
||||
dynamicBuild.setDirectory( restoreString( dynamicBuild.getDirectory(), originalInterpolatedBuild.getDirectory(),
|
||||
changedBuild.getDirectory(), project, config ) );
|
||||
|
||||
project.setBuild( dynamicBuild );
|
||||
|
||||
project.clearRestorableBuild();
|
||||
}
|
||||
|
||||
private List interpolateListOfStrings( List originalStrings, Model model, File projectDir,
|
||||
ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
if ( originalStrings == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List result = new ArrayList();
|
||||
|
||||
for ( Iterator it = originalStrings.iterator(); it.hasNext(); )
|
||||
{
|
||||
String original = (String) it.next();
|
||||
String interpolated =
|
||||
modelInterpolator.interpolate( original, model, projectDir, config, getLogger().isDebugEnabled() );
|
||||
|
||||
result.add( interpolated );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private String restoreString( String originalString, String originalInterpolatedString, String changedString,
|
||||
MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
if ( originalString == null )
|
||||
{
|
||||
return changedString;
|
||||
}
|
||||
else if ( changedString == null )
|
||||
{
|
||||
return originalString;
|
||||
}
|
||||
|
||||
Model model = project.getModel();
|
||||
|
||||
String relativeChangedString;
|
||||
if ( project.getBasedir() != null )
|
||||
{
|
||||
relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
|
||||
}
|
||||
else
|
||||
{
|
||||
relativeChangedString = changedString;
|
||||
}
|
||||
|
||||
String interpolatedOriginal = modelInterpolator.interpolate( originalString, model, project.getBasedir(),
|
||||
config, getLogger().isDebugEnabled() );
|
||||
String interpolatedOriginal2 = modelInterpolator.interpolate( originalInterpolatedString, model,
|
||||
project.getBasedir(), config,
|
||||
getLogger().isDebugEnabled() );
|
||||
|
||||
String interpolatedChanged = modelInterpolator.interpolate( changedString, model, project.getBasedir(), config,
|
||||
getLogger().isDebugEnabled() );
|
||||
String relativeInterpolatedChanged = modelInterpolator.interpolate( relativeChangedString, model,
|
||||
project.getBasedir(), config,
|
||||
getLogger().isDebugEnabled() );
|
||||
|
||||
if ( interpolatedOriginal.equals( interpolatedChanged ) || interpolatedOriginal2.equals( interpolatedChanged ) )
|
||||
{
|
||||
return originalString;
|
||||
}
|
||||
else if ( interpolatedOriginal.equals( relativeInterpolatedChanged ) ||
|
||||
interpolatedOriginal2.equals( relativeInterpolatedChanged ) )
|
||||
{
|
||||
return originalString;
|
||||
}
|
||||
|
||||
return relativeChangedString;
|
||||
}
|
||||
|
||||
private List restoreListOfStrings( List originalStrings, List originalInterpolatedStrings, List changedStrings,
|
||||
MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
if ( originalStrings == null )
|
||||
{
|
||||
return changedStrings;
|
||||
}
|
||||
else if ( changedStrings == null )
|
||||
{
|
||||
return originalStrings;
|
||||
}
|
||||
|
||||
List result = new ArrayList();
|
||||
|
||||
Map orig = new HashMap();
|
||||
for ( int idx = 0; idx < originalStrings.size(); idx++ )
|
||||
{
|
||||
String[] permutations = new String[2];
|
||||
|
||||
permutations[0] = (String) originalInterpolatedStrings.get( idx );
|
||||
permutations[1] = (String) originalStrings.get( idx );
|
||||
|
||||
orig.put( permutations[0], permutations );
|
||||
}
|
||||
|
||||
for ( Iterator it = changedStrings.iterator(); it.hasNext(); )
|
||||
{
|
||||
String changedString = (String) it.next();
|
||||
String relativeChangedString;
|
||||
if ( project.getBasedir() != null )
|
||||
{
|
||||
relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
|
||||
}
|
||||
else
|
||||
{
|
||||
relativeChangedString = changedString;
|
||||
}
|
||||
|
||||
String interpolated = modelInterpolator.interpolate( changedString, project.getModel(),
|
||||
project.getBasedir(), config,
|
||||
getLogger().isDebugEnabled() );
|
||||
|
||||
String relativeInterpolated = modelInterpolator.interpolate( relativeChangedString, project.getModel(),
|
||||
project.getBasedir(), config,
|
||||
getLogger().isDebugEnabled() );
|
||||
|
||||
String[] original = (String[]) orig.get( interpolated );
|
||||
if ( original == null )
|
||||
{
|
||||
original = (String[]) orig.get( relativeInterpolated );
|
||||
}
|
||||
|
||||
if ( original == null )
|
||||
{
|
||||
result.add( relativeChangedString );
|
||||
}
|
||||
else
|
||||
{
|
||||
result.add( original[1] );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO: Convert this to use the mergeId on each resource...
|
||||
private List restoreResources( List<Resource> originalResources, List<Resource> originalInterpolatedResources,
|
||||
List<Resource> changedResources, MavenProject project,
|
||||
ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
if ( originalResources == null || changedResources == null )
|
||||
{
|
||||
return originalResources;
|
||||
}
|
||||
|
||||
List<Resource> result = new ArrayList<Resource>();
|
||||
|
||||
Map<String, Resource[]> originalResourcesByMergeId = new HashMap<String, Resource[]>();
|
||||
for ( int idx = 0; idx < originalResources.size(); idx++ )
|
||||
{
|
||||
Resource[] permutations = new Resource[2];
|
||||
|
||||
permutations[0] = originalInterpolatedResources.get( idx );
|
||||
permutations[1] = originalResources.get( idx );
|
||||
|
||||
originalResourcesByMergeId.put( permutations[0].getMergeId(), permutations );
|
||||
}
|
||||
|
||||
for ( Resource resource : changedResources )
|
||||
{
|
||||
String mergeId = resource.getMergeId();
|
||||
if ( mergeId == null || !originalResourcesByMergeId.containsKey( mergeId ) )
|
||||
{
|
||||
result.add( resource );
|
||||
}
|
||||
else
|
||||
{
|
||||
Resource originalInterpolatedResource = originalResourcesByMergeId.get( mergeId )[0];
|
||||
Resource originalResource = originalResourcesByMergeId.get( mergeId )[1];
|
||||
|
||||
String dir = modelInterpolator.interpolate( resource.getDirectory(), project.getModel(),
|
||||
project.getBasedir(), config,
|
||||
getLogger().isDebugEnabled() );
|
||||
String oDir = originalInterpolatedResource.getDirectory();
|
||||
|
||||
if ( !dir.equals( oDir ) )
|
||||
{
|
||||
originalResource.setDirectory(
|
||||
pathTranslator.unalignFromBaseDirectory( dir, project.getBasedir() ) );
|
||||
}
|
||||
|
||||
if ( resource.getTargetPath() != null )
|
||||
{
|
||||
String target = modelInterpolator.interpolate( resource.getTargetPath(), project.getModel(),
|
||||
project.getBasedir(), config,
|
||||
getLogger().isDebugEnabled() );
|
||||
|
||||
String oTarget = originalInterpolatedResource.getTargetPath();
|
||||
|
||||
if ( !target.equals( oTarget ) )
|
||||
{
|
||||
originalResource.setTargetPath(
|
||||
pathTranslator.unalignFromBaseDirectory( target, project.getBasedir() ) );
|
||||
}
|
||||
}
|
||||
|
||||
originalResource.setFiltering( resource.isFiltering() );
|
||||
|
||||
originalResource.setExcludes( collectRestoredListOfPatterns( resource.getExcludes(),
|
||||
originalResource.getExcludes(),
|
||||
originalInterpolatedResource.getExcludes() ) );
|
||||
|
||||
originalResource.setIncludes( collectRestoredListOfPatterns( resource.getIncludes(),
|
||||
originalResource.getIncludes(),
|
||||
originalInterpolatedResource.getIncludes() ) );
|
||||
|
||||
result.add( originalResource );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<String> collectRestoredListOfPatterns( List<String> patterns, List<String> originalPatterns,
|
||||
List<String> originalInterpolatedPatterns )
|
||||
{
|
||||
LinkedHashSet<String> collectedPatterns = new LinkedHashSet<String>();
|
||||
|
||||
collectedPatterns.addAll( originalPatterns );
|
||||
|
||||
for ( String pattern : patterns )
|
||||
{
|
||||
if ( !originalInterpolatedPatterns.contains( pattern ) )
|
||||
{
|
||||
collectedPatterns.add( pattern );
|
||||
}
|
||||
}
|
||||
|
||||
return (List<String>) ( collectedPatterns.isEmpty()
|
||||
? Collections.emptyList()
|
||||
: new ArrayList<String>( collectedPatterns ) );
|
||||
}
|
||||
|
||||
|
||||
private void initResourceMergeIds( List<Resource> resources )
|
||||
{
|
||||
if ( resources != null )
|
||||
{
|
||||
for ( Resource resource : resources )
|
||||
{
|
||||
resource.initMergeId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateConcreteProjectReferences( MavenProject project, ProjectBuilderConfiguration config )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
Map projectRefs = project.getProjectReferences();
|
||||
|
||||
if ( projectRefs != null )
|
||||
{
|
||||
for ( Iterator it = projectRefs.values().iterator(); it.hasNext(); )
|
||||
{
|
||||
MavenProject reference = (MavenProject) it.next();
|
||||
calculateConcreteState( reference, config );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List translateListOfPaths( List paths, File basedir )
|
||||
{
|
||||
if ( paths == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if ( basedir == null )
|
||||
{
|
||||
return paths;
|
||||
}
|
||||
|
||||
List result = new ArrayList( paths.size() );
|
||||
for ( Iterator it = paths.iterator(); it.hasNext(); )
|
||||
{
|
||||
String path = (String) it.next();
|
||||
|
||||
String aligned = pathTranslator.alignToBaseDirectory( path, basedir );
|
||||
|
||||
result.add( aligned );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +1,31 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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.InvalidRepositoryException;
|
||||
|
||||
public class MissingRepositoryElementException
|
||||
extends InvalidRepositoryException
|
||||
{
|
||||
|
||||
public MissingRepositoryElementException( String message,
|
||||
String repositoryId )
|
||||
public MissingRepositoryElementException( String message, String repositoryId )
|
||||
{
|
||||
super( message, repositoryId );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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 java.io.File;
|
||||
|
||||
public class ModelAndFile
|
||||
{
|
||||
|
||||
private final Model model;
|
||||
|
||||
private final File file;
|
||||
|
||||
private final boolean validProfilesXmlLocation;
|
||||
|
||||
public ModelAndFile( Model model, File file, boolean validProfilesXmlLocation )
|
||||
{
|
||||
this.model = model;
|
||||
this.file = file;
|
||||
this.validProfilesXmlLocation = validProfilesXmlLocation;
|
||||
}
|
||||
|
||||
public Model getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
public boolean isValidProfilesXmlLocation()
|
||||
{
|
||||
return validProfilesXmlLocation;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return model.getId() + "@" + file;
|
||||
}
|
||||
|
||||
}
|
|
@ -61,65 +61,17 @@
|
|||
public final class ModelUtils
|
||||
{
|
||||
|
||||
/**
|
||||
* Given this plugin list:
|
||||
*
|
||||
* A1 -> B -> C -> A2 -> D
|
||||
*
|
||||
* Rearrange it to this:
|
||||
*
|
||||
* A(A1 + A2) -> B -> C -> D
|
||||
*
|
||||
* In cases of overlapping definitions, A1 is overridden by A2
|
||||
*
|
||||
*/
|
||||
public static void mergeDuplicatePluginDefinitions( PluginContainer pluginContainer )
|
||||
{
|
||||
if ( pluginContainer == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List originalPlugins = pluginContainer.getPlugins();
|
||||
|
||||
if ( ( originalPlugins == null ) || originalPlugins.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List normalized = new ArrayList( originalPlugins.size() );
|
||||
|
||||
for ( Iterator it = originalPlugins.iterator(); it.hasNext(); )
|
||||
{
|
||||
Plugin currentPlugin = (Plugin) it.next();
|
||||
|
||||
if ( normalized.contains( currentPlugin ) )
|
||||
{
|
||||
int idx = normalized.indexOf( currentPlugin );
|
||||
Plugin firstPlugin = (Plugin) normalized.get( idx );
|
||||
|
||||
mergePluginDefinitions( firstPlugin, currentPlugin, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
normalized.add( currentPlugin );
|
||||
}
|
||||
}
|
||||
|
||||
pluginContainer.setPlugins( normalized );
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be the resulting ordering of plugins after merging:
|
||||
*
|
||||
* <p/>
|
||||
* Given:
|
||||
*
|
||||
* parent: X -> A -> B -> D -> E
|
||||
* child: Y -> A -> C -> D -> F
|
||||
*
|
||||
* <p/>
|
||||
* parent: X -> A -> B -> D -> E
|
||||
* child: Y -> A -> C -> D -> F
|
||||
* <p/>
|
||||
* Result:
|
||||
*
|
||||
* X -> Y -> A -> B -> C -> D -> E -> F
|
||||
* <p/>
|
||||
* X -> Y -> A -> B -> C -> D -> E -> F
|
||||
*/
|
||||
public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer,
|
||||
boolean handleAsInheritance )
|
||||
|
@ -194,9 +146,8 @@ public static void mergePluginLists( PluginContainer childContainer, PluginConta
|
|||
|
||||
// very important to use the parentPlugins List, rather than parentContainer.getPlugins()
|
||||
// since this list is a local one, and may have been modified during processing.
|
||||
List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins,
|
||||
childContainer.getPlugins() );
|
||||
|
||||
List results =
|
||||
ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, childContainer.getPlugins() );
|
||||
|
||||
childContainer.setPlugins( results );
|
||||
|
||||
|
@ -262,67 +213,6 @@ public static List orderAfterMerge( List merged, List highPrioritySource, List l
|
|||
return results;
|
||||
}
|
||||
|
||||
public static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance )
|
||||
{
|
||||
if ( ( child == null ) || ( parent == null ) )
|
||||
{
|
||||
// nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
List parentPlugins = parent.getPlugins();
|
||||
|
||||
if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
|
||||
{
|
||||
Map assembledPlugins = new TreeMap();
|
||||
|
||||
Map childPlugins = child.getReportPluginsAsMap();
|
||||
|
||||
for ( Iterator it = parentPlugins.iterator(); it.hasNext(); )
|
||||
{
|
||||
ReportPlugin parentPlugin = (ReportPlugin) it.next();
|
||||
|
||||
String parentInherited = parentPlugin.getInherited();
|
||||
|
||||
if ( !handleAsInheritance || ( parentInherited == null ) ||
|
||||
Boolean.valueOf( parentInherited ).booleanValue() )
|
||||
{
|
||||
|
||||
ReportPlugin assembledPlugin = parentPlugin;
|
||||
|
||||
ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey() );
|
||||
|
||||
if ( childPlugin != null )
|
||||
{
|
||||
assembledPlugin = childPlugin;
|
||||
|
||||
mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
|
||||
}
|
||||
|
||||
if ( handleAsInheritance && ( parentInherited == null ) )
|
||||
{
|
||||
assembledPlugin.unsetInheritanceApplied();
|
||||
}
|
||||
|
||||
assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin );
|
||||
}
|
||||
}
|
||||
|
||||
for ( Iterator it = childPlugins.values().iterator(); it.hasNext(); )
|
||||
{
|
||||
ReportPlugin childPlugin = (ReportPlugin) it.next();
|
||||
|
||||
if ( !assembledPlugins.containsKey( childPlugin.getKey() ) )
|
||||
{
|
||||
assembledPlugins.put( childPlugin.getKey(), childPlugin );
|
||||
}
|
||||
}
|
||||
|
||||
child.setPlugins( new ArrayList( assembledPlugins.values() ) );
|
||||
|
||||
child.flushReportPluginMap();
|
||||
}
|
||||
}
|
||||
|
||||
public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance )
|
||||
{
|
||||
|
@ -372,7 +262,8 @@ public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean
|
|||
|
||||
String inherited = parentExecution.getInherited();
|
||||
|
||||
boolean parentExecInherited = parentIsInherited && ( ( inherited == null ) || Boolean.valueOf( inherited ).booleanValue() );
|
||||
boolean parentExecInherited =
|
||||
parentIsInherited && ( ( inherited == null ) || Boolean.valueOf( inherited ).booleanValue() );
|
||||
|
||||
if ( !handleAsInheritance || parentExecInherited )
|
||||
{
|
||||
|
@ -392,98 +283,27 @@ else if ( handleAsInheritance && ( parentInherited == null ) )
|
|||
}
|
||||
|
||||
assembledExecutions.put( assembled.getId(), assembled );
|
||||
mergedExecutions.add(assembled);
|
||||
mergedExecutions.add( assembled );
|
||||
}
|
||||
}
|
||||
|
||||
for ( Iterator it = child.getExecutions().iterator(); it.hasNext(); )
|
||||
{
|
||||
PluginExecution childExecution = (PluginExecution)it.next();
|
||||
PluginExecution childExecution = (PluginExecution) it.next();
|
||||
|
||||
if ( !assembledExecutions.containsKey( childExecution.getId() ) )
|
||||
{
|
||||
mergedExecutions.add(childExecution);
|
||||
mergedExecutions.add( childExecution );
|
||||
}
|
||||
}
|
||||
|
||||
child.setExecutions(mergedExecutions);
|
||||
child.setExecutions( mergedExecutions );
|
||||
|
||||
child.flushExecutionMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent,
|
||||
boolean handleAsInheritance )
|
||||
{
|
||||
if ( ( child == null ) || ( parent == null ) )
|
||||
{
|
||||
// nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
|
||||
{
|
||||
child.setVersion( parent.getVersion() );
|
||||
}
|
||||
|
||||
// from here to the end of the method is dealing with merging of the <executions/> section.
|
||||
String parentInherited = parent.getInherited();
|
||||
|
||||
boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue();
|
||||
|
||||
List parentReportSets = parent.getReportSets();
|
||||
|
||||
if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
|
||||
{
|
||||
Map assembledReportSets = new TreeMap();
|
||||
|
||||
Map childReportSets = child.getReportSetsAsMap();
|
||||
|
||||
for ( Iterator it = parentReportSets.iterator(); it.hasNext(); )
|
||||
{
|
||||
ReportSet parentReportSet = (ReportSet) it.next();
|
||||
|
||||
if ( !handleAsInheritance || parentIsInherited )
|
||||
{
|
||||
ReportSet assembledReportSet = parentReportSet;
|
||||
|
||||
ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() );
|
||||
|
||||
if ( childReportSet != null )
|
||||
{
|
||||
mergeReportSetDefinitions( childReportSet, parentReportSet );
|
||||
|
||||
assembledReportSet = childReportSet;
|
||||
}
|
||||
else if ( handleAsInheritance && ( parentInherited == null ) )
|
||||
{
|
||||
parentReportSet.unsetInheritanceApplied();
|
||||
}
|
||||
|
||||
assembledReportSets.put( assembledReportSet.getId(), assembledReportSet );
|
||||
}
|
||||
}
|
||||
|
||||
for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
|
||||
String id = (String) entry.getKey();
|
||||
|
||||
if ( !assembledReportSets.containsKey( id ) )
|
||||
{
|
||||
assembledReportSets.put( id, entry.getValue() );
|
||||
}
|
||||
}
|
||||
|
||||
child.setReportSets( new ArrayList( assembledReportSets.values() ) );
|
||||
|
||||
child.flushReportSetMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent )
|
||||
{
|
||||
if ( child.getPhase() == null )
|
||||
|
@ -524,41 +344,6 @@ private static void mergePluginExecutionDefinitions( PluginExecution child, Plug
|
|||
child.setConfiguration( childConfiguration );
|
||||
}
|
||||
|
||||
private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
|
||||
{
|
||||
List parentReports = parent.getReports();
|
||||
List childReports = child.getReports();
|
||||
|
||||
List reports = new ArrayList();
|
||||
|
||||
if ( ( childReports != null ) && !childReports.isEmpty() )
|
||||
{
|
||||
reports.addAll( childReports );
|
||||
}
|
||||
|
||||
if ( parentReports != null )
|
||||
{
|
||||
for ( Iterator i = parentReports.iterator(); i.hasNext(); )
|
||||
{
|
||||
String report = (String) i.next();
|
||||
|
||||
if ( !reports.contains( report ) )
|
||||
{
|
||||
reports.add( report );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
child.setReports( reports );
|
||||
|
||||
Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
|
||||
Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
|
||||
|
||||
childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
|
||||
|
||||
child.setConfiguration( childConfiguration );
|
||||
}
|
||||
|
||||
public static Model cloneModel( Model model )
|
||||
{
|
||||
// TODO: would be nice for the modello:java code to generate this as a copy constructor
|
||||
|
|
|
@ -49,10 +49,10 @@ public ProjectBuildingException( String projectId, String message )
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link File} constructor for pomLocation
|
||||
* @param projectId
|
||||
* @param message
|
||||
* @param pomLocation absolute path of the pom file
|
||||
* @deprecated use {@link File} constructor for pomLocation
|
||||
*/
|
||||
protected ProjectBuildingException( String projectId, String message, String pomLocation )
|
||||
{
|
||||
|
@ -62,10 +62,9 @@ protected ProjectBuildingException( String projectId, String message, String pom
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param projectId
|
||||
* @param message
|
||||
* @param pomFile pom file location
|
||||
* @param pomFile pom file location
|
||||
*/
|
||||
public ProjectBuildingException( String projectId, String message, File pomFile )
|
||||
{
|
||||
|
@ -77,7 +76,7 @@ public ProjectBuildingException( String projectId, String message, File pomFile
|
|||
/**
|
||||
* @param projectId
|
||||
* @param message
|
||||
* @param pomFile pom file location
|
||||
* @param pomFile pom file location
|
||||
* @param cause
|
||||
*/
|
||||
protected ProjectBuildingException( String projectId, String message, File pomFile, Throwable cause )
|
||||
|
@ -98,8 +97,7 @@ public ProjectBuildingException( String projectId, String message, String pomLoc
|
|||
pomFile = new File( pomLocation );
|
||||
}
|
||||
|
||||
public ProjectBuildingException( String projectId, String message, File pomFile,
|
||||
ProfileActivationException cause )
|
||||
public ProjectBuildingException( String projectId, String message, File pomFile, ProfileActivationException cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.projectId = projectId;
|
||||
|
@ -133,7 +131,8 @@ public ProjectBuildingException( String projectId, String message, IOException c
|
|||
/**
|
||||
* @deprecated use {@link File} constructor for pomLocation
|
||||
*/
|
||||
public ProjectBuildingException( String projectId, String message, String pomLocation, XmlPullParserException cause )
|
||||
public ProjectBuildingException( String projectId, String message, String pomLocation,
|
||||
XmlPullParserException cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.projectId = projectId;
|
||||
|
@ -178,8 +177,7 @@ public ProjectBuildingException( String projectId, String message, ArtifactNotFo
|
|||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public ProjectBuildingException( String projectId, String message, File pomFile,
|
||||
ArtifactResolutionException cause )
|
||||
public ProjectBuildingException( String projectId, String message, File pomFile, ArtifactResolutionException cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.projectId = projectId;
|
||||
|
@ -269,12 +267,10 @@ protected ProjectBuildingException( String projectId, String message, String pom
|
|||
{
|
||||
super( message, cause );
|
||||
this.projectId = projectId;
|
||||
pomFile = new File ( pomLocation );
|
||||
pomFile = new File( pomLocation );
|
||||
}
|
||||
|
||||
public ProjectBuildingException( String projectId,
|
||||
String message,
|
||||
ModelInterpolationException cause )
|
||||
public ProjectBuildingException( String projectId, String message, ModelInterpolationException cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.projectId = projectId;
|
||||
|
@ -288,7 +284,7 @@ public File getPomFile()
|
|||
/**
|
||||
* @deprecated use {@link #getPomFile()}
|
||||
*/
|
||||
public String getPomLocation ()
|
||||
public String getPomLocation()
|
||||
{
|
||||
if ( getPomFile() != null )
|
||||
{
|
||||
|
@ -307,7 +303,7 @@ public String getProjectId()
|
|||
|
||||
public String getMessage()
|
||||
{
|
||||
return super.getMessage() + " for project " + projectId
|
||||
+ ( ( getPomFile() == null ? "" : " at " + getPomFile().getAbsolutePath() ) );
|
||||
return super.getMessage() + " for project " + projectId +
|
||||
( ( getPomFile() == null ? "" : " at " + getPomFile().getAbsolutePath() ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,248 +0,0 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* 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.ArtifactUtils;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
import org.codehaus.plexus.util.dag.DAG;
|
||||
import org.codehaus.plexus.util.dag.TopologicalSorter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Sort projects by dependencies.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectSorter
|
||||
{
|
||||
private final DAG dag;
|
||||
|
||||
private final List sortedProjects;
|
||||
|
||||
private MavenProject topLevelProject;
|
||||
|
||||
/**
|
||||
* Sort a list of projects.
|
||||
* <ul>
|
||||
* <li>collect all the vertices for the projects that we want to build.</li>
|
||||
* <li>iterate through the deps of each project and if that dep is within
|
||||
* the set of projects we want to build then add an edge, otherwise throw
|
||||
* the edge away because that dependency is not within the set of projects
|
||||
* we are trying to build. we assume a closed set.</li>
|
||||
* <li>do a topo sort on the graph that remains.</li>
|
||||
* </ul>
|
||||
* @throws DuplicateProjectException if any projects are duplicated by id
|
||||
*/
|
||||
// MAVENAPI FIXME: the DAG used is NOT only used to represent the dependency relation,
|
||||
// but also for <parent>, <build><plugin>, <reports>. We need multiple DAG's
|
||||
// since a DAG can only handle 1 type of relationship properly.
|
||||
// Usecase: This is detected as a cycle:
|
||||
// org.apache.maven:maven-plugin-api -(PARENT)->
|
||||
// org.apache.maven:maven -(inherited REPORTING)->
|
||||
// org.apache.maven.plugins:maven-checkstyle-plugin -(DEPENDENCY)->
|
||||
// org.apache.maven:maven-plugin-api
|
||||
// In this case, both the verify and the report goals are called
|
||||
// in a different lifecycle. Though the compiler-plugin has a valid usecase, although
|
||||
// that seems to work fine. We need to take versions and lifecycle into account.
|
||||
public ProjectSorter( List projects )
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
{
|
||||
dag = new DAG();
|
||||
|
||||
Map projectMap = new HashMap();
|
||||
|
||||
for ( Iterator i = projects.iterator(); i.hasNext(); )
|
||||
{
|
||||
MavenProject project = (MavenProject) i.next();
|
||||
|
||||
String id = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
|
||||
|
||||
if ( dag.getVertex( id ) != null )
|
||||
{
|
||||
MavenProject conflictingProject = (MavenProject) projectMap.get( id );
|
||||
|
||||
throw new DuplicateProjectException( id,
|
||||
conflictingProject.getFile(),
|
||||
project.getFile(),
|
||||
"Project '"
|
||||
+ id
|
||||
+ "' is duplicated in the reactor" );
|
||||
}
|
||||
|
||||
dag.addVertex( id );
|
||||
|
||||
projectMap.put( id, project );
|
||||
}
|
||||
|
||||
for ( Iterator i = projects.iterator(); i.hasNext(); )
|
||||
{
|
||||
MavenProject project = (MavenProject) i.next();
|
||||
|
||||
String id = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
|
||||
|
||||
for ( Iterator j = project.getDependencies().iterator(); j.hasNext(); )
|
||||
{
|
||||
Dependency dependency = (Dependency) j.next();
|
||||
|
||||
String dependencyId = ArtifactUtils
|
||||
.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() );
|
||||
|
||||
if ( dag.getVertex( dependencyId ) != null )
|
||||
{
|
||||
project.addProjectReference( (MavenProject) projectMap.get( dependencyId ) );
|
||||
|
||||
dag.addEdge( id, dependencyId );
|
||||
}
|
||||
}
|
||||
|
||||
MavenProject parent = project.getParent();
|
||||
if ( parent != null )
|
||||
{
|
||||
String parentId = ArtifactUtils.versionlessKey( parent.getGroupId(), parent.getArtifactId() );
|
||||
if ( dag.getVertex( parentId ) != null )
|
||||
{
|
||||
// Parent is added as an edge, but must not cause a cycle - so we remove any other edges it has in conflict
|
||||
if ( dag.hasEdge( parentId, id ) )
|
||||
{
|
||||
dag.removeEdge( parentId, id );
|
||||
}
|
||||
dag.addEdge( id, parentId );
|
||||
}
|
||||
}
|
||||
|
||||
List buildPlugins = project.getBuildPlugins();
|
||||
if ( buildPlugins != null )
|
||||
{
|
||||
for ( Iterator j = buildPlugins.iterator(); j.hasNext(); )
|
||||
{
|
||||
Plugin plugin = (Plugin) j.next();
|
||||
String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() );
|
||||
if ( ( dag.getVertex( pluginId ) != null ) && !pluginId.equals( id ) )
|
||||
{
|
||||
addEdgeWithParentCheck( projectMap, pluginId, project, id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List reportPlugins = project.getReportPlugins();
|
||||
if ( reportPlugins != null )
|
||||
{
|
||||
for ( Iterator j = reportPlugins.iterator(); j.hasNext(); )
|
||||
{
|
||||
ReportPlugin plugin = (ReportPlugin) j.next();
|
||||
String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() );
|
||||
if ( ( dag.getVertex( pluginId ) != null ) && !pluginId.equals( id ) )
|
||||
{
|
||||
addEdgeWithParentCheck( projectMap, pluginId, project, id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( Iterator j = project.getBuildExtensions().iterator(); j.hasNext(); )
|
||||
{
|
||||
Extension extension = (Extension) j.next();
|
||||
String extensionId = ArtifactUtils.versionlessKey( extension.getGroupId(), extension.getArtifactId() );
|
||||
if ( dag.getVertex( extensionId ) != null )
|
||||
{
|
||||
addEdgeWithParentCheck( projectMap, extensionId, project, id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List sortedProjects = new ArrayList();
|
||||
|
||||
for ( Iterator i = TopologicalSorter.sort( dag ).iterator(); i.hasNext(); )
|
||||
{
|
||||
String id = (String) i.next();
|
||||
|
||||
sortedProjects.add( projectMap.get( id ) );
|
||||
}
|
||||
|
||||
this.sortedProjects = Collections.unmodifiableList( sortedProjects );
|
||||
}
|
||||
|
||||
private void addEdgeWithParentCheck( Map projectMap, String projectRefId, MavenProject project, String id )
|
||||
throws CycleDetectedException
|
||||
{
|
||||
MavenProject extProject = (MavenProject) projectMap.get( projectRefId );
|
||||
|
||||
if ( extProject == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
project.addProjectReference( extProject );
|
||||
|
||||
MavenProject extParent = extProject.getParent();
|
||||
if ( extParent != null )
|
||||
{
|
||||
String parentId = ArtifactUtils.versionlessKey( extParent.getGroupId(), extParent.getArtifactId() );
|
||||
// Don't add edge from parent to extension if a reverse edge already exists
|
||||
if ( !dag.hasEdge( projectRefId, id ) || !parentId.equals( id ) )
|
||||
{
|
||||
dag.addEdge( id, projectRefId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: !![jc; 28-jul-2005] check this; if we're using '-r' and there are aggregator tasks, this will result in weirdness.
|
||||
public MavenProject getTopLevelProject()
|
||||
{
|
||||
if ( topLevelProject == null )
|
||||
{
|
||||
for ( Iterator i = sortedProjects.iterator(); i.hasNext() && ( topLevelProject == null ); )
|
||||
{
|
||||
MavenProject project = (MavenProject) i.next();
|
||||
if ( project.isExecutionRoot() )
|
||||
{
|
||||
topLevelProject = project;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return topLevelProject;
|
||||
}
|
||||
|
||||
public List getSortedProjects()
|
||||
{
|
||||
return sortedProjects;
|
||||
}
|
||||
|
||||
public boolean hasMultipleProjects()
|
||||
{
|
||||
return sortedProjects.size() > 1;
|
||||
}
|
||||
|
||||
public List getDependents( String id )
|
||||
{
|
||||
return dag.getParentLabels( id );
|
||||
}
|
||||
}
|
|
@ -97,7 +97,8 @@ public static ArtifactRepository buildArtifactRepository( Repository repo,
|
|||
|
||||
if ( url == null || url.trim().length() < 1 )
|
||||
{
|
||||
throw new MissingRepositoryElementException( "Repository URL must not be empty (ID is: " + id + ").", id );
|
||||
throw new MissingRepositoryElementException( "Repository URL must not be empty (ID is: " + id + ").",
|
||||
id );
|
||||
}
|
||||
|
||||
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationContext;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is a temporary class. These methods are originally from the DefaultMavenProjectHelper. This class will be
|
||||
* eliminated when Mercury is integrated.
|
||||
*/
|
||||
public interface RepositoryHelper
|
||||
{
|
||||
|
||||
String ROLE = RepositoryHelper.class.getName();
|
||||
|
||||
Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
List buildArtifactRepositories( Model model )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
LinkedHashSet collectInitialRepositories( Model model, Model superModel, List parentSearchRepositories,
|
||||
File pomFile, boolean validProfilesXmlLocation,
|
||||
ProfileActivationContext profileActivationContext )
|
||||
throws ProjectBuildingException;
|
||||
}
|
|
@ -58,293 +58,389 @@ public ActiveProjectArtifact( MavenProject project, Artifact artifact )
|
|||
artifact.setResolved( true );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public File getFile()
|
||||
{
|
||||
// we need to get the latest file for the project, not the artifact that was created at one point in time
|
||||
return project.getArtifact().getFile();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getGroupId()
|
||||
{
|
||||
return artifact.getGroupId();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getArtifactId()
|
||||
{
|
||||
return artifact.getArtifactId();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
return artifact.getVersion();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setVersion( String version )
|
||||
{
|
||||
artifact.setVersion( version );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getScope()
|
||||
{
|
||||
return artifact.getScope();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return artifact.getType();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getClassifier()
|
||||
{
|
||||
return artifact.getClassifier();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean hasClassifier()
|
||||
{
|
||||
return artifact.hasClassifier();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setFile( File destination )
|
||||
{
|
||||
artifact.setFile( destination );
|
||||
project.getArtifact().setFile( destination );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getBaseVersion()
|
||||
{
|
||||
return artifact.getBaseVersion();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setBaseVersion( String baseVersion )
|
||||
{
|
||||
artifact.setBaseVersion( baseVersion );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return artifact.getId();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getDependencyConflictId()
|
||||
{
|
||||
return artifact.getDependencyConflictId();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMetadata( ArtifactMetadata metadata )
|
||||
{
|
||||
artifact.addMetadata( metadata );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Collection getMetadataList()
|
||||
{
|
||||
return artifact.getMetadataList();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setRepository( ArtifactRepository remoteRepository )
|
||||
{
|
||||
artifact.setRepository( remoteRepository );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ArtifactRepository getRepository()
|
||||
{
|
||||
return artifact.getRepository();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void updateVersion( String version, ArtifactRepository localRepository )
|
||||
{
|
||||
artifact.updateVersion( version, localRepository );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getDownloadUrl()
|
||||
{
|
||||
return artifact.getDownloadUrl();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setDownloadUrl( String downloadUrl )
|
||||
{
|
||||
artifact.setDownloadUrl( downloadUrl );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ArtifactFilter getDependencyFilter()
|
||||
{
|
||||
return artifact.getDependencyFilter();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setDependencyFilter( ArtifactFilter artifactFilter )
|
||||
{
|
||||
artifact.setDependencyFilter( artifactFilter );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ArtifactHandler getArtifactHandler()
|
||||
{
|
||||
return artifact.getArtifactHandler();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List getDependencyTrail()
|
||||
{
|
||||
return artifact.getDependencyTrail();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setDependencyTrail( List dependencyTrail )
|
||||
{
|
||||
artifact.setDependencyTrail( dependencyTrail );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setScope( String scope )
|
||||
{
|
||||
artifact.setScope( scope );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public VersionRange getVersionRange()
|
||||
{
|
||||
return artifact.getVersionRange();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setVersionRange( VersionRange newRange )
|
||||
{
|
||||
artifact.setVersionRange( newRange );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void selectVersion( String version )
|
||||
{
|
||||
artifact.selectVersion( version );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
artifact.setGroupId( groupId );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
artifact.setArtifactId( artifactId );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isSnapshot()
|
||||
{
|
||||
return artifact.isSnapshot();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int compareTo( Object o )
|
||||
{
|
||||
return artifact.compareTo( o );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setResolved( boolean resolved )
|
||||
{
|
||||
artifact.setResolved( resolved );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isResolved()
|
||||
{
|
||||
return artifact.isResolved();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setResolvedVersion( String version )
|
||||
{
|
||||
artifact.setResolvedVersion( version );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setArtifactHandler( ArtifactHandler handler )
|
||||
{
|
||||
artifact.setArtifactHandler( handler );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return "active project artifact:\n\tartifact = " + artifact + ";\n\tproject: " + project;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isRelease()
|
||||
{
|
||||
return artifact.isRelease();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setRelease( boolean release )
|
||||
{
|
||||
artifact.setRelease( release );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List getAvailableVersions()
|
||||
{
|
||||
return artifact.getAvailableVersions();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setAvailableVersions( List versions )
|
||||
{
|
||||
artifact.setAvailableVersions( versions );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isOptional()
|
||||
{
|
||||
return artifact.isOptional();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ArtifactVersion getSelectedVersion()
|
||||
throws OverConstrainedVersionException
|
||||
{
|
||||
return artifact.getSelectedVersion();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isSelectedVersionKnown()
|
||||
throws OverConstrainedVersionException
|
||||
{
|
||||
return artifact.isSelectedVersionKnown();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setOptional( boolean optional )
|
||||
{
|
||||
artifact.setOptional( optional );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
int result = 17;
|
||||
|
@ -361,7 +457,9 @@ public int hashCode()
|
|||
return result;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if ( o == this )
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
package org.apache.maven.project.artifact;
|
||||
|
||||
/*
|
||||
* 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.DefaultArtifact;
|
||||
import org.apache.maven.artifact.InvalidArtifactRTException;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AttachedArtifact
|
||||
extends DefaultArtifact
|
||||
{
|
||||
|
||||
private final Artifact parent;
|
||||
|
||||
public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler )
|
||||
{
|
||||
super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
|
||||
classifier, artifactHandler, parent.isOptional() );
|
||||
|
||||
setDependencyTrail( Collections.singletonList( parent.getId() ) );
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
if ( getId().equals( parent.getId() ) )
|
||||
{
|
||||
throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parent.getType(), "An attached artifact must have a different ID than its corresponding main artifact." );
|
||||
}
|
||||
}
|
||||
|
||||
public AttachedArtifact( Artifact parent, String type, ArtifactHandler artifactHandler )
|
||||
{
|
||||
this( parent, type, null, artifactHandler );
|
||||
}
|
||||
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public List getAvailableVersions()
|
||||
{
|
||||
return parent.getAvailableVersions();
|
||||
}
|
||||
|
||||
public void setAvailableVersions( List availableVersions )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getBaseVersion()
|
||||
{
|
||||
return parent.getBaseVersion();
|
||||
}
|
||||
|
||||
public void setBaseVersion( String baseVersion )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getDownloadUrl()
|
||||
{
|
||||
return parent.getDownloadUrl();
|
||||
}
|
||||
|
||||
public void setDownloadUrl( String downloadUrl )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public ArtifactRepository getRepository()
|
||||
{
|
||||
return parent.getRepository();
|
||||
}
|
||||
|
||||
public void setRepository( ArtifactRepository repository )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getScope()
|
||||
{
|
||||
return parent.getScope();
|
||||
}
|
||||
|
||||
public void setScope( String scope )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return parent.getVersion();
|
||||
}
|
||||
|
||||
public void setVersion( String version )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public VersionRange getVersionRange()
|
||||
{
|
||||
return parent.getVersionRange();
|
||||
}
|
||||
|
||||
public void setVersionRange( VersionRange range )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public boolean isRelease()
|
||||
{
|
||||
return parent.isRelease();
|
||||
}
|
||||
|
||||
public void setRelease( boolean release )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public boolean isSnapshot()
|
||||
{
|
||||
return parent.isSnapshot();
|
||||
}
|
||||
|
||||
public void addMetadata( ArtifactMetadata metadata )
|
||||
{
|
||||
// ignore. The parent artifact will handle metadata.
|
||||
// we must fail silently here to avoid problems with the artifact transformers.
|
||||
}
|
||||
|
||||
public Collection getMetadataList()
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
}
|
|
@ -37,7 +37,8 @@ public class InvalidDependencyVersionException
|
|||
{
|
||||
private Dependency dependency;
|
||||
|
||||
public InvalidDependencyVersionException( String projectId, Dependency dependency, File pomFile, InvalidVersionSpecificationException cause )
|
||||
public InvalidDependencyVersionException( String projectId, Dependency dependency, File pomFile,
|
||||
InvalidVersionSpecificationException cause )
|
||||
{
|
||||
super( projectId, formatLocationInPom( dependency ), dependency.getVersion(), pomFile, cause );
|
||||
this.dependency = dependency;
|
||||
|
|
|
@ -85,14 +85,15 @@ public class MavenMetadataSource
|
|||
|
||||
private PlexusContainer container;
|
||||
|
||||
/** Unfortunately we have projects that are still sending us JARs without the accompanying POMs. */
|
||||
/**
|
||||
* Unfortunately we have projects that are still sending us JARs without the accompanying POMs.
|
||||
*/
|
||||
private boolean strictlyEnforceThePresenceOfAValidMavenPOM = false;
|
||||
|
||||
/**
|
||||
* Resolve all relocations in the POM for this artifact, and return the new artifact coordinate.
|
||||
*/
|
||||
public Artifact retrieveRelocatedArtifact( Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
|
@ -114,7 +115,6 @@ public Artifact retrieveRelocatedArtifact( Artifact artifact,
|
|||
return artifact;
|
||||
}
|
||||
|
||||
|
||||
// NOTE: Using artifact information here, since some POMs are deployed
|
||||
// to central with one version in the filename, but another in the <version> string!
|
||||
// Case in point: org.apache.ws.commons:XmlSchema:1.1:pom.
|
||||
|
@ -124,11 +124,14 @@ public Artifact retrieveRelocatedArtifact( Artifact artifact,
|
|||
Artifact result = null;
|
||||
if ( artifact.getClassifier() != null )
|
||||
{
|
||||
result = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier() );
|
||||
result = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(),
|
||||
artifact.getVersion(), artifact.getType(),
|
||||
artifact.getClassifier() );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope(), artifact.getType() );
|
||||
result = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
|
||||
artifact.getVersion(), artifact.getScope(), artifact.getType() );
|
||||
}
|
||||
|
||||
result.setScope( artifact.getScope() );
|
||||
|
@ -146,9 +149,8 @@ private String getRelocationKey( Artifact artifact )
|
|||
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();
|
||||
}
|
||||
|
||||
private ProjectRelocation retrieveRelocatedProject( Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
private ProjectRelocation retrieveRelocatedProject( Artifact artifact, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
if ( remoteRepositories == null )
|
||||
|
@ -162,7 +164,8 @@ private ProjectRelocation retrieveRelocatedProject( Artifact artifact,
|
|||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Cannot lookup MavenProjectBuilder component instance: " + e.getMessage(), e );
|
||||
throw new ArtifactMetadataRetrievalException(
|
||||
"Cannot lookup MavenProjectBuilder component instance: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
MavenProject project = null;
|
||||
|
@ -183,7 +186,8 @@ private ProjectRelocation retrieveRelocatedProject( Artifact artifact,
|
|||
{
|
||||
try
|
||||
{
|
||||
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
|
||||
project =
|
||||
mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
|
||||
}
|
||||
catch ( InvalidProjectModelException e )
|
||||
{
|
||||
|
@ -261,8 +265,8 @@ private ProjectRelocation retrieveRelocatedProject( Artifact artifact,
|
|||
List available = artifact.getAvailableVersions();
|
||||
if ( available != null && !available.isEmpty() )
|
||||
{
|
||||
artifact.setAvailableVersions( retrieveAvailableVersions( artifact, localRepository,
|
||||
remoteRepositories ) );
|
||||
artifact.setAvailableVersions(
|
||||
retrieveAvailableVersions( artifact, localRepository, remoteRepositories ) );
|
||||
|
||||
}
|
||||
|
||||
|
@ -274,7 +278,8 @@ private ProjectRelocation retrieveRelocatedProject( Artifact artifact,
|
|||
message += " " + relocation.getMessage() + "\n";
|
||||
}
|
||||
|
||||
if ( ( artifact.getDependencyTrail() != null ) && ( artifact.getDependencyTrail().size() == 1 ) )
|
||||
if ( ( artifact.getDependencyTrail() != null ) &&
|
||||
( artifact.getDependencyTrail().size() == 1 ) )
|
||||
{
|
||||
getLogger().warn( "While downloading " + artifact.getGroupId() + ":" +
|
||||
artifact.getArtifactId() + ":" + artifact.getVersion() + message + "\n" );
|
||||
|
@ -342,8 +347,8 @@ public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepo
|
|||
// or used the inherited scope (should that be passed to the buildFromRepository method above?)
|
||||
try
|
||||
{
|
||||
artifacts = project.createArtifacts( artifactFactory, artifact.getScope(),
|
||||
artifact.getDependencyFilter() );
|
||||
artifacts =
|
||||
project.createArtifacts( artifactFactory, artifact.getScope(), artifact.getDependencyFilter() );
|
||||
}
|
||||
catch ( InvalidDependencyVersionException e )
|
||||
{
|
||||
|
@ -365,17 +370,16 @@ private void handleInvalidOrMissingMavenPOM( Artifact artifact, ProjectBuildingE
|
|||
{
|
||||
if ( strictlyEnforceThePresenceOfAValidMavenPOM )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Invalid POM file for artifact: '" +
|
||||
artifact.getDependencyConflictId() + "': " + e.getMessage(), e, artifact );
|
||||
throw new ArtifactMetadataRetrievalException(
|
||||
"Invalid POM file for artifact: '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e,
|
||||
artifact );
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().warn(
|
||||
"\n\tDEPRECATION: The POM for the artifact '"
|
||||
+ artifact.getDependencyConflictId()
|
||||
+ "' was invalid or not found on any repositories.\n"
|
||||
+ "\tThis may not be supported by future versions of Maven and should be corrected as soon as possible.\n"
|
||||
+ "\tError given: " + e.getMessage() + "\n" );
|
||||
getLogger().warn( "\n\tDEPRECATION: The POM for the artifact '" + artifact.getDependencyConflictId() +
|
||||
"' was invalid or not found on any repositories.\n" +
|
||||
"\tThis may not be supported by future versions of Maven and should be corrected as soon as possible.\n" +
|
||||
"\tError given: " + e.getMessage() + "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,11 +450,12 @@ private List aggregateRepositoryLists( List remoteRepositories, List remoteArtif
|
|||
}
|
||||
|
||||
/**
|
||||
* @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific
|
||||
* @return {@link Set} < {@link Artifact} >
|
||||
* @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific
|
||||
*/
|
||||
public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> dependencies, String inheritedScope,
|
||||
ArtifactFilter dependencyFilter, MavenProject project )
|
||||
public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> dependencies,
|
||||
String inheritedScope, ArtifactFilter dependencyFilter,
|
||||
MavenProject project )
|
||||
throws InvalidDependencyVersionException
|
||||
{
|
||||
Set<Artifact> projectArtifacts = new LinkedHashSet<Artifact>( dependencies.size() );
|
||||
|
@ -545,8 +550,7 @@ public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, Artif
|
|||
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );
|
||||
}
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
|
||||
Artifact artifact,
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
ArtifactRepository deploymentRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
|
@ -578,7 +582,7 @@ private List<ArtifactVersion> retrieveAvailableVersionsFromMetadata( Metadata re
|
|||
}
|
||||
else
|
||||
{
|
||||
versions = Collections.<ArtifactVersion> emptyList();
|
||||
versions = Collections.<ArtifactVersion>emptyList();
|
||||
}
|
||||
|
||||
return versions;
|
||||
|
@ -593,6 +597,7 @@ public void contextualize( Context context )
|
|||
private static final class ProjectRelocation
|
||||
{
|
||||
private MavenProject project;
|
||||
|
||||
private Artifact pomArtifact;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,206 +0,0 @@
|
|||
package org.apache.maven.project.artifact;
|
||||
|
||||
/*
|
||||
* 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.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.resolver.metadata.MetadataResolution;
|
||||
import org.apache.maven.artifact.resolver.metadata.MetadataRetrievalException;
|
||||
import org.apache.maven.artifact.resolver.metadata.MetadataSource;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.project.InvalidProjectModelException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.context.Context;
|
||||
import org.codehaus.plexus.context.ContextException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PomMetadataSource
|
||||
extends AbstractLogEnabled
|
||||
implements MetadataSource,
|
||||
Contextualizable
|
||||
{
|
||||
public static final String ROLE_HINT = "default";
|
||||
|
||||
private MavenProjectBuilder mavenProjectBuilder;
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
// lazily instantiated and cached.
|
||||
private MavenProject superProject;
|
||||
|
||||
private PlexusContainer container;
|
||||
|
||||
/** Unfortunately we have projects that are still sending us JARs without the accompanying POMs. */
|
||||
private boolean strictlyEnforceThePresenceOfAValidMavenPOM = true;
|
||||
|
||||
public MetadataResolution retrieve( ArtifactMetadata artifactMetadata,
|
||||
ArtifactRepository localRepository,
|
||||
List remoteRepositories )
|
||||
throws MetadataRetrievalException
|
||||
{
|
||||
try
|
||||
{
|
||||
loadProjectBuilder();
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new MetadataRetrievalException(
|
||||
"Cannot lookup MavenProjectBuilder component instance: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
MavenProject project = null;
|
||||
|
||||
Artifact pomArtifact = artifactFactory.createProjectArtifact(
|
||||
artifactMetadata.getGroupId()
|
||||
, artifactMetadata.getArtifactId()
|
||||
, artifactMetadata.getVersion()
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
|
||||
if ( pomArtifact.getFile() != null )
|
||||
{
|
||||
artifactMetadata.setArtifactUri( pomArtifact.getFile().toURI().toString() );
|
||||
}
|
||||
}
|
||||
catch ( InvalidProjectModelException e )
|
||||
{
|
||||
// We want to capture this in the graph so that we can display the error to the user
|
||||
artifactMetadata.setError( e.getMessage() );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
if ( strictlyEnforceThePresenceOfAValidMavenPOM )
|
||||
{
|
||||
throw new MetadataRetrievalException(
|
||||
"Unable to read the metadata file for artifactMetadata '" +
|
||||
artifactMetadata.getDependencyConflictId() + "': " + e.getMessage(), e, artifactMetadata );
|
||||
}
|
||||
}
|
||||
|
||||
Set artifacts = new HashSet();
|
||||
|
||||
for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
|
||||
{
|
||||
Dependency d = (Dependency) i.next();
|
||||
|
||||
artifacts.add( new ArtifactMetadata( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getType(),
|
||||
d.getScope(), d.getClassifier(), null, null, false, null ) );
|
||||
}
|
||||
|
||||
// The remote repositories is intentially null here while working in the graph in the least invasive way
|
||||
// and making sure repositories added for a POM are scope only for a particular POM. We don't want
|
||||
// repositories lingering around or being aggregated after they are used. jvz
|
||||
|
||||
artifactMetadata.setDependencies( artifacts );
|
||||
|
||||
return new MetadataResolution( artifactMetadata );
|
||||
}
|
||||
|
||||
private void loadProjectBuilder()
|
||||
throws ComponentLookupException
|
||||
{
|
||||
if ( mavenProjectBuilder == null )
|
||||
{
|
||||
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.class );
|
||||
}
|
||||
}
|
||||
|
||||
private List aggregateRepositoryLists( List remoteRepositories,
|
||||
List remoteArtifactRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
if ( superProject == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
superProject = mavenProjectBuilder.buildStandaloneSuperProject();
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException(
|
||||
"Unable to parse the Maven built-in model: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
List repositories = new ArrayList();
|
||||
|
||||
repositories.addAll( remoteRepositories );
|
||||
|
||||
// ensure that these are defined
|
||||
for ( Iterator it = superProject.getRemoteArtifactRepositories().iterator(); it.hasNext(); )
|
||||
{
|
||||
ArtifactRepository superRepo = (ArtifactRepository) it.next();
|
||||
|
||||
for ( Iterator aggregatedIterator = repositories.iterator(); aggregatedIterator.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repo = (ArtifactRepository) aggregatedIterator.next();
|
||||
|
||||
// if the repository exists in the list and was introduced by another POM's super-pom,
|
||||
// remove it...the repository definitions from the super-POM should only be at the end of
|
||||
// the list.
|
||||
// if the repository has been redefined, leave it.
|
||||
if ( repo.getId().equals( superRepo.getId() ) && repo.getUrl().equals( superRepo.getUrl() ) )
|
||||
{
|
||||
aggregatedIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this list should contain the super-POM repositories, so we don't have to explicitly add them back.
|
||||
for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) it.next();
|
||||
|
||||
if ( !repositories.contains( repository ) )
|
||||
{
|
||||
repositories.add( repository );
|
||||
}
|
||||
}
|
||||
|
||||
return repositories;
|
||||
}
|
||||
|
||||
public void contextualize( Context context )
|
||||
throws ContextException
|
||||
{
|
||||
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||
}
|
||||
}
|
|
@ -45,8 +45,7 @@ public ProjectArtifactMetadata( Artifact artifact )
|
|||
this( artifact, null );
|
||||
}
|
||||
|
||||
public ProjectArtifactMetadata( Artifact artifact,
|
||||
File file )
|
||||
public ProjectArtifactMetadata( Artifact artifact, File file )
|
||||
{
|
||||
super( artifact );
|
||||
this.file = file;
|
||||
|
@ -67,8 +66,7 @@ private String getFilename()
|
|||
return getArtifactId() + "-" + artifact.getVersion() + ".pom";
|
||||
}
|
||||
|
||||
public void storeInLocalRepository( ArtifactRepository localRepository,
|
||||
ArtifactRepository remoteRepository )
|
||||
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||
throws RepositoryMetadataStoreException
|
||||
{
|
||||
File destination = new File( localRepository.getBasedir(),
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package org.apache.maven.project.build.model;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ModelAndFile
|
||||
{
|
||||
|
||||
private final Model model;
|
||||
|
||||
private final File file;
|
||||
|
||||
private final boolean validProfilesXmlLocation;
|
||||
|
||||
public ModelAndFile( Model model,
|
||||
File file,
|
||||
boolean validProfilesXmlLocation )
|
||||
{
|
||||
this.model = model;
|
||||
this.file = file;
|
||||
this.validProfilesXmlLocation = validProfilesXmlLocation;
|
||||
}
|
||||
|
||||
public Model getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
public boolean isValidProfilesXmlLocation()
|
||||
{
|
||||
return validProfilesXmlLocation;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return model.getId() + "@" + file;
|
||||
}
|
||||
|
||||
}
|
|
@ -72,26 +72,40 @@ private static class ArtifactModelContainer
|
|||
|
||||
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 );
|
||||
String uri = findBaseUriFrom( this.properties );
|
||||
|
||||
for ( ModelProperty mp : properties )
|
||||
for ( ModelProperty mp : this.properties )
|
||||
{
|
||||
if ( mp.getUri().endsWith( "version" ) )
|
||||
if ( version == null && mp.getUri().equals( uri + "/version" ) )
|
||||
{
|
||||
this.version = mp.getValue();
|
||||
}
|
||||
else if ( mp.getUri().endsWith( "artifactId" ) )
|
||||
else if ( artifactId == null && mp.getUri().equals( uri + "/artifactId" ) )
|
||||
{
|
||||
this.artifactId = mp.getValue();
|
||||
}
|
||||
else if ( mp.getUri().endsWith( "groupId" ) )
|
||||
else if ( groupId == null && mp.getUri().equals( uri + "/groupId" ) )
|
||||
{
|
||||
this.groupId = mp.getValue();
|
||||
}
|
||||
else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.type ) )
|
||||
else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.type ) && type == null )
|
||||
{
|
||||
this.type = mp.getValue();
|
||||
}
|
||||
|
@ -105,8 +119,13 @@ else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.type ) )
|
|||
|
||||
if ( artifactId == null )
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Properties does not contain artifact id. Group ID = " + groupId + ", Version = " + version );
|
||||
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 + ":" + sb );
|
||||
}
|
||||
|
||||
if ( type == null )
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Writer;
|
||||
|
@ -59,6 +61,10 @@ public final class PomClassicDomainModel
|
|||
|
||||
private String id;
|
||||
|
||||
private File file;
|
||||
|
||||
private File parentFile;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -73,10 +79,20 @@ public PomClassicDomainModel( Model model )
|
|||
throw new IllegalArgumentException( "model: null" );
|
||||
}
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Writer out = WriterFactory.newXmlWriter( baos );
|
||||
Writer out = null;
|
||||
MavenXpp3Writer writer = new MavenXpp3Writer();
|
||||
writer.write( out, model );
|
||||
out.close();
|
||||
try
|
||||
{
|
||||
out = WriterFactory.newXmlWriter( baos );
|
||||
writer.write( out, model );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( out != null )
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
inputBytes = baos.toByteArray();
|
||||
}
|
||||
|
||||
|
@ -96,6 +112,22 @@ public PomClassicDomainModel( InputStream inputStream )
|
|||
this.inputBytes = IOUtil.toByteArray( inputStream );
|
||||
}
|
||||
|
||||
public PomClassicDomainModel( File file )
|
||||
throws IOException
|
||||
{
|
||||
this( new FileInputStream( file ) );
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public File getParentFile()
|
||||
{
|
||||
return parentFile;
|
||||
}
|
||||
|
||||
public void setParentFile( File parentFile )
|
||||
{
|
||||
this.parentFile = parentFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if groupId.equals(a.groupId) && artifactId.equals(a.artifactId) && version.equals(a.version),
|
||||
|
@ -140,10 +172,15 @@ public String getId()
|
|||
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();
|
||||
String groupId = ( model.getGroupId() == null && model.getParent() != null )
|
||||
? model.getParent().getGroupId()
|
||||
: model.getGroupId();
|
||||
String artifactId = ( model.getArtifactId() == null && model.getParent() != null )
|
||||
? model.getParent().getArtifactId()
|
||||
: model.getArtifactId();
|
||||
String version = ( model.getVersion() == null && model.getParent() != null )
|
||||
? model.getParent().getVersion()
|
||||
: model.getVersion();
|
||||
|
||||
id = groupId + ":" + artifactId + ":" + version;
|
||||
}
|
||||
|
@ -211,6 +248,14 @@ public InputStream getInputStream()
|
|||
return new ByteArrayInputStream( copy );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return file of pom. May be null.
|
||||
*/
|
||||
public File getFile()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.maven.shared.model.DomainModel#getEventHistory()
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
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.ModelContainerAction;
|
||||
import org.apache.maven.shared.model.ModelDataSource;
|
||||
import org.apache.maven.shared.model.ModelMarshaller;
|
||||
import org.apache.maven.shared.model.ModelProperty;
|
||||
|
@ -33,11 +34,12 @@
|
|||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Provides methods for transforming model properties into a domain model for the pom classic format and vice versa.
|
||||
|
@ -49,71 +51,77 @@ public final class PomClassicTransformer
|
|||
/**
|
||||
* The URIs this tranformer supports
|
||||
*/
|
||||
private final Set<String> uris;
|
||||
private static Set<String> uris = new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
|
||||
ProjectUri.Build.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" ) );
|
||||
|
||||
private static Map<String, List<ModelProperty>> cache = new HashMap<String, List<ModelProperty>>();
|
||||
|
||||
private Collection<Profile> profiles;
|
||||
|
||||
//private static List<DomainModel> cache = new ArrayList<DomainModel>();
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public PomClassicTransformer()
|
||||
public PomClassicTransformer( Collection<Profile> profiles )
|
||||
{
|
||||
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" ) );
|
||||
this.profiles = profiles;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,6 +148,102 @@ public DomainModel transformToDomainModel( List<ModelProperty> properties )
|
|||
}
|
||||
}
|
||||
|
||||
//dependency management
|
||||
ModelDataSource source = new DefaultModelDataSource();
|
||||
source.init( props, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
||||
|
||||
for ( ModelContainer dependencyContainer : source.queryFor( ProjectUri.Dependencies.Dependency.xUri ) )
|
||||
{
|
||||
for ( ModelContainer managementContainer : source.queryFor(
|
||||
ProjectUri.DependencyManagement.Dependencies.Dependency.xUri ) )
|
||||
{
|
||||
managementContainer = new ArtifactModelContainerFactory().create(
|
||||
transformDependencyManagement( managementContainer.getProperties() ) );
|
||||
ModelContainerAction action = dependencyContainer.containerAction( managementContainer );
|
||||
if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) )
|
||||
{
|
||||
source.join( dependencyContainer, managementContainer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( ModelContainer dependencyContainer : source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri ) )
|
||||
{
|
||||
for ( ModelContainer managementContainer : source.queryFor(
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri ) )
|
||||
{
|
||||
managementContainer = new ArtifactModelContainerFactory().create(
|
||||
transformPluginManagement( managementContainer.getProperties() ) );
|
||||
|
||||
//Remove duplicate executions tags
|
||||
boolean hasExecutionsTag = false;
|
||||
for ( ModelProperty mp : dependencyContainer.getProperties() )
|
||||
{
|
||||
if ( mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.Executions.xUri ) )
|
||||
{
|
||||
hasExecutionsTag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<ModelProperty> pList = new ArrayList<ModelProperty>();
|
||||
if ( !hasExecutionsTag )
|
||||
{
|
||||
pList = managementContainer.getProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
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 = dependencyContainer.containerAction( managementContainer );
|
||||
if ( action.equals( ModelContainerAction.JOIN ) || action.equals( ModelContainerAction.DELETE ) )
|
||||
{
|
||||
source.join( dependencyContainer, managementContainer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
props = source.getModelProperties();
|
||||
|
||||
//Rule: Do not join plugin executions without ids
|
||||
Set<ModelProperty> removeProperties = new HashSet<ModelProperty>();
|
||||
ModelDataSource dataSource = new DefaultModelDataSource();
|
||||
dataSource.init( props, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
||||
List<ModelContainer> containers = dataSource.queryFor( ProjectUri.Build.Plugins.Plugin.xUri );
|
||||
for ( ModelContainer pluginContainer : containers )
|
||||
{
|
||||
ModelDataSource executionSource = new DefaultModelDataSource();
|
||||
executionSource.init( pluginContainer.getProperties(),
|
||||
Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
||||
List<ModelContainer> executionContainers =
|
||||
executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
|
||||
if ( executionContainers.size() < 2 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean hasAtLeastOneWithoutId = true;
|
||||
for ( ModelContainer executionContainer : executionContainers )
|
||||
{
|
||||
if ( hasAtLeastOneWithoutId )
|
||||
{
|
||||
hasAtLeastOneWithoutId = hasExecutionId( executionContainer );
|
||||
}
|
||||
if ( !hasAtLeastOneWithoutId && !hasExecutionId( executionContainer ) &&
|
||||
executionContainers.indexOf( executionContainer ) > 0 )
|
||||
{
|
||||
removeProperties.addAll( executionContainer.getProperties() );
|
||||
}
|
||||
}
|
||||
}
|
||||
props.removeAll( removeProperties );
|
||||
String xml = null;
|
||||
try
|
||||
{
|
||||
|
@ -150,7 +254,7 @@ public DomainModel transformToDomainModel( List<ModelProperty> properties )
|
|||
{
|
||||
throw new IOException( e + ":\r\n" + xml );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ModelTransformer#transformToModelProperties(java.util.List)
|
||||
|
@ -168,6 +272,11 @@ public List<ModelProperty> transformToModelProperties( List<DomainModel> domainM
|
|||
StringBuffer scmUrl = new StringBuffer();
|
||||
StringBuffer scmConnectionUrl = new StringBuffer();
|
||||
StringBuffer scmDeveloperUrl = new StringBuffer();
|
||||
|
||||
boolean containsBuildResources = false;
|
||||
boolean containsTestResources = false;
|
||||
boolean containsPluginRepositories = false;
|
||||
|
||||
for ( DomainModel domainModel : domainModels )
|
||||
{
|
||||
if ( !( domainModel instanceof PomClassicDomainModel ) )
|
||||
|
@ -185,6 +294,7 @@ public List<ModelProperty> transformToModelProperties( List<DomainModel> domainM
|
|||
|
||||
List<ModelProperty> tmp = ModelMarshaller.marshallXmlToModelProperties(
|
||||
( (PomClassicDomainModel) domainModel ).getInputStream(), ProjectUri.baseUri, uris );
|
||||
|
||||
List clearedProperties = new ArrayList<ModelProperty>();
|
||||
|
||||
//Missing Version Rule
|
||||
|
@ -320,25 +430,62 @@ public List<ModelProperty> transformToModelProperties( List<DomainModel> domainM
|
|||
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 ) ) )
|
||||
uri.equals( ProjectUri.packaging ) || uri.startsWith( ProjectUri.Profiles.xUri ) ) )
|
||||
{
|
||||
clearedProperties.add( mp );
|
||||
}
|
||||
}
|
||||
|
||||
//Remove Plugin Repository Inheritance Rule
|
||||
//Build Resources Inheritence Rule
|
||||
//Build Test Resources Inheritance Rule
|
||||
//Only inherit IF: the above is contained in super pom (domainModels.size() -1) && the child doesn't has it's own respective field
|
||||
if ( domainModels.indexOf( domainModel ) == 0 )
|
||||
{
|
||||
containsBuildResources = hasProjectUri( ProjectUri.Build.Resources.xUri, tmp );
|
||||
containsTestResources = hasProjectUri( ProjectUri.Build.TestResources.xUri, tmp );
|
||||
containsPluginRepositories = hasProjectUri( ProjectUri.PluginRepositories.xUri, tmp );
|
||||
}
|
||||
for ( ModelProperty mp : tmp )
|
||||
{
|
||||
if ( domainModels.indexOf( domainModel ) > 0 )
|
||||
{
|
||||
String uri = mp.getUri();
|
||||
boolean isNotSuperPom = domainModels.indexOf( domainModel ) != ( domainModels.size() - 1 );
|
||||
if ( isNotSuperPom )
|
||||
{
|
||||
if ( uri.startsWith( ProjectUri.Build.Resources.xUri ) ||
|
||||
uri.startsWith( ProjectUri.Build.TestResources.xUri ) ||
|
||||
uri.startsWith( ProjectUri.PluginRepositories.xUri ) )
|
||||
{
|
||||
clearedProperties.add( mp );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( containsBuildResources && uri.startsWith( ProjectUri.Build.Resources.xUri ) )
|
||||
{
|
||||
clearedProperties.add( mp );
|
||||
}
|
||||
else if ( containsTestResources && uri.startsWith( ProjectUri.Build.TestResources.xUri ) )
|
||||
{
|
||||
clearedProperties.add( mp );
|
||||
}
|
||||
else if ( containsPluginRepositories && uri.startsWith( ProjectUri.PluginRepositories.xUri ) )
|
||||
{
|
||||
clearedProperties.add( mp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModelProperty artifactId = getPropertyFor( ProjectUri.artifactId, tmp );
|
||||
if ( artifactId != null )
|
||||
{
|
||||
|
@ -347,8 +494,9 @@ public List<ModelProperty> transformToModelProperties( List<DomainModel> domainM
|
|||
|
||||
tmp.removeAll( clearedProperties );
|
||||
modelProperties.addAll( tmp );
|
||||
modelProperties.removeAll( clearedProperties );
|
||||
|
||||
if ( domainModels.indexOf( domainModel ) > 0 )
|
||||
if ( domainModels.indexOf( domainModel ) == 0 )
|
||||
{
|
||||
//cache.put( pomDomainModel.getId(), modelProperties );
|
||||
}
|
||||
|
@ -362,9 +510,22 @@ public List<ModelProperty> transformToModelProperties( List<DomainModel> domainM
|
|||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return modelProperties;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base uri of all model properties: http://apache.org/maven/project/
|
||||
*
|
||||
|
@ -375,6 +536,18 @@ public String getBaseUri()
|
|||
return ProjectUri.baseUri;
|
||||
}
|
||||
|
||||
private static boolean hasProjectUri( String projectUri, List<ModelProperty> modelProperties )
|
||||
{
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().equals( projectUri ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all model properties containing the specified uri from the specified properties list.
|
||||
*
|
||||
|
@ -414,5 +587,34 @@ private static ModelProperty getPropertyFor( String uri, List<ModelProperty> pro
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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.getValue() ) );
|
||||
}
|
||||
}
|
||||
return transformedProperties;
|
||||
}
|
||||
|
||||
public static List<ModelProperty> transformPluginManagement( List<ModelProperty> modelProperties )
|
||||
{
|
||||
List<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().startsWith( ProjectUri.Build.PluginManagement.xUri ) )
|
||||
{
|
||||
transformedProperties.add( new ModelProperty(
|
||||
mp.getUri().replace( ProjectUri.Build.PluginManagement.xUri, ProjectUri.Build.xUri ),
|
||||
mp.getValue() ) );
|
||||
}
|
||||
}
|
||||
return transformedProperties;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
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.
|
||||
*/
|
||||
|
||||
public class Profile
|
||||
{
|
||||
|
||||
|
||||
}
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.shared.model.ImportModel;
|
||||
import org.apache.maven.shared.model.InterpolatorProperty;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -40,17 +42,19 @@ public interface ProjectBuilder
|
|||
/**
|
||||
* 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
|
||||
* @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
|
||||
* @param projectBuilderConfiguration
|
||||
* @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,
|
||||
MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedModels, Collection<ImportModel> importModels,
|
||||
Collection<InterpolatorProperty> interpolatorProperties,
|
||||
PomArtifactResolver resolver, File baseDirectory )
|
||||
PomArtifactResolver resolver, File baseDirectory,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -372,27 +372,27 @@ public static class Plugin
|
|||
public static class Executions
|
||||
{
|
||||
public static String xUri =
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions";
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions#collection";
|
||||
|
||||
public static class Execution
|
||||
{
|
||||
public static String xUri =
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions/execution";
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions#collection/execution";
|
||||
|
||||
public static String id =
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions/execution/id";
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions#collection/execution/id";
|
||||
|
||||
public static String phase =
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions/execution/phase";
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions#collection/execution/phase";
|
||||
|
||||
public static String goals =
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions/execution/goals";
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions#collection/execution/goals";
|
||||
|
||||
public static String inherited =
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions/execution/inherited";
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions#collection/execution/inherited";
|
||||
|
||||
public static String configuration =
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/executions/execution/configuration";
|
||||
"http://apache.org/maven/project/build/pluginManagement/plugins#collection/plugin/execution#collections/execution/configuration";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
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.shared.model.ImportModel;
|
||||
import org.apache.maven.shared.model.ModelProperty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class DefaultImportModel
|
||||
implements ImportModel
|
||||
{
|
||||
|
||||
private final String id;
|
||||
|
||||
private final List<ModelProperty> modelProperties;
|
||||
|
||||
public DefaultImportModel( String id, List<ModelProperty> modelProperties )
|
||||
{
|
||||
if ( id == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "id: null" );
|
||||
}
|
||||
|
||||
if ( modelProperties == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "modelProperties: null" );
|
||||
}
|
||||
this.id = id;
|
||||
this.modelProperties = new ArrayList<ModelProperty>( modelProperties );
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<ModelProperty> getModelProperties()
|
||||
{
|
||||
return new ArrayList<ModelProperty>( modelProperties );
|
||||
}
|
||||
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if ( this == o )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ImportModel that = (ImportModel) o;
|
||||
|
||||
if ( id != null ? !id.equals( that.getId() ) : that.getId() != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return ( id != null ? id.hashCode() : 0 );
|
||||
}
|
||||
}
|
|
@ -19,11 +19,15 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.MavenTools;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
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.ProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.RepositoryHelper;
|
||||
import org.apache.maven.project.builder.ArtifactModelContainerFactory;
|
||||
import org.apache.maven.project.builder.IdModelContainerFactory;
|
||||
import org.apache.maven.project.builder.PomArtifactResolver;
|
||||
|
@ -33,13 +37,13 @@
|
|||
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.ImportModel;
|
||||
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;
|
||||
|
@ -64,6 +68,10 @@ public final class DefaultProjectBuilder
|
|||
|
||||
private ModelValidator validator;
|
||||
|
||||
private MavenTools mavenTools;
|
||||
|
||||
private RepositoryHelper repositoryHelper;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
|
@ -86,11 +94,13 @@ protected DefaultProjectBuilder( ArtifactFactory artifactFactory )
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ProjectBuilder#buildFromLocalPath(java.io.InputStream, java.util.List, java.util.Collection, org.apache.maven.project.builder.PomArtifactResolver, java.io.File)
|
||||
* @see ProjectBuilder#buildFromLocalPath(java.io.InputStream, java.util.List, java.util.Collection, java.util.Collection, org.apache.maven.project.builder.PomArtifactResolver, java.io.File, org.apache.maven.project.ProjectBuilderConfiguration)
|
||||
*/
|
||||
public MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedModels,
|
||||
Collection<ImportModel> importModels,
|
||||
Collection<InterpolatorProperty> interpolatorProperties,
|
||||
PomArtifactResolver resolver, File projectDirectory )
|
||||
PomArtifactResolver resolver, File projectDirectory,
|
||||
ProjectBuilderConfiguration projectBuilderConfiguration )
|
||||
throws IOException
|
||||
{
|
||||
if ( pom == null )
|
||||
|
@ -132,16 +142,30 @@ public MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedMo
|
|||
List<DomainModel> domainModels = new ArrayList<DomainModel>();
|
||||
domainModels.add( domainModel );
|
||||
|
||||
File parentFile = null;
|
||||
if ( domainModel.getModel().getParent() != null )
|
||||
{
|
||||
List<DomainModel> mavenParents;
|
||||
if ( isParentLocal( domainModel.getModel().getParent(), projectDirectory ) )
|
||||
{
|
||||
domainModels.addAll( getDomainModelParentsFromLocalPath( domainModel, resolver, projectDirectory ) );
|
||||
mavenParents = getDomainModelParentsFromLocalPath( domainModel, resolver, projectDirectory );
|
||||
}
|
||||
else
|
||||
{
|
||||
domainModels.addAll( getDomainModelParentsFromRepository( domainModel, resolver ) );
|
||||
mavenParents = getDomainModelParentsFromRepository( domainModel, resolver );
|
||||
}
|
||||
|
||||
if ( mavenParents.size() > 0 )
|
||||
{
|
||||
PomClassicDomainModel dm = (PomClassicDomainModel) mavenParents.get( 0 );
|
||||
parentFile = dm.getFile();
|
||||
domainModel.setParentFile( parentFile );
|
||||
// mavenParent = buildFromLocalPath( dm.getInputStream(), inheritedModels,
|
||||
// importModels, interpolatorProperties, resolver, projectDirectory);
|
||||
// mavenParent.setFile(dm.getFile());
|
||||
}
|
||||
|
||||
domainModels.addAll( mavenParents );
|
||||
}
|
||||
|
||||
for ( Model model : inheritedModels )
|
||||
|
@ -149,16 +173,37 @@ public MavenProject buildFromLocalPath( InputStream pom, List<Model> inheritedMo
|
|||
domainModels.add( new PomClassicDomainModel( model ) );
|
||||
}
|
||||
|
||||
PomClassicTransformer transformer = new PomClassicTransformer();
|
||||
PomClassicTransformer transformer = new PomClassicTransformer( null );
|
||||
ModelTransformerContext ctx = new ModelTransformerContext(
|
||||
Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
||||
|
||||
PomClassicDomainModel transformedDomainModel =
|
||||
( (PomClassicDomainModel) ctx.transform( domainModels, transformer, transformer, null, properties ) );
|
||||
Model model = transformedDomainModel.getModel();
|
||||
return new MavenProject( model );
|
||||
PomClassicDomainModel transformedDomainModel = ( (PomClassicDomainModel) ctx.transform( domainModels,
|
||||
transformer,
|
||||
transformer,
|
||||
importModels,
|
||||
properties ) );
|
||||
// System.out.println(transformedDomainModel.asString());
|
||||
try
|
||||
{
|
||||
MavenProject mavenProject = new MavenProject( transformedDomainModel.getModel(), artifactFactory,
|
||||
mavenTools, repositoryHelper, null,
|
||||
projectBuilderConfiguration );
|
||||
mavenProject.setParentFile( parentFile );
|
||||
return mavenProject;
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
throw new IOException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the relative path of the specified parent references a pom, otherwise returns false.
|
||||
*
|
||||
* @param parent the parent model info
|
||||
* @param projectDirectory the project directory of the child pom
|
||||
* @return true if the relative path of the specified parent references a pom, otherwise returns fals
|
||||
*/
|
||||
private boolean isParentLocal( Parent parent, File projectDirectory )
|
||||
{
|
||||
try
|
||||
|
@ -199,11 +244,11 @@ private List<DomainModel> getDomainModelParentsFromRepository( PomClassicDomainM
|
|||
artifactFactory.createParentArtifact( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
|
||||
artifactResolver.resolve( artifactParent );
|
||||
|
||||
PomClassicDomainModel parentDomainModel =
|
||||
new PomClassicDomainModel( new FileInputStream( artifactParent.getFile() ) );
|
||||
PomClassicDomainModel parentDomainModel = new PomClassicDomainModel( artifactParent.getFile() );
|
||||
if ( !parentDomainModel.matchesParent( domainModel.getModel().getParent() ) )
|
||||
{
|
||||
logger.warn( "Parent pom ids do not match: File = " + artifactParent.getFile().getAbsolutePath() );
|
||||
logger.warn( "Parent pom ids do not match: Parent File = " + artifactParent.getFile().getAbsolutePath() +
|
||||
": Child ID = " + domainModel.getModel().getId() );
|
||||
return domainModels;
|
||||
}
|
||||
else
|
||||
|
@ -217,7 +262,15 @@ private List<DomainModel> getDomainModelParentsFromRepository( PomClassicDomainM
|
|||
return domainModels;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns list of domain model parents of the specified domain model. The parent domain models are part
|
||||
*
|
||||
* @param domainModel
|
||||
* @param artifactResolver
|
||||
* @param projectDirectory
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private List<DomainModel> getDomainModelParentsFromLocalPath( PomClassicDomainModel domainModel,
|
||||
PomArtifactResolver artifactResolver,
|
||||
File projectDirectory )
|
||||
|
@ -248,13 +301,14 @@ private List<DomainModel> getDomainModelParentsFromLocalPath( PomClassicDomainMo
|
|||
|
||||
if ( !parentFile.exists() )
|
||||
{
|
||||
throw new IOException( "File does not exist: File =" + parentFile.getAbsolutePath() );
|
||||
throw new IOException( "File does not exist: File = " + parentFile.getAbsolutePath() );
|
||||
}
|
||||
|
||||
PomClassicDomainModel parentDomainModel = new PomClassicDomainModel( new FileInputStream( parentFile ) );
|
||||
PomClassicDomainModel parentDomainModel = new PomClassicDomainModel( parentFile );
|
||||
if ( !parentDomainModel.matchesParent( domainModel.getModel().getParent() ) )
|
||||
{
|
||||
logger.warn( "Parent pom ids do not match: File = " + parentFile.getAbsolutePath() );
|
||||
logger.warn( "Parent pom ids do not match: Parent File = " + parentFile.getAbsolutePath() +
|
||||
": Child ID = " + domainModel.getModel().getId() );
|
||||
}
|
||||
|
||||
domainModels.add( parentDomainModel );
|
||||
|
@ -290,6 +344,4 @@ private void validateModel( Model model )
|
|||
throw new IOException( "Failed to validate: " + validationResult.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -26,12 +26,15 @@
|
|||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.PluginManagement;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.ReportSet;
|
||||
import org.apache.maven.model.Reporting;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.model.Scm;
|
||||
import org.apache.maven.model.Site;
|
||||
import org.apache.maven.project.ModelUtils;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
@ -52,21 +55,131 @@
|
|||
public class DefaultModelInheritanceAssembler
|
||||
implements ModelInheritanceAssembler
|
||||
{
|
||||
|
||||
// TODO: Remove this!
|
||||
@SuppressWarnings("unchecked")
|
||||
public void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance )
|
||||
{
|
||||
// The build has been set but we want to step in here and fill in
|
||||
// values that have not been set by the child.
|
||||
|
||||
if ( childBuild.getSourceDirectory() == null )
|
||||
{
|
||||
childBuild.setSourceDirectory( parentBuild.getSourceDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getScriptSourceDirectory() == null )
|
||||
{
|
||||
childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getTestSourceDirectory() == null )
|
||||
{
|
||||
childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getOutputDirectory() == null )
|
||||
{
|
||||
childBuild.setOutputDirectory( parentBuild.getOutputDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getTestOutputDirectory() == null )
|
||||
{
|
||||
childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() );
|
||||
}
|
||||
|
||||
// Extensions are accumlated
|
||||
ModelUtils.mergeExtensionLists( childBuild, parentBuild );
|
||||
|
||||
if ( childBuild.getDirectory() == null )
|
||||
{
|
||||
childBuild.setDirectory( parentBuild.getDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getDefaultGoal() == null )
|
||||
{
|
||||
childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
|
||||
}
|
||||
|
||||
if ( childBuild.getFinalName() == null )
|
||||
{
|
||||
childBuild.setFinalName( parentBuild.getFinalName() );
|
||||
}
|
||||
|
||||
ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() );
|
||||
|
||||
List<Resource> resources = childBuild.getResources();
|
||||
if ( ( resources == null ) || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setResources( parentBuild.getResources() );
|
||||
}
|
||||
|
||||
resources = childBuild.getTestResources();
|
||||
if ( ( resources == null ) || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setTestResources( parentBuild.getTestResources() );
|
||||
}
|
||||
|
||||
// Plugins are aggregated if Plugin.inherit != false
|
||||
ModelUtils.mergePluginLists( childBuild, parentBuild, handleAsInheritance );
|
||||
|
||||
// Plugin management :: aggregate
|
||||
PluginManagement dominantPM = childBuild.getPluginManagement();
|
||||
PluginManagement recessivePM = parentBuild.getPluginManagement();
|
||||
|
||||
if ( ( dominantPM == null ) && ( recessivePM != null ) )
|
||||
{
|
||||
// FIXME: Filter out the inherited == false stuff!
|
||||
childBuild.setPluginManagement( recessivePM );
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false );
|
||||
}
|
||||
}
|
||||
|
||||
private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths )
|
||||
{
|
||||
if ( parent.getScm() != null )
|
||||
{
|
||||
Scm parentScm = parent.getScm();
|
||||
|
||||
Scm childScm = child.getScm();
|
||||
|
||||
if ( childScm == null )
|
||||
{
|
||||
childScm = new Scm();
|
||||
|
||||
child.setScm( childScm );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) )
|
||||
{
|
||||
childScm.setConnection(
|
||||
appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) &&
|
||||
!StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
|
||||
{
|
||||
childScm
|
||||
.setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(),
|
||||
childPathAdjustment, appendPaths ) );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) )
|
||||
{
|
||||
childScm.setUrl(
|
||||
appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void copyModel( Model dest, Model source )
|
||||
{
|
||||
assembleModelInheritance( dest, source, null, false );
|
||||
}
|
||||
|
||||
public void assembleModelInheritance( Model child, Model parent, String childPathAdjustment )
|
||||
{
|
||||
assembleModelInheritance( child, parent, childPathAdjustment, true );
|
||||
}
|
||||
|
||||
public void assembleModelInheritance( Model child, Model parent )
|
||||
{
|
||||
assembleModelInheritance( child, parent, null, true );
|
||||
}
|
||||
|
||||
private void assembleModelInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths )
|
||||
{
|
||||
// cannot inherit from null parent.
|
||||
|
@ -243,10 +356,179 @@ private void assembleReportingInheritance( Model child, Model parent )
|
|||
childReporting.setOutputDirectory( parentReporting.getOutputDirectory() );
|
||||
}
|
||||
|
||||
ModelUtils.mergeReportPluginLists( childReporting, parentReporting, true );
|
||||
mergeReportPluginLists( childReporting, parentReporting, true );
|
||||
}
|
||||
}
|
||||
|
||||
private static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance )
|
||||
{
|
||||
if ( ( child == null ) || ( parent == null ) )
|
||||
{
|
||||
// nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
List parentPlugins = parent.getPlugins();
|
||||
|
||||
if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
|
||||
{
|
||||
Map assembledPlugins = new TreeMap();
|
||||
|
||||
Map childPlugins = child.getReportPluginsAsMap();
|
||||
|
||||
for ( Iterator it = parentPlugins.iterator(); it.hasNext(); )
|
||||
{
|
||||
ReportPlugin parentPlugin = (ReportPlugin) it.next();
|
||||
|
||||
String parentInherited = parentPlugin.getInherited();
|
||||
|
||||
if ( !handleAsInheritance || ( parentInherited == null ) ||
|
||||
Boolean.valueOf( parentInherited ).booleanValue() )
|
||||
{
|
||||
|
||||
ReportPlugin assembledPlugin = parentPlugin;
|
||||
|
||||
ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey() );
|
||||
|
||||
if ( childPlugin != null )
|
||||
{
|
||||
assembledPlugin = childPlugin;
|
||||
|
||||
mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
|
||||
}
|
||||
|
||||
if ( handleAsInheritance && ( parentInherited == null ) )
|
||||
{
|
||||
assembledPlugin.unsetInheritanceApplied();
|
||||
}
|
||||
|
||||
assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin );
|
||||
}
|
||||
}
|
||||
|
||||
for ( Iterator it = childPlugins.values().iterator(); it.hasNext(); )
|
||||
{
|
||||
ReportPlugin childPlugin = (ReportPlugin) it.next();
|
||||
|
||||
if ( !assembledPlugins.containsKey( childPlugin.getKey() ) )
|
||||
{
|
||||
assembledPlugins.put( childPlugin.getKey(), childPlugin );
|
||||
}
|
||||
}
|
||||
|
||||
child.setPlugins( new ArrayList( assembledPlugins.values() ) );
|
||||
|
||||
child.flushReportPluginMap();
|
||||
}
|
||||
}
|
||||
|
||||
private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
|
||||
{
|
||||
List parentReports = parent.getReports();
|
||||
List childReports = child.getReports();
|
||||
|
||||
List reports = new ArrayList();
|
||||
|
||||
if ( ( childReports != null ) && !childReports.isEmpty() )
|
||||
{
|
||||
reports.addAll( childReports );
|
||||
}
|
||||
|
||||
if ( parentReports != null )
|
||||
{
|
||||
for ( Iterator i = parentReports.iterator(); i.hasNext(); )
|
||||
{
|
||||
String report = (String) i.next();
|
||||
|
||||
if ( !reports.contains( report ) )
|
||||
{
|
||||
reports.add( report );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
child.setReports( reports );
|
||||
|
||||
Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
|
||||
Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
|
||||
|
||||
childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
|
||||
|
||||
child.setConfiguration( childConfiguration );
|
||||
}
|
||||
|
||||
|
||||
public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent,
|
||||
boolean handleAsInheritance )
|
||||
{
|
||||
if ( ( child == null ) || ( parent == null ) )
|
||||
{
|
||||
// nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
|
||||
{
|
||||
child.setVersion( parent.getVersion() );
|
||||
}
|
||||
|
||||
// from here to the end of the method is dealing with merging of the <executions/> section.
|
||||
String parentInherited = parent.getInherited();
|
||||
|
||||
boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue();
|
||||
|
||||
List parentReportSets = parent.getReportSets();
|
||||
|
||||
if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
|
||||
{
|
||||
Map assembledReportSets = new TreeMap();
|
||||
|
||||
Map childReportSets = child.getReportSetsAsMap();
|
||||
|
||||
for ( Iterator it = parentReportSets.iterator(); it.hasNext(); )
|
||||
{
|
||||
ReportSet parentReportSet = (ReportSet) it.next();
|
||||
|
||||
if ( !handleAsInheritance || parentIsInherited )
|
||||
{
|
||||
ReportSet assembledReportSet = parentReportSet;
|
||||
|
||||
ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() );
|
||||
|
||||
if ( childReportSet != null )
|
||||
{
|
||||
mergeReportSetDefinitions( childReportSet, parentReportSet );
|
||||
|
||||
assembledReportSet = childReportSet;
|
||||
}
|
||||
else if ( handleAsInheritance && ( parentInherited == null ) )
|
||||
{
|
||||
parentReportSet.unsetInheritanceApplied();
|
||||
}
|
||||
|
||||
assembledReportSets.put( assembledReportSet.getId(), assembledReportSet );
|
||||
}
|
||||
}
|
||||
|
||||
for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
|
||||
String id = (String) entry.getKey();
|
||||
|
||||
if ( !assembledReportSets.containsKey( id ) )
|
||||
{
|
||||
assembledReportSets.put( id, entry.getValue() );
|
||||
}
|
||||
}
|
||||
|
||||
child.setReportSets( new ArrayList( assembledReportSets.values() ) );
|
||||
|
||||
child.flushReportSetMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: Remove this!
|
||||
@SuppressWarnings("unchecked")
|
||||
private void assembleDependencyInheritance( Model child, Model parent )
|
||||
|
@ -295,129 +577,8 @@ private void assembleBuildInheritance( Model child, Model parent )
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this!
|
||||
@SuppressWarnings("unchecked")
|
||||
public void assembleBuildInheritance( Build childBuild,
|
||||
Build parentBuild,
|
||||
boolean handleAsInheritance )
|
||||
{
|
||||
// The build has been set but we want to step in here and fill in
|
||||
// values that have not been set by the child.
|
||||
|
||||
if ( childBuild.getSourceDirectory() == null )
|
||||
{
|
||||
childBuild.setSourceDirectory( parentBuild.getSourceDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getScriptSourceDirectory() == null )
|
||||
{
|
||||
childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getTestSourceDirectory() == null )
|
||||
{
|
||||
childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getOutputDirectory() == null )
|
||||
{
|
||||
childBuild.setOutputDirectory( parentBuild.getOutputDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getTestOutputDirectory() == null )
|
||||
{
|
||||
childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() );
|
||||
}
|
||||
|
||||
// Extensions are accumlated
|
||||
ModelUtils.mergeExtensionLists( childBuild, parentBuild );
|
||||
|
||||
if ( childBuild.getDirectory() == null )
|
||||
{
|
||||
childBuild.setDirectory( parentBuild.getDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getDefaultGoal() == null )
|
||||
{
|
||||
childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
|
||||
}
|
||||
|
||||
if ( childBuild.getFinalName() == null )
|
||||
{
|
||||
childBuild.setFinalName( parentBuild.getFinalName() );
|
||||
}
|
||||
|
||||
ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() );
|
||||
|
||||
List<Resource> resources = childBuild.getResources();
|
||||
if ( ( resources == null ) || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setResources( parentBuild.getResources() );
|
||||
}
|
||||
|
||||
resources = childBuild.getTestResources();
|
||||
if ( ( resources == null ) || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setTestResources( parentBuild.getTestResources() );
|
||||
}
|
||||
|
||||
// Plugins are aggregated if Plugin.inherit != false
|
||||
ModelUtils.mergePluginLists( childBuild, parentBuild, handleAsInheritance );
|
||||
|
||||
// Plugin management :: aggregate
|
||||
PluginManagement dominantPM = childBuild.getPluginManagement();
|
||||
PluginManagement recessivePM = parentBuild.getPluginManagement();
|
||||
|
||||
if ( ( dominantPM == null ) && ( recessivePM != null ) )
|
||||
{
|
||||
// FIXME: Filter out the inherited == false stuff!
|
||||
childBuild.setPluginManagement( recessivePM );
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(),
|
||||
false );
|
||||
}
|
||||
}
|
||||
|
||||
private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths )
|
||||
{
|
||||
if ( parent.getScm() != null )
|
||||
{
|
||||
Scm parentScm = parent.getScm();
|
||||
|
||||
Scm childScm = child.getScm();
|
||||
|
||||
if ( childScm == null )
|
||||
{
|
||||
childScm = new Scm();
|
||||
|
||||
child.setScm( childScm );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) )
|
||||
{
|
||||
childScm.setConnection(
|
||||
appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) &&
|
||||
!StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
|
||||
{
|
||||
childScm
|
||||
.setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(),
|
||||
childPathAdjustment, appendPaths ) );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) )
|
||||
{
|
||||
childScm.setUrl(
|
||||
appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void assembleDistributionInheritence( Model child, Model parent, String childPathAdjustment, boolean appendPaths )
|
||||
private void assembleDistributionInheritence( Model child, Model parent, String childPathAdjustment,
|
||||
boolean appendPaths )
|
||||
{
|
||||
if ( parent.getDistributionManagement() != null )
|
||||
{
|
||||
|
@ -570,7 +731,6 @@ else if ( token.equals( ".." ) )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
StringBuffer cleanedPath = new StringBuffer();
|
||||
|
||||
while ( !pathElements.isEmpty() )
|
||||
|
|
|
@ -30,13 +30,7 @@ public interface ModelInheritanceAssembler
|
|||
{
|
||||
String ROLE = ModelInheritanceAssembler.class.getName();
|
||||
|
||||
void assembleModelInheritance( Model child, Model parent, String childPathAdjustment );
|
||||
|
||||
void assembleModelInheritance( Model child, Model parent );
|
||||
|
||||
void assembleBuildInheritance( Build childBuild,
|
||||
Build parentBuild,
|
||||
boolean handleAsInheriance );
|
||||
void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheriance );
|
||||
|
||||
void copyModel( Model dest, Model source );
|
||||
}
|
||||
|
|
|
@ -42,29 +42,20 @@ public interface ModelInterpolator
|
|||
* @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Model interpolate( Model project,
|
||||
Map<String, ?> context )
|
||||
Model interpolate( Model project, Map<String, ?> context )
|
||||
throws ModelInterpolationException;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Model interpolate( Model model,
|
||||
Map<String, ?> context,
|
||||
boolean strict )
|
||||
Model interpolate( Model model, Map<String, ?> context, boolean strict )
|
||||
throws ModelInterpolationException;
|
||||
|
||||
Model interpolate( Model model,
|
||||
File projectDir,
|
||||
ProjectBuilderConfiguration config,
|
||||
boolean debugEnabled )
|
||||
Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled )
|
||||
throws ModelInterpolationException;
|
||||
|
||||
String interpolate( String src,
|
||||
Model model,
|
||||
File projectDir,
|
||||
ProjectBuilderConfiguration config,
|
||||
String interpolate( String src, Model model, File projectDir, ProjectBuilderConfiguration config,
|
||||
boolean debugEnabled )
|
||||
throws ModelInterpolationException;
|
||||
}
|
|
@ -20,15 +20,12 @@
|
|||
*/
|
||||
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.codehaus.plexus.interpolation.AbstractFunctionValueSourceWrapper;
|
||||
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
|
||||
import org.codehaus.plexus.interpolation.ValueSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version $Id: PathTranslatingPostProcessor.java 677447 2008-07-16 22:15:57Z jdcasey $
|
||||
*/
|
||||
public class PathTranslatingPostProcessor
|
||||
|
@ -36,7 +33,9 @@ public class PathTranslatingPostProcessor
|
|||
{
|
||||
|
||||
private final List unprefixedPathKeys;
|
||||
|
||||
private final File projectDir;
|
||||
|
||||
private final PathTranslator pathTranslator;
|
||||
|
||||
public PathTranslatingPostProcessor( List unprefixedPathKeys, File projectDir, PathTranslator pathTranslator )
|
||||
|
@ -46,8 +45,7 @@ public PathTranslatingPostProcessor( List unprefixedPathKeys, File projectDir, P
|
|||
this.pathTranslator = pathTranslator;
|
||||
}
|
||||
|
||||
public Object execute( String expression,
|
||||
Object value )
|
||||
public Object execute( String expression, Object value )
|
||||
{
|
||||
if ( projectDir != null && value != null && unprefixedPathKeys.contains( expression ) )
|
||||
{
|
||||
|
|
|
@ -61,7 +61,8 @@ public class RegexBasedModelInterpolator
|
|||
implements ModelInterpolator
|
||||
{
|
||||
|
||||
private static final List<String> PROJECT_PREFIXES = Arrays.asList( new String[]{ "pom.", "project." } );
|
||||
private static final List<String> PROJECT_PREFIXES = Arrays.asList( new String[]{"pom.", "project."} );
|
||||
|
||||
private static final List<String> TRANSLATED_PATH_EXPRESSIONS;
|
||||
|
||||
static
|
||||
|
@ -101,9 +102,7 @@ public Model interpolate( Model model, Map<String, ?> context )
|
|||
Properties props = new Properties();
|
||||
props.putAll( context );
|
||||
|
||||
return interpolate( model,
|
||||
null,
|
||||
new DefaultProjectBuilderConfiguration().setExecutionProperties( props ),
|
||||
return interpolate( model, null, new DefaultProjectBuilderConfiguration().setExecutionProperties( props ),
|
||||
true );
|
||||
}
|
||||
|
||||
|
@ -113,9 +112,7 @@ public Model interpolate( Model model, Map<String, ?> context, boolean strict )
|
|||
Properties props = new Properties();
|
||||
props.putAll( context );
|
||||
|
||||
return interpolate( model,
|
||||
null,
|
||||
new DefaultProjectBuilderConfiguration().setExecutionProperties( props ),
|
||||
return interpolate( model, null, new DefaultProjectBuilderConfiguration().setExecutionProperties( props ),
|
||||
true );
|
||||
}
|
||||
|
||||
|
@ -125,14 +122,14 @@ public Model interpolate( Model model, Map<String, ?> context, boolean strict )
|
|||
* <br/>
|
||||
* <b>NOTE:</b> This will result in a different instance of Model being returned!!!
|
||||
*
|
||||
* @param model The inbound Model instance, to serialize and reference for expression resolution
|
||||
* @param context The other context map to be used during resolution
|
||||
* @param model The inbound Model instance, to serialize and reference for expression resolution
|
||||
* @param context The other context map to be used during resolution
|
||||
* @param overrideContext The context map which should be used to OVERRIDE
|
||||
* values from everything else. This will come from the CLI
|
||||
* or userProperties in the execution request.
|
||||
* @param projectDir The directory from which the current model's pom was read.
|
||||
* @param strict This parameter is ignored!
|
||||
* @param debugMessages If true, print any feedback from the interpolator out to the DEBUG log-level.
|
||||
* @param projectDir The directory from which the current model's pom was read.
|
||||
* @param strict This parameter is ignored!
|
||||
* @param debugMessages If true, print any feedback from the interpolator out to the DEBUG log-level.
|
||||
* @return The resolved instance of the inbound Model. This is a different instance!
|
||||
*/
|
||||
public Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugMessages )
|
||||
|
@ -176,23 +173,21 @@ public Model interpolate( Model model, File projectDir, ProjectBuilderConfigurat
|
|||
|
||||
/**
|
||||
* Interpolates all expressions in the src parameter.
|
||||
* <p>
|
||||
* <p/>
|
||||
* The algorithm used for each expression is:
|
||||
* <ul>
|
||||
* <li>If it starts with either "pom." or "project.", the expression is evaluated against the model.</li>
|
||||
* <li>If the value is null, get the value from the context.</li>
|
||||
* <li>If the value is null, but the context contains the expression, don't replace the expression string
|
||||
* with the value, and continue to find other expressions.</li>
|
||||
* <li>If the value is null, get it from the model properties.</li>
|
||||
* <li>
|
||||
* <li>If it starts with either "pom." or "project.", the expression is evaluated against the model.</li>
|
||||
* <li>If the value is null, get the value from the context.</li>
|
||||
* <li>If the value is null, but the context contains the expression, don't replace the expression string
|
||||
* with the value, and continue to find other expressions.</li>
|
||||
* <li>If the value is null, get it from the model properties.</li>
|
||||
* <li>
|
||||
*
|
||||
* @param overrideContext
|
||||
* @param debugMessages
|
||||
*/
|
||||
public String interpolate( String src,
|
||||
Model model,
|
||||
final File projectDir,
|
||||
ProjectBuilderConfiguration config,
|
||||
boolean debugMessages )
|
||||
public String interpolate( String src, Model model, final File projectDir, ProjectBuilderConfiguration config,
|
||||
boolean debugMessages )
|
||||
throws ModelInterpolationException
|
||||
{
|
||||
Logger logger = getLogger();
|
||||
|
@ -208,7 +203,8 @@ public String interpolate( String src,
|
|||
ValueSource modelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false );
|
||||
ValueSource modelValueSource2 = new ObjectBasedValueSource( model );
|
||||
|
||||
ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new ValueSource(){
|
||||
ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new ValueSource()
|
||||
{
|
||||
public Object getValue( String expression )
|
||||
{
|
||||
if ( projectDir != null && "basedir".equals( expression ) )
|
||||
|
@ -218,8 +214,7 @@ public Object getValue( String expression )
|
|||
|
||||
return null;
|
||||
}
|
||||
},
|
||||
PROJECT_PREFIXES, true );
|
||||
}, PROJECT_PREFIXES, true );
|
||||
|
||||
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
|
||||
|
||||
|
@ -228,7 +223,8 @@ public Object getValue( String expression )
|
|||
interpolator.addValueSource( new BuildTimestampValueSource( config.getBuildStartTime(), timestampFormat ) );
|
||||
interpolator.addValueSource( new MapBasedValueSource( config.getExecutionProperties() ) );
|
||||
interpolator.addValueSource( modelValueSource1 );
|
||||
interpolator.addValueSource( new PrefixedValueSourceWrapper( new MapBasedValueSource( modelProperties ), PROJECT_PREFIXES, true ) );
|
||||
interpolator.addValueSource(
|
||||
new PrefixedValueSourceWrapper( new MapBasedValueSource( modelProperties ), PROJECT_PREFIXES, true ) );
|
||||
interpolator.addValueSource( modelValueSource2 );
|
||||
interpolator.addValueSource( new MapBasedValueSource( config.getUserProperties() ) );
|
||||
|
||||
|
@ -244,7 +240,7 @@ public Object getValue( String expression )
|
|||
{
|
||||
result = interpolator.interpolate( result, "", recursionInterceptor );
|
||||
}
|
||||
catch( InterpolationException e )
|
||||
catch ( InterpolationException e )
|
||||
{
|
||||
throw new ModelInterpolationException( e.getMessage(), e );
|
||||
}
|
||||
|
|
|
@ -31,11 +31,7 @@
|
|||
public class DefaultPathTranslator
|
||||
implements PathTranslator
|
||||
{
|
||||
private static final String[] BASEDIR_EXPRESSIONS = {
|
||||
"${basedir}",
|
||||
"${pom.basedir}",
|
||||
"${project.basedir}"
|
||||
};
|
||||
private static final String[] BASEDIR_EXPRESSIONS = {"${basedir}", "${pom.basedir}", "${project.basedir}"};
|
||||
|
||||
private String FILE_SEPARATOR = "/";
|
||||
|
||||
|
|
|
@ -63,14 +63,14 @@ public ModelValidationResult validate( Model model )
|
|||
if ( !model.getModules().isEmpty() && !"pom".equals( model.getPackaging() ) )
|
||||
{
|
||||
result.addMessage( "Packaging '" + model.getPackaging() + "' is invalid. Aggregator projects " +
|
||||
"require 'pom' as packaging." );
|
||||
"require 'pom' as packaging." );
|
||||
}
|
||||
|
||||
Parent parent = model.getParent();
|
||||
if ( parent != null )
|
||||
{
|
||||
if ( parent.getGroupId().equals( model.getGroupId() ) &&
|
||||
parent.getArtifactId().equals( model.getArtifactId() ) )
|
||||
parent.getArtifactId().equals( model.getArtifactId() ) )
|
||||
{
|
||||
result.addMessage( "The parent element cannot have the same ID as the project." );
|
||||
}
|
||||
|
@ -88,7 +88,8 @@ public ModelValidationResult validate( Model model )
|
|||
|
||||
validateStringNotEmpty( "dependencies.dependency.type", result, d.getType(), dependencySourceHint( d ) );
|
||||
|
||||
validateStringNotEmpty( "dependencies.dependency.version", result, d.getVersion(), dependencySourceHint( d ) );
|
||||
validateStringNotEmpty( "dependencies.dependency.version", result, d.getVersion(),
|
||||
dependencySourceHint( d ) );
|
||||
|
||||
if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) )
|
||||
{
|
||||
|
@ -100,10 +101,10 @@ public ModelValidationResult validate( Model model )
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( ! new File( systemPath ).isAbsolute() )
|
||||
if ( !new File( systemPath ).isAbsolute() )
|
||||
{
|
||||
result.addMessage( "For dependency " + d + ": system-scoped dependency must " +
|
||||
"specify an absolute path systemPath." );
|
||||
"specify an absolute path systemPath." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,14 +134,15 @@ else if ( StringUtils.isNotEmpty( d.getSystemPath() ) )
|
|||
|
||||
if ( StringUtils.isEmpty( systemPath ) )
|
||||
{
|
||||
result.addMessage( "For managed dependency " + d + ": system-scoped dependency must specify systemPath." );
|
||||
result.addMessage(
|
||||
"For managed dependency " + d + ": system-scoped dependency must specify systemPath." );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! new File( systemPath ).isAbsolute() )
|
||||
if ( !new File( systemPath ).isAbsolute() )
|
||||
{
|
||||
result.addMessage( "For managed dependency " + d + ": system-scoped dependency must " +
|
||||
"specify an absolute path systemPath." );
|
||||
"specify an absolute path systemPath." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +260,6 @@ private void forcePluginExecutionIdCollision( Model model, ModelValidationResult
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Field validation
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -289,7 +290,8 @@ private boolean validateStringNotEmpty( String fieldName, ModelValidationResult
|
|||
* <li><code>string.length > 0</code>
|
||||
* </ul>
|
||||
*/
|
||||
private boolean validateStringNotEmpty( String fieldName, ModelValidationResult result, String string, String sourceHint )
|
||||
private boolean validateStringNotEmpty( String fieldName, ModelValidationResult result, String string,
|
||||
String sourceHint )
|
||||
{
|
||||
if ( !validateNotNull( fieldName, result, string, sourceHint ) )
|
||||
{
|
||||
|
@ -310,7 +312,6 @@ private boolean validateStringNotEmpty( String fieldName, ModelValidationResult
|
|||
result.addMessage( "'" + fieldName + "' is missing." );
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,28 @@
|
|||
package org.apache.maven.project.workspace;
|
||||
|
||||
/*
|
||||
* 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.project.MavenProject;
|
||||
import org.apache.maven.project.build.model.ModelAndFile;
|
||||
import org.apache.maven.project.ModelAndFile;
|
||||
import org.apache.maven.workspace.MavenWorkspaceStore;
|
||||
import org.codehaus.plexus.logging.LogEnabled;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
@ -16,6 +35,7 @@ public class DefaultProjectWorkspace
|
|||
{
|
||||
|
||||
private MavenWorkspaceStore workspaceStore;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
public DefaultProjectWorkspace()
|
||||
|
@ -28,9 +48,7 @@ protected DefaultProjectWorkspace( MavenWorkspaceStore workspaceStore, Logger lo
|
|||
this.logger = logger;
|
||||
}
|
||||
|
||||
public ModelAndFile getModelAndFile( String groupId,
|
||||
String artifactId,
|
||||
String version )
|
||||
public ModelAndFile getModelAndFile( String groupId, String artifactId, String version )
|
||||
{
|
||||
Map cache = workspaceStore.getWorkspaceCache( ProjectWorkspace.MODEL_AND_FILE_BYGAV_KEY );
|
||||
|
||||
|
@ -70,9 +88,7 @@ public MavenProject getProject( File projectFile )
|
|||
return (MavenProject) cache.get( pathKey );
|
||||
}
|
||||
|
||||
public MavenProject getProject( String groupId,
|
||||
String artifactId,
|
||||
String version )
|
||||
public MavenProject getProject( String groupId, String artifactId, String version )
|
||||
{
|
||||
Map cache = workspaceStore.getWorkspaceCache( ProjectWorkspace.PROJECT_INSTANCE_BYGAV_KEY );
|
||||
|
||||
|
@ -131,7 +147,8 @@ private String createCacheKeyUsingParent( Model model )
|
|||
|
||||
public void storeProjectByFile( MavenProject project )
|
||||
{
|
||||
if ( project.getFile() == null ){
|
||||
if ( project.getFile() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,26 @@
|
|||
package org.apache.maven.project.workspace;
|
||||
|
||||
/*
|
||||
* 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.project.MavenProject;
|
||||
import org.apache.maven.project.build.model.ModelAndFile;
|
||||
import org.apache.maven.project.ModelAndFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
|
|
@ -50,14 +50,16 @@ public class DefaultMavenRealmManager
|
|||
{
|
||||
|
||||
private Map pluginArtifacts = new HashMap();
|
||||
|
||||
private Set managedRealmIds = new HashSet();
|
||||
|
||||
private final ClassWorld world;
|
||||
|
||||
private final PlexusContainer container;
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
public DefaultMavenRealmManager( PlexusContainer container,
|
||||
Logger logger )
|
||||
public DefaultMavenRealmManager( PlexusContainer container, Logger logger )
|
||||
{
|
||||
world = container.getContainerRealm().getWorld();
|
||||
this.container = container;
|
||||
|
@ -114,8 +116,7 @@ public boolean hasExtensionRealm( Artifact extensionArtifact )
|
|||
}
|
||||
}
|
||||
|
||||
public ClassRealm createExtensionRealm( Artifact extensionArtifact,
|
||||
List artifacts )
|
||||
public ClassRealm createExtensionRealm( Artifact extensionArtifact, List artifacts )
|
||||
throws RealmManagementException
|
||||
{
|
||||
String id = RealmUtils.createExtensionRealmId( extensionArtifact );
|
||||
|
@ -127,8 +128,7 @@ public ClassRealm createExtensionRealm( Artifact extensionArtifact,
|
|||
}
|
||||
catch ( DuplicateRealmException e )
|
||||
{
|
||||
throw new RealmManagementException( id, "Extension realm: " + id + " already exists.",
|
||||
e );
|
||||
throw new RealmManagementException( id, "Extension realm: " + id + " already exists.", e );
|
||||
}
|
||||
|
||||
populateRealm( id, realm, extensionArtifact, artifacts, null );
|
||||
|
@ -136,24 +136,25 @@ public ClassRealm createExtensionRealm( Artifact extensionArtifact,
|
|||
return realm;
|
||||
}
|
||||
|
||||
public void importExtensionsIntoProjectRealm( String projectGroupId,
|
||||
String projectArtifactId,
|
||||
String projectVersion,
|
||||
Artifact extensionArtifact )
|
||||
public void importExtensionsIntoProjectRealm( String projectGroupId, String projectArtifactId,
|
||||
String projectVersion, Artifact extensionArtifact )
|
||||
throws RealmManagementException
|
||||
{
|
||||
String extensionRealmId = RealmUtils.createExtensionRealmId( extensionArtifact );
|
||||
|
||||
if ( extensionArtifact.getFile() == null )
|
||||
{
|
||||
throw new RealmManagementException( extensionRealmId, "Cannot import project extensions; extension artifact has no associated file that can be scanned for extension components (extension: " + extensionArtifact.getId() + ")" );
|
||||
throw new RealmManagementException( extensionRealmId,
|
||||
"Cannot import project extensions; extension artifact has no associated file that can be scanned for extension components (extension: " +
|
||||
extensionArtifact.getId() + ")" );
|
||||
}
|
||||
|
||||
|
||||
ComponentDiscoverer discoverer = new DefaultComponentDiscoverer();
|
||||
discoverer.setManager( RealmScanningUtils.getDummyComponentDiscovererManager() );
|
||||
|
||||
List componentSetDescriptors = RealmScanningUtils.scanForComponentSetDescriptors( extensionArtifact, discoverer, container.getContext(), extensionRealmId );
|
||||
List componentSetDescriptors = RealmScanningUtils.scanForComponentSetDescriptors( extensionArtifact, discoverer,
|
||||
container.getContext(),
|
||||
extensionRealmId );
|
||||
|
||||
ClassRealm realm = getProjectRealm( projectGroupId, projectArtifactId, projectVersion, true );
|
||||
|
||||
|
@ -168,7 +169,9 @@ public void importExtensionsIntoProjectRealm( String projectGroupId,
|
|||
|
||||
try
|
||||
{
|
||||
logger.debug( "Importing: " + implementation + "\nwith role: " + comp.getRole() + "\nand hint: " + comp.getRoleHint() + "\nfrom extension realm: " + extensionRealmId + "\nto project realm: " + realm.getId() );
|
||||
logger.debug( "Importing: " + implementation + "\nwith role: " + comp.getRole() + "\nand hint: " +
|
||||
comp.getRoleHint() + "\nfrom extension realm: " + extensionRealmId + "\nto project realm: " +
|
||||
realm.getId() );
|
||||
|
||||
// Import the extension component's implementation class into the project-level
|
||||
// realm.
|
||||
|
@ -187,12 +190,17 @@ public void importExtensionsIntoProjectRealm( String projectGroupId,
|
|||
}
|
||||
catch ( NoSuchRealmException e )
|
||||
{
|
||||
throw new RealmManagementException( extensionRealmId, "Failed to create import for component: " + implementation + " from extension realm: " + extensionRealmId + " to project realm: " + realm.getId(), e );
|
||||
throw new RealmManagementException( extensionRealmId, "Failed to create import for component: " +
|
||||
implementation + " from extension realm: " + extensionRealmId + " to project realm: " +
|
||||
realm.getId(), e );
|
||||
}
|
||||
catch ( ComponentRepositoryException e )
|
||||
{
|
||||
String projectId = RealmUtils.createProjectId( projectGroupId, projectArtifactId, projectVersion );
|
||||
throw new RealmManagementException( extensionRealmId, "Unable to discover components from imports to project: " + projectId + " from extension artifact: " + extensionArtifact.getId(), e );
|
||||
throw new RealmManagementException( extensionRealmId,
|
||||
"Unable to discover components from imports to project: " +
|
||||
projectId + " from extension artifact: " +
|
||||
extensionArtifact.getId(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +211,8 @@ public ClassRealm getProjectRealm( String projectGroupId, String projectArtifact
|
|||
return getProjectRealm( projectGroupId, projectArtifactId, projectVersion, false );
|
||||
}
|
||||
|
||||
private ClassRealm getProjectRealm( String projectGroupId, String projectArtifactId, String projectVersion, boolean create )
|
||||
private ClassRealm getProjectRealm( String projectGroupId, String projectArtifactId, String projectVersion,
|
||||
boolean create )
|
||||
{
|
||||
String id = RealmUtils.createProjectId( projectGroupId, projectArtifactId, projectVersion );
|
||||
|
||||
|
@ -266,10 +275,8 @@ public void disposePluginRealm( Plugin plugin )
|
|||
pluginArtifacts.remove( id );
|
||||
}
|
||||
|
||||
public ClassRealm createPluginRealm( Plugin plugin,
|
||||
Artifact pluginArtifact,
|
||||
List artifacts,
|
||||
ArtifactFilter coreArtifactFilter )
|
||||
public ClassRealm createPluginRealm( Plugin plugin, Artifact pluginArtifact, List artifacts,
|
||||
ArtifactFilter coreArtifactFilter )
|
||||
throws RealmManagementException
|
||||
{
|
||||
String id = RealmUtils.createPluginRealmId( plugin );
|
||||
|
@ -284,8 +291,7 @@ public ClassRealm createPluginRealm( Plugin plugin,
|
|||
}
|
||||
catch ( DuplicateRealmException e )
|
||||
{
|
||||
throw new RealmManagementException( id, "Plugin realm: " + id + " already exists.",
|
||||
e );
|
||||
throw new RealmManagementException( id, "Plugin realm: " + id + " already exists.", e );
|
||||
}
|
||||
|
||||
populateRealm( id, realm, pluginArtifact, artifacts, coreArtifactFilter );
|
||||
|
@ -296,10 +302,7 @@ public ClassRealm createPluginRealm( Plugin plugin,
|
|||
return realm;
|
||||
}
|
||||
|
||||
private void populateRealm( String id,
|
||||
ClassRealm realm,
|
||||
Artifact mainArtifact,
|
||||
List artifacts,
|
||||
private void populateRealm( String id, ClassRealm realm, Artifact mainArtifact, List artifacts,
|
||||
ArtifactFilter coreArtifactFilter )
|
||||
throws RealmManagementException
|
||||
{
|
||||
|
@ -311,10 +314,8 @@ private void populateRealm( String id,
|
|||
}
|
||||
catch ( MalformedURLException e )
|
||||
{
|
||||
throw new RealmManagementException( id, mainArtifact, "Invalid URL for artifact file: "
|
||||
+ mainArtifact.getFile()
|
||||
+ " to be used in realm: " + id
|
||||
+ ".", e );
|
||||
throw new RealmManagementException( id, mainArtifact, "Invalid URL for artifact file: " +
|
||||
mainArtifact.getFile() + " to be used in realm: " + id + ".", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,15 +331,14 @@ private void populateRealm( String id,
|
|||
}
|
||||
catch ( MalformedURLException e )
|
||||
{
|
||||
throw new RealmManagementException( id, artifact, "Invalid URL for artifact file: "
|
||||
+ artifact.getFile()
|
||||
+ " to be used in realm: " + id
|
||||
+ ".", e );
|
||||
throw new RealmManagementException( id, artifact, "Invalid URL for artifact file: " +
|
||||
artifact.getFile() + " to be used in realm: " + id + ".", e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug( "Excluding artifact: " + artifact.getArtifactId() + " from plugin realm; it's already included in Maven's core." );
|
||||
logger.debug( "Excluding artifact: " + artifact.getArtifactId() +
|
||||
" from plugin realm; it's already included in Maven's core." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,8 +361,7 @@ public List getPluginArtifacts( Plugin plugin )
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setPluginArtifacts( Plugin plugin,
|
||||
List artifacts )
|
||||
public void setPluginArtifacts( Plugin plugin, List artifacts )
|
||||
{
|
||||
String id = RealmUtils.createPluginRealmId( plugin );
|
||||
|
||||
|
|
|
@ -14,32 +14,24 @@ public interface MavenRealmManager
|
|||
|
||||
boolean hasExtensionRealm( Artifact extensionArtifact );
|
||||
|
||||
ClassRealm createExtensionRealm( Artifact extensionArtifact,
|
||||
List artifacts )
|
||||
ClassRealm createExtensionRealm( Artifact extensionArtifact, List artifacts )
|
||||
throws RealmManagementException;
|
||||
|
||||
void importExtensionsIntoProjectRealm( String projectGroupId,
|
||||
String projectArtifactId,
|
||||
String projectVersion,
|
||||
void importExtensionsIntoProjectRealm( String projectGroupId, String projectArtifactId, String projectVersion,
|
||||
Artifact extensionArtifact )
|
||||
throws RealmManagementException;
|
||||
|
||||
ClassRealm getProjectRealm( String groupId,
|
||||
String artifactId,
|
||||
String version );
|
||||
ClassRealm getProjectRealm( String groupId, String artifactId, String version );
|
||||
|
||||
ClassRealm getPluginRealm( Plugin plugin );
|
||||
|
||||
List getPluginArtifacts( Plugin plugin );
|
||||
|
||||
ClassRealm createPluginRealm( Plugin plugin,
|
||||
Artifact pluginArtifact,
|
||||
List artifacts,
|
||||
ClassRealm createPluginRealm( Plugin plugin, Artifact pluginArtifact, List artifacts,
|
||||
ArtifactFilter coreArtifactFilter )
|
||||
throws RealmManagementException;
|
||||
|
||||
void disposePluginRealm( Plugin plugin );
|
||||
|
||||
void setPluginArtifacts( Plugin plugin,
|
||||
List artifacts );
|
||||
void setPluginArtifacts( Plugin plugin, List artifacts );
|
||||
}
|
||||
|
|
|
@ -13,8 +13,11 @@ public class RealmManagementException
|
|||
{
|
||||
|
||||
private final String realmId;
|
||||
|
||||
private String offendingGroupId;
|
||||
|
||||
private String offendingArtifactId;
|
||||
|
||||
private String offendingVersion;
|
||||
|
||||
public RealmManagementException( String realmId, String message, DuplicateRealmException cause )
|
||||
|
@ -23,7 +26,8 @@ public RealmManagementException( String realmId, String message, DuplicateRealmE
|
|||
this.realmId = realmId;
|
||||
}
|
||||
|
||||
public RealmManagementException( String realmId, Artifact offendingArtifact, String message, MalformedURLException cause )
|
||||
public RealmManagementException( String realmId, Artifact offendingArtifact, String message,
|
||||
MalformedURLException cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.realmId = realmId;
|
||||
|
@ -32,25 +36,19 @@ public RealmManagementException( String realmId, Artifact offendingArtifact, Str
|
|||
offendingVersion = offendingArtifact.getVersion();
|
||||
}
|
||||
|
||||
public RealmManagementException( String realmId,
|
||||
String message,
|
||||
NoSuchRealmException cause )
|
||||
public RealmManagementException( String realmId, String message, NoSuchRealmException cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.realmId = realmId;
|
||||
}
|
||||
|
||||
public RealmManagementException( String realmId,
|
||||
String message,
|
||||
ComponentRepositoryException cause )
|
||||
public RealmManagementException( String realmId, String message, ComponentRepositoryException cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.realmId = realmId;
|
||||
}
|
||||
|
||||
public RealmManagementException( String realmId,
|
||||
String message,
|
||||
PlexusConfigurationException cause )
|
||||
public RealmManagementException( String realmId, String message, PlexusConfigurationException cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.realmId = realmId;
|
||||
|
|
|
@ -23,10 +23,8 @@ public class RealmScanningUtils
|
|||
|
||||
private static final String DISCOVERY_REALM_ID = "discovery realm";
|
||||
|
||||
public static List scanForComponentSetDescriptors( Artifact artifact,
|
||||
ComponentDiscoverer discoverer,
|
||||
Context context,
|
||||
String discoveryContextId )
|
||||
public static List scanForComponentSetDescriptors( Artifact artifact, ComponentDiscoverer discoverer,
|
||||
Context context, String discoveryContextId )
|
||||
throws RealmManagementException
|
||||
{
|
||||
ClassWorld discoveryWorld = new ClassWorld();
|
||||
|
@ -44,7 +42,9 @@ public static List scanForComponentSetDescriptors( Artifact artifact,
|
|||
}
|
||||
catch ( DuplicateRealmException e )
|
||||
{
|
||||
throw new RealmManagementException( discoveryContextId, "Unable to create temporary ClassRealm for local-component discovery.", e );
|
||||
throw new RealmManagementException( discoveryContextId,
|
||||
"Unable to create temporary ClassRealm for local-component discovery.",
|
||||
e );
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -53,7 +53,9 @@ public static List scanForComponentSetDescriptors( Artifact artifact,
|
|||
}
|
||||
catch ( MalformedURLException e )
|
||||
{
|
||||
throw new RealmManagementException( discoveryContextId, artifact, "Unable to generate URL from artifact file: " + artifact.getFile() + " for local-component discovery.", e );
|
||||
throw new RealmManagementException( discoveryContextId, artifact,
|
||||
"Unable to generate URL from artifact file: " + artifact.getFile() +
|
||||
" for local-component discovery.", e );
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -65,7 +67,9 @@ public static List scanForComponentSetDescriptors( Artifact artifact,
|
|||
}
|
||||
catch ( PlexusConfigurationException e )
|
||||
{
|
||||
throw new RealmManagementException( discoveryContextId, "Unable to discover components in artifact: " + artifact.getId(), e );
|
||||
throw new RealmManagementException( discoveryContextId,
|
||||
"Unable to discover components in artifact: " + artifact.getId(),
|
||||
e );
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@ -92,7 +96,8 @@ public static ComponentDiscovererManager getDummyComponentDiscovererManager()
|
|||
return new DummyDiscovererManager();
|
||||
}
|
||||
|
||||
private static final class DummyDiscovererManager implements ComponentDiscovererManager
|
||||
private static final class DummyDiscovererManager
|
||||
implements ComponentDiscovererManager
|
||||
{
|
||||
|
||||
public void fireComponentDiscoveryEvent( ComponentDiscoveryEvent arg0 )
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue