mirror of https://github.com/apache/maven.git
Fixing project-loading to process inheritance in the correct direction, and finishing support for custom profile activators...also moving /project/build/extensions handling out to a separate extension scanner component, for later reuse elsewhere.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@501186 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3b44ad3ac3
commit
ad35b458bf
|
@ -42,6 +42,7 @@ public class DefaultArtifactFilterManager implements ArtifactFilterManager
|
|||
artifacts.add( "jsch" );
|
||||
artifacts.add( "maven-artifact" );
|
||||
artifacts.add( "maven-artifact-manager" );
|
||||
artifacts.add( "maven-build-context" );
|
||||
artifacts.add( "maven-core" );
|
||||
artifacts.add( "maven-error-diagnoser" );
|
||||
artifacts.add( "maven-model" );
|
||||
|
|
|
@ -17,9 +17,7 @@ package org.apache.maven;
|
|||
*/
|
||||
|
||||
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
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.versioning.DefaultArtifactVersion;
|
||||
import org.apache.maven.context.BuildContextManager;
|
||||
|
@ -32,31 +30,26 @@ import org.apache.maven.execution.MavenExecutionResult;
|
|||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.execution.RuntimeInformation;
|
||||
import org.apache.maven.extension.BuildExtensionScanner;
|
||||
import org.apache.maven.extension.ExtensionManager;
|
||||
import org.apache.maven.extension.ExtensionScanningException;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||
import org.apache.maven.monitor.event.EventDispatcher;
|
||||
import org.apache.maven.monitor.event.MavenEvents;
|
||||
import org.apache.maven.profiles.DefaultProfileManager;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
import org.apache.maven.profiles.activation.CustomActivatorAdvice;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||
import org.apache.maven.project.DuplicateProjectException;
|
||||
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.ModelLineage;
|
||||
import org.apache.maven.project.build.model.ModelLineageBuilder;
|
||||
import org.apache.maven.project.build.model.ModelLineageIterator;
|
||||
import org.apache.maven.reactor.MavenExecutionException;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnostics;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
import org.codehaus.plexus.context.Context;
|
||||
import org.codehaus.plexus.context.ContextException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
@ -90,10 +83,6 @@ public class DefaultMaven
|
|||
// Components
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
protected ExtensionManager extensionManager;
|
||||
|
||||
protected ModelLineageBuilder modelLineageBuilder;
|
||||
|
||||
protected BuildContextManager buildContextManager;
|
||||
|
||||
protected MavenProjectBuilder projectBuilder;
|
||||
|
@ -106,6 +95,8 @@ public class DefaultMaven
|
|||
|
||||
protected RuntimeInformation runtimeInformation;
|
||||
|
||||
private BuildExtensionScanner buildExtensionScanner;
|
||||
|
||||
private static final long MB = 1024 * 1024;
|
||||
|
||||
private static final int MS_PER_SEC = 1000;
|
||||
|
@ -354,7 +345,23 @@ public class DefaultMaven
|
|||
throw new MavenExecutionException( "Error selecting project files for the reactor: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
scanProjectsForExtensions( files, request, globalProfileManager );
|
||||
// TODO: We should probably do this discovery just-in-time, if we can move to building project
|
||||
// instances just-in-time.
|
||||
Map cache = new HashMap();
|
||||
|
||||
for ( Iterator it = files.iterator(); it.hasNext(); )
|
||||
{
|
||||
File pom = (File) it.next();
|
||||
|
||||
try
|
||||
{
|
||||
buildExtensionScanner.scanForBuildExtensions( pom, request.getLocalRepository(), globalProfileManager, cache );
|
||||
}
|
||||
catch ( ExtensionScanningException e )
|
||||
{
|
||||
throw new MavenExecutionException( "Error scanning: " + pom + " for extensions: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -377,109 +384,6 @@ public class DefaultMaven
|
|||
return projects;
|
||||
}
|
||||
|
||||
// TODO: We should probably do this discovery just-in-time, if we can move to building project
|
||||
// instances just-in-time.
|
||||
private void scanProjectsForExtensions( List files, MavenExecutionRequest request,
|
||||
ProfileManager globalProfileManager )
|
||||
throws MavenExecutionException
|
||||
{
|
||||
// setup the CustomActivatorAdvice to fail quietly while we discover extensions...then, we'll
|
||||
// reset it.
|
||||
CustomActivatorAdvice activatorAdvice = CustomActivatorAdvice.getCustomActivatorAdvice( buildContextManager );
|
||||
activatorAdvice.setFailQuietly( true );
|
||||
activatorAdvice.store( buildContextManager );
|
||||
|
||||
try
|
||||
{
|
||||
MavenProject superProject;
|
||||
try
|
||||
{
|
||||
superProject = projectBuilder.buildStandaloneSuperProject( request.getLocalRepository(),
|
||||
globalProfileManager );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new MavenExecutionException( "Error building super-POM for retrieving the default remote repository list: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
List originalRemoteRepositories = superProject.getRemoteArtifactRepositories();
|
||||
Map cache = new HashMap();
|
||||
|
||||
for ( Iterator it = files.iterator(); it.hasNext(); )
|
||||
{
|
||||
File pom = (File) it.next();
|
||||
|
||||
ModelLineage lineage;
|
||||
try
|
||||
{
|
||||
getLogger().debug( "Building model-lineage for: " + pom + " to pre-scan for extensions." );
|
||||
|
||||
lineage = modelLineageBuilder.buildModelLineage( pom, request.getLocalRepository(), originalRemoteRepositories, globalProfileManager, cache );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new MavenExecutionException( "Error building model lineage in order to pre-scan for extensions: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
for ( ModelLineageIterator lineageIterator = lineage.lineageIterator(); lineageIterator.hasNext(); )
|
||||
{
|
||||
Model model = (Model) lineageIterator.next();
|
||||
|
||||
Build build = model.getBuild();
|
||||
|
||||
if ( build != null )
|
||||
{
|
||||
List extensions = build.getExtensions();
|
||||
|
||||
if ( extensions != null && !extensions.isEmpty() )
|
||||
{
|
||||
List remoteRepositories = lineageIterator.getArtifactRepositories();
|
||||
|
||||
// thankfully, we don't have to deal with dependencyManagement here, yet.
|
||||
// TODO Revisit if/when extensions are made to use the info in dependencyManagement
|
||||
for ( Iterator extensionIterator = extensions.iterator(); extensionIterator.hasNext(); )
|
||||
{
|
||||
Extension extension = (Extension) extensionIterator.next();
|
||||
|
||||
getLogger().debug( "Adding extension: " + ArtifactUtils.versionlessKey( extension.getGroupId(), extension.getArtifactId() ) + " from model: " + model.getId() );
|
||||
|
||||
try
|
||||
{
|
||||
extensionManager.addExtension( extension, model, remoteRepositories, request.getLocalRepository() );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new MavenExecutionException( "Cannot resolve pre-scanned extension artifact: "
|
||||
+ extension.getGroupId() + ":" + extension.getArtifactId() + ": " + e.getMessage(),
|
||||
e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new MavenExecutionException( "Cannot find pre-scanned extension artifact: "
|
||||
+ extension.getGroupId() + ":" + extension.getArtifactId() + ": " + e.getMessage(),
|
||||
e );
|
||||
}
|
||||
catch ( PlexusContainerException e )
|
||||
{
|
||||
throw new MavenExecutionException( "Failed to add pre-scanned extension: "
|
||||
+ extension.getGroupId() + ":" + extension.getArtifactId() + ": " + e.getMessage(),
|
||||
e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extensionManager.registerWagons();
|
||||
}
|
||||
finally
|
||||
{
|
||||
activatorAdvice.reset();
|
||||
activatorAdvice.store( buildContextManager );
|
||||
}
|
||||
}
|
||||
|
||||
private void logReactorSummaryLine( String name,
|
||||
String status )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.apache.maven.extension;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BuildExtensionScanner
|
||||
{
|
||||
|
||||
String ROLE = BuildExtensionScanner.class.getName();
|
||||
|
||||
void scanForBuildExtensions( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager, Map pomFilesById )
|
||||
throws ExtensionScanningException;
|
||||
|
||||
}
|
|
@ -0,0 +1,255 @@
|
|||
package org.apache.maven.extension;
|
||||
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
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.context.BuildContextManager;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
import org.apache.maven.profiles.activation.CustomActivatorAdvice;
|
||||
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.ModelLineage;
|
||||
import org.apache.maven.project.build.model.ModelLineageBuilder;
|
||||
import org.apache.maven.project.build.model.ModelLineageIterator;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolator;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
import org.codehaus.plexus.logging.LogEnabled;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public class DefaultBuildExtensionScanner
|
||||
implements BuildExtensionScanner, LogEnabled
|
||||
{
|
||||
|
||||
private Logger logger;
|
||||
|
||||
private BuildContextManager buildContextManager;
|
||||
|
||||
private ExtensionManager extensionManager;
|
||||
|
||||
private MavenProjectBuilder projectBuilder;
|
||||
|
||||
private ModelLineageBuilder modelLineageBuilder;
|
||||
|
||||
private ModelInterpolator modelInterpolator;
|
||||
|
||||
public void scanForBuildExtensions( File pom, ArtifactRepository localRepository,
|
||||
ProfileManager globalProfileManager, Map pomFilesById )
|
||||
throws ExtensionScanningException
|
||||
{
|
||||
// setup the CustomActivatorAdvice to fail quietly while we discover extensions...then, we'll
|
||||
// reset it.
|
||||
CustomActivatorAdvice activatorAdvice = CustomActivatorAdvice.getCustomActivatorAdvice( buildContextManager );
|
||||
activatorAdvice.setFailQuietly( true );
|
||||
activatorAdvice.store( buildContextManager );
|
||||
|
||||
try
|
||||
{
|
||||
List originalRemoteRepositories = getInitialRemoteRepositories( localRepository, globalProfileManager );
|
||||
|
||||
getLogger().debug( "Pre-scanning POM lineage of: " + pom + " for build extensions." );
|
||||
|
||||
ModelLineage lineage = buildModelLineage( pom, localRepository, originalRemoteRepositories,
|
||||
globalProfileManager, pomFilesById );
|
||||
|
||||
Map inheritedInterpolationValues = new HashMap();
|
||||
|
||||
for ( ModelLineageIterator lineageIterator = lineage.reversedLineageIterator(); lineageIterator.hasNext(); )
|
||||
{
|
||||
Model model = (Model) lineageIterator.next();
|
||||
|
||||
getLogger().debug( "Checking: " + model.getId() + " for extensions." );
|
||||
|
||||
if ( inheritedInterpolationValues == null )
|
||||
{
|
||||
inheritedInterpolationValues = new HashMap();
|
||||
}
|
||||
|
||||
model = modelInterpolator.interpolate( model, inheritedInterpolationValues, false );
|
||||
|
||||
checkModelBuildForExtensions( model, localRepository, lineageIterator.getArtifactRepositories() );
|
||||
|
||||
checkModulesForExtensions( pom, model, localRepository, originalRemoteRepositories, globalProfileManager,
|
||||
pomFilesById );
|
||||
|
||||
Properties modelProps = model.getProperties();
|
||||
if ( modelProps != null )
|
||||
{
|
||||
inheritedInterpolationValues.putAll( modelProps );
|
||||
}
|
||||
}
|
||||
|
||||
getLogger().debug( "Finished pre-scanning: " + pom + " for build extensions." );
|
||||
|
||||
extensionManager.registerWagons();
|
||||
}
|
||||
catch ( ModelInterpolationException e )
|
||||
{
|
||||
throw new ExtensionScanningException( "Failed to interpolate model from: " + pom + " prior to scanning for extensions.", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
activatorAdvice.reset();
|
||||
activatorAdvice.store( buildContextManager );
|
||||
}
|
||||
}
|
||||
|
||||
private void checkModulesForExtensions( File containingPom, Model model, ArtifactRepository localRepository,
|
||||
List originalRemoteRepositories, ProfileManager globalProfileManager,
|
||||
Map pomFilesById )
|
||||
throws ExtensionScanningException
|
||||
{
|
||||
// FIXME: This gets a little sticky, because modules can be added by profiles that require
|
||||
// an extension in place before they can be activated.
|
||||
List modules = model.getModules();
|
||||
|
||||
if ( modules != null )
|
||||
{
|
||||
File basedir = containingPom.getParentFile();
|
||||
|
||||
for ( Iterator it = modules.iterator(); it.hasNext(); )
|
||||
{
|
||||
// TODO: change this if we ever find a way to replace module definitions with g:a:v
|
||||
String moduleSubpath = (String) it.next();
|
||||
|
||||
getLogger().debug( "Scanning module: " + moduleSubpath );
|
||||
|
||||
File modulePom = new File( basedir, moduleSubpath );
|
||||
|
||||
if ( modulePom.isDirectory() )
|
||||
{
|
||||
getLogger().debug(
|
||||
"Assuming POM file 'pom.xml' in module: " + moduleSubpath + " under basedir: "
|
||||
+ basedir );
|
||||
modulePom = new File( modulePom, "pom.xml" );
|
||||
}
|
||||
|
||||
if ( !modulePom.exists() )
|
||||
{
|
||||
getLogger().debug(
|
||||
"Cannot find POM for module: " + moduleSubpath
|
||||
+ "; continuing scan with next module." );
|
||||
continue;
|
||||
}
|
||||
|
||||
scanForBuildExtensions( modulePom, localRepository, globalProfileManager, pomFilesById );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkModelBuildForExtensions( Model model, ArtifactRepository localRepository, List remoteRepositories )
|
||||
throws ExtensionScanningException
|
||||
{
|
||||
Build build = model.getBuild();
|
||||
|
||||
if ( build != null )
|
||||
{
|
||||
List extensions = build.getExtensions();
|
||||
|
||||
if ( extensions != null && !extensions.isEmpty() )
|
||||
{
|
||||
// thankfully, we don't have to deal with dependencyManagement here, yet.
|
||||
// TODO Revisit if/when extensions are made to use the info in dependencyManagement
|
||||
for ( Iterator extensionIterator = extensions.iterator(); extensionIterator.hasNext(); )
|
||||
{
|
||||
Extension extension = (Extension) extensionIterator.next();
|
||||
|
||||
getLogger().debug(
|
||||
"Adding extension: "
|
||||
+ ArtifactUtils.versionlessKey( extension.getGroupId(), extension
|
||||
.getArtifactId() ) + " from model: " + model.getId() );
|
||||
|
||||
try
|
||||
{
|
||||
extensionManager.addExtension( extension, model, remoteRepositories, localRepository );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new ExtensionScanningException( "Cannot resolve pre-scanned extension artifact: "
|
||||
+ extension.getGroupId() + ":" + extension.getArtifactId() + ": " + e.getMessage(), e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new ExtensionScanningException( "Cannot find pre-scanned extension artifact: "
|
||||
+ extension.getGroupId() + ":" + extension.getArtifactId() + ": " + e.getMessage(), e );
|
||||
}
|
||||
catch ( PlexusContainerException e )
|
||||
{
|
||||
throw new ExtensionScanningException( "Failed to add pre-scanned extension: "
|
||||
+ extension.getGroupId() + ":" + extension.getArtifactId() + ": " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository,
|
||||
List originalRemoteRepositories, ProfileManager globalProfileManager,
|
||||
Map cache )
|
||||
throws ExtensionScanningException
|
||||
{
|
||||
ModelLineage lineage;
|
||||
try
|
||||
{
|
||||
getLogger().debug( "Building model-lineage for: " + pom + " to pre-scan for extensions." );
|
||||
|
||||
lineage = modelLineageBuilder.buildModelLineage( pom, localRepository, originalRemoteRepositories,
|
||||
globalProfileManager, cache );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new ExtensionScanningException( "Error building model lineage in order to pre-scan for extensions: "
|
||||
+ e.getMessage(), e );
|
||||
}
|
||||
|
||||
return lineage;
|
||||
}
|
||||
|
||||
private List getInitialRemoteRepositories( ArtifactRepository localRepository, ProfileManager globalProfileManager )
|
||||
throws ExtensionScanningException
|
||||
{
|
||||
MavenProject superProject;
|
||||
try
|
||||
{
|
||||
superProject = projectBuilder.buildStandaloneSuperProject( localRepository, globalProfileManager );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new ExtensionScanningException(
|
||||
"Error building super-POM for retrieving the default remote repository list: "
|
||||
+ e.getMessage(), e );
|
||||
}
|
||||
|
||||
return superProject.getRemoteArtifactRepositories();
|
||||
}
|
||||
|
||||
protected Logger getLogger()
|
||||
{
|
||||
if ( logger == null )
|
||||
{
|
||||
logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "DefaultBuildExtensionScanner:internal" );
|
||||
}
|
||||
|
||||
return logger;
|
||||
}
|
||||
|
||||
public void enableLogging( Logger logger )
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
}
|
|
@ -124,6 +124,8 @@ public class DefaultExtensionManager
|
|||
ActiveArtifactResolver activeArtifactResolver )
|
||||
throws ArtifactResolutionException, PlexusContainerException, ArtifactNotFoundException
|
||||
{
|
||||
getLogger().debug( "Starting extension-addition process for: " + extensionArtifact );
|
||||
|
||||
if ( extensionArtifact != null )
|
||||
{
|
||||
ArtifactFilter filter =
|
||||
|
@ -142,7 +144,7 @@ public class DefaultExtensionManager
|
|||
a = activeArtifactResolver.replaceWithActiveArtifact( a );
|
||||
}
|
||||
|
||||
getLogger().debug( "Adding to extension classpath: " + a.getFile() );
|
||||
getLogger().debug( "Adding to extension classpath: " + a.getFile() + " in classRealm: " + container.getContainerRealm().getId() );
|
||||
|
||||
container.addJarResource( a.getFile() );
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.apache.maven.extension;
|
||||
|
||||
public class ExtensionScanningException
|
||||
extends Exception
|
||||
{
|
||||
|
||||
public ExtensionScanningException( String message, Throwable cause )
|
||||
{
|
||||
super( message, cause );
|
||||
}
|
||||
|
||||
public ExtensionScanningException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,30 @@
|
|||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.extension.BuildExtensionScanner</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.extension.DefaultBuildExtensionScanner</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.extension.ExtensionManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.context.BuildContextManager</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.MavenProjectBuilder</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.ArtifactFilterManager</role>
|
||||
<implementation>org.apache.maven.DefaultArtifactFilterManager</implementation>
|
||||
|
@ -84,10 +109,7 @@
|
|||
<implementation>org.apache.maven.DefaultMaven</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.extension.ExtensionManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
|
||||
<role>org.apache.maven.extension.BuildExtensionScanner</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
|
|
|
@ -257,7 +257,14 @@ public class DefaultProfileManager
|
|||
|
||||
if ( activator.canDetermineActivation( profile ) )
|
||||
{
|
||||
return activator.isActive( profile );
|
||||
boolean result = activator.isActive( profile );
|
||||
|
||||
if ( result )
|
||||
{
|
||||
container.getLogger().debug( "Profile: " + profile.getId() + " is active. (source: " + profile.getSource() + ")" );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,11 +90,9 @@ public class CustomActivator
|
|||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
getLogger().debug( "Failed to lookup ProfileActivator \'" + type + "\'", e );
|
||||
|
||||
if ( !advice.failQuietly() )
|
||||
{
|
||||
throw new ProfileActivationException( "Cannot find ProfileActivator with role-hint: " + type
|
||||
throw new ProfileActivationException( "Cannot find custom ProfileActivator: " + type
|
||||
+ ". \nPerhaps you're missing a build extension?", e );
|
||||
}
|
||||
}
|
||||
|
@ -109,11 +107,9 @@ public class CustomActivator
|
|||
}
|
||||
catch ( ComponentConfigurationException e )
|
||||
{
|
||||
getLogger().debug( "Failed to configure ProfileActivator \'" + type + "\'", e );
|
||||
|
||||
if ( !advice.failQuietly() )
|
||||
{
|
||||
throw new ProfileActivationException( "Failed to configure ProfileActivator with role-hint: " + type
|
||||
throw new ProfileActivationException( "Failed to configure custom ProfileActivator: " + type
|
||||
+ ".", e );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class CustomActivatorAdvice
|
|||
|
||||
public static final String BUILD_CONTEXT_KEY = CustomActivatorAdvice.class.getName();
|
||||
|
||||
private static final boolean DEFAULT_FAIL_QUIETLY = true;
|
||||
private static final boolean DEFAULT_FAIL_QUIETLY = false;
|
||||
|
||||
/**
|
||||
* If set to false, this tells the CustomProfileActivator to fail quietly when the specified
|
||||
|
|
|
@ -368,4 +368,44 @@ public class DefaultModelLineage
|
|||
};
|
||||
}
|
||||
|
||||
public ModelLineageIterator reversedLineageIterator()
|
||||
{
|
||||
return new ModelLineageIterator()
|
||||
{
|
||||
|
||||
private int idx = tuples.size();
|
||||
|
||||
public boolean hasNext()
|
||||
{
|
||||
return idx > 0;
|
||||
}
|
||||
|
||||
public Object next()
|
||||
{
|
||||
return ( (ModelLineageTuple) tuples.get( ( --idx ) ) ).model;
|
||||
}
|
||||
|
||||
public void remove()
|
||||
{
|
||||
tuples.remove( idx );
|
||||
}
|
||||
|
||||
public List getArtifactRepositories()
|
||||
{
|
||||
return ( (ModelLineageTuple) tuples.get( idx ) ).remoteRepositories;
|
||||
}
|
||||
|
||||
public Model getModel()
|
||||
{
|
||||
return ( (ModelLineageTuple) tuples.get( idx ) ).model;
|
||||
}
|
||||
|
||||
public File getPOMFile()
|
||||
{
|
||||
return ( (ModelLineageTuple) tuples.get( idx ) ).file;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -97,6 +97,14 @@ public interface ModelLineage
|
|||
*/
|
||||
ModelLineageIterator lineageIterator();
|
||||
|
||||
/**
|
||||
* Retrieve an Iterator derivative that functions in the simplest sense just like the return
|
||||
* value of the modelIterator() method. However, the ModelLineageIterator also gives access to
|
||||
* the current POM file and current remote ArtifactRepository instances used to resolve the
|
||||
* current Model...along with a method to give explicit access to the current Model instance.
|
||||
*/
|
||||
ModelLineageIterator reversedLineageIterator();
|
||||
|
||||
/**
|
||||
* Iterate over the lineage of Model instances, starting with the child (current) Model,
|
||||
* and ending with the deepest ancestor.
|
||||
|
|
Loading…
Reference in New Issue