mirror of https://github.com/apache/maven.git
Removing pluginRepository use (finally), and fixing pluginGroups usage with profiles from the settings and super-POM without an accompanying pom.xml in the project directory...I know, something of a convoluted case.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@599692 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b310a40d6b
commit
2ec256bab6
|
@ -115,6 +115,12 @@ under the License.
|
||||||
<version>1.2_Java1.3</version>
|
<version>1.2_Java1.3</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.shared</groupId>
|
||||||
|
<artifactId>maven-test-tools</artifactId>
|
||||||
|
<version>1.0-alpha-1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Needed for backward compat aspect. -->
|
<!-- Needed for backward compat aspect. -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -282,102 +282,116 @@ public class DefaultMaven
|
||||||
{
|
{
|
||||||
List projects = new ArrayList( files.size() );
|
List projects = new ArrayList( files.size() );
|
||||||
|
|
||||||
for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
|
if ( files.isEmpty() )
|
||||||
{
|
{
|
||||||
File file = (File) iterator.next();
|
|
||||||
|
|
||||||
boolean usingReleasePom = false;
|
|
||||||
|
|
||||||
if ( RELEASE_POMv4.equals( file.getName() ) )
|
|
||||||
{
|
|
||||||
getLogger().info( "NOTE: Using release-pom: " + file + " in reactor build." );
|
|
||||||
|
|
||||||
usingReleasePom = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MavenProject project;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
project = projectBuilder.build( file, localRepository, globalProfileManager );
|
projects.add( projectBuilder.buildStandaloneSuperProject( globalProfileManager ) );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
throw new MavenExecutionException( "Failed to build MavenProject instance for: " + file, file, e );
|
throw new MavenExecutionException( "Failed to build super-project instance.", e );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( isRoot )
|
else
|
||||||
|
{
|
||||||
|
for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
|
||||||
{
|
{
|
||||||
project.setExecutionRoot( true );
|
File file = (File) iterator.next();
|
||||||
}
|
|
||||||
|
|
||||||
if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) )
|
boolean usingReleasePom = false;
|
||||||
{
|
|
||||||
DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
|
|
||||||
|
|
||||||
if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 )
|
if ( RELEASE_POMv4.equals( file.getName() ) )
|
||||||
{
|
{
|
||||||
throw new MavenExecutionException(
|
getLogger().info( "NOTE: Using release-pom: " + file + " in reactor build." );
|
||||||
"Unable to build project '" + file +
|
|
||||||
"; it requires Maven version " + version.toString(), file );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ( project.getModules() != null ) && !project.getModules().isEmpty() && recursive )
|
usingReleasePom = true;
|
||||||
{
|
|
||||||
// TODO: Really should fail if it was not? What if it is aggregating - eg "ear"?
|
|
||||||
project.setPackaging( "pom" );
|
|
||||||
|
|
||||||
File basedir = file.getParentFile();
|
|
||||||
|
|
||||||
// Initial ordering is as declared in the modules section
|
|
||||||
List moduleFiles = new ArrayList( project.getModules().size() );
|
|
||||||
|
|
||||||
for ( Iterator i = project.getModules().iterator(); i.hasNext(); )
|
|
||||||
{
|
|
||||||
String name = (String) i.next();
|
|
||||||
|
|
||||||
if ( StringUtils.isEmpty( StringUtils.trim( name ) ) )
|
|
||||||
{
|
|
||||||
getLogger().warn( "Empty module detected. Please check you don't have any empty module definitions in your POM." );
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
File moduleFile;
|
|
||||||
|
|
||||||
if ( usingReleasePom )
|
|
||||||
{
|
|
||||||
moduleFile = new File( basedir, name + "/" + Maven.RELEASE_POMv4 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
moduleFile = new File( basedir, name + "/" + Maven.POMv4 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
|
|
||||||
{
|
|
||||||
// we don't canonicalize on unix to avoid interfering with symlinks
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
moduleFile = moduleFile.getCanonicalFile();
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new MavenExecutionException( "Unable to canonicalize file name " + moduleFile, e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleFiles.add( moduleFile );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List collectedProjects = collectProjects( moduleFiles, localRepository, recursive,
|
MavenProject project;
|
||||||
globalProfileManager, false );
|
try
|
||||||
|
{
|
||||||
|
project = projectBuilder.build( file, localRepository, globalProfileManager );
|
||||||
|
}
|
||||||
|
catch ( ProjectBuildingException e )
|
||||||
|
{
|
||||||
|
throw new MavenExecutionException( "Failed to build MavenProject instance for: " + file, file, e );
|
||||||
|
}
|
||||||
|
|
||||||
projects.addAll( collectedProjects );
|
if ( isRoot )
|
||||||
project.setCollectedProjects( collectedProjects );
|
{
|
||||||
|
project.setExecutionRoot( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) )
|
||||||
|
{
|
||||||
|
DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
|
||||||
|
|
||||||
|
if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 )
|
||||||
|
{
|
||||||
|
throw new MavenExecutionException(
|
||||||
|
"Unable to build project '" + file +
|
||||||
|
"; it requires Maven version " + version.toString(), file );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( project.getModules() != null ) && !project.getModules().isEmpty() && recursive )
|
||||||
|
{
|
||||||
|
// TODO: Really should fail if it was not? What if it is aggregating - eg "ear"?
|
||||||
|
project.setPackaging( "pom" );
|
||||||
|
|
||||||
|
File basedir = file.getParentFile();
|
||||||
|
|
||||||
|
// Initial ordering is as declared in the modules section
|
||||||
|
List moduleFiles = new ArrayList( project.getModules().size() );
|
||||||
|
|
||||||
|
for ( Iterator i = project.getModules().iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
String name = (String) i.next();
|
||||||
|
|
||||||
|
if ( StringUtils.isEmpty( StringUtils.trim( name ) ) )
|
||||||
|
{
|
||||||
|
getLogger().warn( "Empty module detected. Please check you don't have any empty module definitions in your POM." );
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File moduleFile;
|
||||||
|
|
||||||
|
if ( usingReleasePom )
|
||||||
|
{
|
||||||
|
moduleFile = new File( basedir, name + "/" + Maven.RELEASE_POMv4 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
moduleFile = new File( basedir, name + "/" + Maven.POMv4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
|
||||||
|
{
|
||||||
|
// we don't canonicalize on unix to avoid interfering with symlinks
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
moduleFile = moduleFile.getCanonicalFile();
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new MavenExecutionException( "Unable to canonicalize file name " + moduleFile, e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleFiles.add( moduleFile );
|
||||||
|
}
|
||||||
|
|
||||||
|
List collectedProjects = collectProjects( moduleFiles, localRepository, recursive,
|
||||||
|
globalProfileManager, false );
|
||||||
|
|
||||||
|
projects.addAll( collectedProjects );
|
||||||
|
project.setCollectedProjects( collectedProjects );
|
||||||
|
}
|
||||||
|
projects.add( project );
|
||||||
}
|
}
|
||||||
projects.add( project );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return projects;
|
return projects;
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.maven.model.Extension;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.Parent;
|
import org.apache.maven.model.Parent;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.plugin.loader.PluginLoader;
|
import org.apache.maven.model.PluginManagement;
|
||||||
import org.apache.maven.profiles.ProfileManager;
|
import org.apache.maven.profiles.ProfileManager;
|
||||||
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
|
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
|
||||||
import org.apache.maven.profiles.activation.ProfileActivationContext;
|
import org.apache.maven.profiles.activation.ProfileActivationContext;
|
||||||
|
@ -47,10 +47,12 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class DefaultBuildExtensionScanner
|
public class DefaultBuildExtensionScanner
|
||||||
implements BuildExtensionScanner, LogEnabled
|
implements BuildExtensionScanner, LogEnabled
|
||||||
|
@ -66,8 +68,6 @@ public class DefaultBuildExtensionScanner
|
||||||
|
|
||||||
private ModelInterpolator modelInterpolator;
|
private ModelInterpolator modelInterpolator;
|
||||||
|
|
||||||
private PluginLoader pluginLoader;
|
|
||||||
|
|
||||||
public void scanForBuildExtensions( List files,
|
public void scanForBuildExtensions( List files,
|
||||||
MavenExecutionRequest request )
|
MavenExecutionRequest request )
|
||||||
throws ExtensionScanningException
|
throws ExtensionScanningException
|
||||||
|
@ -112,6 +112,8 @@ public class DefaultBuildExtensionScanner
|
||||||
|
|
||||||
inheritedRemoteRepositories.addAll( originalRemoteRepositories );
|
inheritedRemoteRepositories.addAll( originalRemoteRepositories );
|
||||||
|
|
||||||
|
Set managedPluginsWithExtensionsFlag = new HashSet();
|
||||||
|
|
||||||
for ( ModelLineageIterator lineageIterator = lineage.reversedLineageIterator(); lineageIterator.hasNext(); )
|
for ( ModelLineageIterator lineageIterator = lineage.reversedLineageIterator(); lineageIterator.hasNext(); )
|
||||||
{
|
{
|
||||||
Model model = (Model) lineageIterator.next();
|
Model model = (Model) lineageIterator.next();
|
||||||
|
@ -144,7 +146,9 @@ public class DefaultBuildExtensionScanner
|
||||||
|
|
||||||
model = modelInterpolator.interpolate( model, inheritedInterpolationValues, false );
|
model = modelInterpolator.interpolate( model, inheritedInterpolationValues, false );
|
||||||
|
|
||||||
checkModelBuildForExtensions( model, request, inheritedRemoteRepositories );
|
grabManagedPluginsWithExtensionsFlagTurnedOn( model, managedPluginsWithExtensionsFlag );
|
||||||
|
|
||||||
|
checkModelBuildForExtensions( model, request, inheritedRemoteRepositories, managedPluginsWithExtensionsFlag );
|
||||||
|
|
||||||
if ( !reactorFiles.contains( modelPom ) )
|
if ( !reactorFiles.contains( modelPom ) )
|
||||||
{
|
{
|
||||||
|
@ -180,6 +184,31 @@ public class DefaultBuildExtensionScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void grabManagedPluginsWithExtensionsFlagTurnedOn( Model model,
|
||||||
|
Set managedPluginsWithExtensionsFlag )
|
||||||
|
{
|
||||||
|
Build build = model.getBuild();
|
||||||
|
if ( build != null )
|
||||||
|
{
|
||||||
|
PluginManagement pluginManagement = build.getPluginManagement();
|
||||||
|
if ( pluginManagement != null )
|
||||||
|
{
|
||||||
|
List plugins = pluginManagement.getPlugins();
|
||||||
|
if ( ( plugins != null ) && !plugins.isEmpty() )
|
||||||
|
{
|
||||||
|
for ( Iterator it = plugins.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Plugin plugin = (Plugin) it.next();
|
||||||
|
if ( plugin.isExtensions() )
|
||||||
|
{
|
||||||
|
managedPluginsWithExtensionsFlag.add( plugin.getKey() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String createKey( Model model )
|
private String createKey( Model model )
|
||||||
{
|
{
|
||||||
Parent parent = model.getParent();
|
Parent parent = model.getParent();
|
||||||
|
@ -271,7 +300,10 @@ public class DefaultBuildExtensionScanner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkModelBuildForExtensions( Model model, MavenExecutionRequest request, List remoteRepositories )
|
private void checkModelBuildForExtensions( Model model,
|
||||||
|
MavenExecutionRequest request,
|
||||||
|
List remoteRepositories,
|
||||||
|
Set managedPluginsWithExtensionsFlag )
|
||||||
throws ExtensionScanningException
|
throws ExtensionScanningException
|
||||||
{
|
{
|
||||||
// FIXME: Fix the log level here.
|
// FIXME: Fix the log level here.
|
||||||
|
@ -316,7 +348,7 @@ public class DefaultBuildExtensionScanner
|
||||||
{
|
{
|
||||||
Plugin plugin = (Plugin) extensionIterator.next();
|
Plugin plugin = (Plugin) extensionIterator.next();
|
||||||
|
|
||||||
if ( plugin.isExtensions() )
|
if ( plugin.isExtensions() || managedPluginsWithExtensionsFlag.contains( plugin.getKey() ) )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Adding plugin: " + plugin.getKey() + " as an extension(from model: " + model.getId() + ")" );
|
getLogger().debug( "Adding plugin: " + plugin.getKey() + " as an extension(from model: " + model.getId() + ")" );
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ import org.codehaus.plexus.context.ContextException;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -207,8 +206,7 @@ public class DefaultExtensionManager
|
||||||
{
|
{
|
||||||
MavenProject dummyProject = new MavenProject( originatingModel );
|
MavenProject dummyProject = new MavenProject( originatingModel );
|
||||||
|
|
||||||
dummyProject.setPluginArtifactRepositories( remoteRepositories );
|
dummyProject.setRemoteArtifactRepositories( remoteRepositories );
|
||||||
dummyProject.setRemoteArtifactRepositories( Collections.EMPTY_LIST );
|
|
||||||
|
|
||||||
EventDispatcher dispatcher = new DefaultEventDispatcher( request.getEventMonitors() );
|
EventDispatcher dispatcher = new DefaultEventDispatcher( request.getEventMonitors() );
|
||||||
MavenSession session = new MavenSession( container, request, dispatcher, null );
|
MavenSession session = new MavenSession( container, request, dispatcher, null );
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class DefaultPluginManager
|
||||||
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
|
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
|
||||||
// use for the mapping manager in here
|
// use for the mapping manager in here
|
||||||
return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(),
|
return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(),
|
||||||
project.getPluginArtifactRepositories(),
|
project.getRemoteArtifactRepositories(),
|
||||||
session.getLocalRepository() );
|
session.getLocalRepository() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
List remoteRepositories = new ArrayList();
|
List remoteRepositories = new ArrayList();
|
||||||
|
|
||||||
remoteRepositories.addAll( project.getPluginArtifactRepositories() );
|
// remoteRepositories.addAll( project.getPluginArtifactRepositories() );
|
||||||
|
|
||||||
remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
|
remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
|
pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
|
||||||
|
|
||||||
artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(),
|
artifactResolver.resolve( pluginArtifact, project.getRemoteArtifactRepositories(),
|
||||||
localRepository );
|
localRepository );
|
||||||
|
|
||||||
addPlugin( plugin, pluginArtifact, project, session );
|
addPlugin( plugin, pluginArtifact, project, session );
|
||||||
|
@ -440,7 +440,7 @@ public class DefaultPluginManager
|
||||||
resolutionGroup = artifactMetadataSource.retrieve(
|
resolutionGroup = artifactMetadataSource.retrieve(
|
||||||
pluginArtifact,
|
pluginArtifact,
|
||||||
localRepository,
|
localRepository,
|
||||||
project.getPluginArtifactRepositories() );
|
project.getRemoteArtifactRepositories() );
|
||||||
}
|
}
|
||||||
catch ( ArtifactMetadataRetrievalException e )
|
catch ( ArtifactMetadataRetrievalException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutio
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -37,7 +36,7 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage plugin prefix to artifact ID mapping associations.
|
* Manage plugin prefix to artifact ID mapping associations.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
* @version $Id: DefaultPluginMappingManager.java 495147 2007-01-11 07:47:53Z
|
* @version $Id: DefaultPluginMappingManager.java 495147 2007-01-11 07:47:53Z
|
||||||
* jvanzyl $
|
* jvanzyl $
|
||||||
|
@ -61,7 +60,14 @@ public class DefaultPluginMappingManager
|
||||||
loadPluginMappings( groupIds, pluginRepositories, localRepository );
|
loadPluginMappings( groupIds, pluginRepositories, localRepository );
|
||||||
}
|
}
|
||||||
|
|
||||||
return (org.apache.maven.model.Plugin) pluginDefinitionsByPrefix.get( pluginPrefix );
|
org.apache.maven.model.Plugin result = (org.apache.maven.model.Plugin) pluginDefinitionsByPrefix.get( pluginPrefix );
|
||||||
|
|
||||||
|
if ( result == null )
|
||||||
|
{
|
||||||
|
getLogger().debug( "Failed to resolve plugin from prefix: " + pluginPrefix, new Throwable() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadPluginMappings( List groupIds, List pluginRepositories, ArtifactRepository localRepository )
|
private void loadPluginMappings( List groupIds, List pluginRepositories, ArtifactRepository localRepository )
|
||||||
|
@ -100,6 +106,7 @@ public class DefaultPluginMappingManager
|
||||||
{
|
{
|
||||||
RepositoryMetadata metadata = new GroupRepositoryMetadata( groupId );
|
RepositoryMetadata metadata = new GroupRepositoryMetadata( groupId );
|
||||||
|
|
||||||
|
getLogger().debug( "Checking repositories:\n" + pluginRepositories + "\n\nfor plugin prefix metadata: " + groupId );
|
||||||
repositoryMetadataManager.resolve( metadata, pluginRepositories, localRepository );
|
repositoryMetadataManager.resolve( metadata, pluginRepositories, localRepository );
|
||||||
|
|
||||||
Metadata repoMetadata = metadata.getMetadata();
|
Metadata repoMetadata = metadata.getMetadata();
|
||||||
|
@ -108,9 +115,10 @@ public class DefaultPluginMappingManager
|
||||||
for ( Iterator pluginIterator = repoMetadata.getPlugins().iterator(); pluginIterator.hasNext(); )
|
for ( Iterator pluginIterator = repoMetadata.getPlugins().iterator(); pluginIterator.hasNext(); )
|
||||||
{
|
{
|
||||||
Plugin mapping = (Plugin) pluginIterator.next();
|
Plugin mapping = (Plugin) pluginIterator.next();
|
||||||
|
getLogger().debug( "Found plugin: " + mapping.getName() + " with prefix: " + mapping.getPrefix() );
|
||||||
|
|
||||||
String prefix = mapping.getPrefix();
|
String prefix = mapping.getPrefix();
|
||||||
|
|
||||||
//if the prefix has already been found, don't add it again.
|
//if the prefix has already been found, don't add it again.
|
||||||
//this is to preserve the correct ordering of prefix searching (MNG-2926)
|
//this is to preserve the correct ordering of prefix searching (MNG-2926)
|
||||||
if ( !pluginDefinitionsByPrefix.containsKey( prefix ) )
|
if ( !pluginDefinitionsByPrefix.containsKey( prefix ) )
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class DefaultPluginLoader
|
||||||
Settings settings = session.getSettings();
|
Settings settings = session.getSettings();
|
||||||
|
|
||||||
Plugin plugin = pluginMappingManager.getByPrefix( prefix, settings.getPluginGroups(),
|
Plugin plugin = pluginMappingManager.getByPrefix( prefix, settings.getPluginGroups(),
|
||||||
project.getPluginArtifactRepositories(), session.getLocalRepository() );
|
project.getRemoteArtifactRepositories(), session.getLocalRepository() );
|
||||||
|
|
||||||
PluginDescriptor pluginDescriptor = null;
|
PluginDescriptor pluginDescriptor = null;
|
||||||
if ( plugin != null )
|
if ( plugin != null )
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class DefaultPluginVersionManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ResolutionGroup resolutionGroup =
|
ResolutionGroup resolutionGroup =
|
||||||
artifactMetadataSource.retrieve( artifact, localRepository, project.getPluginArtifactRepositories() );
|
artifactMetadataSource.retrieve( artifact, localRepository, project.getRemoteArtifactRepositories() );
|
||||||
|
|
||||||
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
|
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
|
||||||
// artifact.
|
// artifact.
|
||||||
|
@ -215,7 +215,7 @@ public class DefaultPluginVersionManager
|
||||||
{
|
{
|
||||||
artifact = artifactFactory.createProjectArtifact( groupId, artifactId, artifactVersion );
|
artifact = artifactFactory.createProjectArtifact( groupId, artifactId, artifactVersion );
|
||||||
|
|
||||||
pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project.getPluginArtifactRepositories(), localRepository );
|
pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project.getRemoteArtifactRepositories(), localRepository );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
|
@ -250,7 +250,7 @@ public class DefaultPluginVersionManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List versions = artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository,
|
List versions = artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository,
|
||||||
project.getPluginArtifactRepositories() );
|
project.getRemoteArtifactRepositories() );
|
||||||
ArtifactVersion v = vr.matchVersion( versions );
|
ArtifactVersion v = vr.matchVersion( versions );
|
||||||
artifactVersion = v != null ? v.toString() : null;
|
artifactVersion = v != null ? v.toString() : null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,12 @@ public class MavenExecutionException
|
||||||
super( message, cause );
|
super( message, cause );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MavenExecutionException( String message,
|
||||||
|
ProjectBuildingException cause )
|
||||||
|
{
|
||||||
|
super( message, cause );
|
||||||
|
}
|
||||||
|
|
||||||
public File getPomFile()
|
public File getPomFile()
|
||||||
{
|
{
|
||||||
return pomFile;
|
return pomFile;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.maven.plugin.PluginManagerException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.component.repository.ComponentDescriptor;
|
import org.codehaus.plexus.component.repository.ComponentDescriptor;
|
||||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||||
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -21,7 +22,9 @@ public class MavenEmbedderProjectWithExtensionReadingTest
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true )
|
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true )
|
||||||
.setPom( new File( basedir, "src/test/resources/pom2.xml" ) );
|
.setPom( new File( basedir, "src/test/resources/pom2.xml" ) )
|
||||||
|
// TODO: Remove this!
|
||||||
|
.setLoggingLevel( Logger.LEVEL_DEBUG );
|
||||||
|
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
|
@ -39,12 +42,14 @@ public class MavenEmbedderProjectWithExtensionReadingTest
|
||||||
|
|
||||||
embedder.getPlexusContainer().addComponentDescriptor( cd );
|
embedder.getPlexusContainer().addComponentDescriptor( cd );
|
||||||
|
|
||||||
// At this point the artifact handler will be inside the container and
|
// At this point the artifact handler will be inside the container and
|
||||||
// Maven internally will pick up the artifact handler and use it accordingly to
|
// Maven internally will pick up the artifact handler and use it accordingly to
|
||||||
// create the classpath appropriately.
|
// create the classpath appropriately.
|
||||||
|
|
||||||
MavenExecutionResult result = embedder.readProjectWithDependencies( request );
|
MavenExecutionResult result = embedder.readProjectWithDependencies( request );
|
||||||
|
|
||||||
|
System.out.println( "Got exceptions: " + result.getExceptions() );
|
||||||
|
|
||||||
assertNoExceptions( result );
|
assertNoExceptions( result );
|
||||||
|
|
||||||
// sources, test sources, and the junit jar..
|
// sources, test sources, and the junit jar..
|
||||||
|
|
|
@ -222,6 +222,8 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
superModel.setVersion( STANDALONE_SUPERPOM_VERSION );
|
superModel.setVersion( STANDALONE_SUPERPOM_VERSION );
|
||||||
|
|
||||||
|
superModel = ModelUtils.cloneModel( superModel );
|
||||||
|
|
||||||
List activeProfiles;
|
List activeProfiles;
|
||||||
if ( profileManager != null )
|
if ( profileManager != null )
|
||||||
{
|
{
|
||||||
|
@ -239,12 +241,15 @@ public class DefaultMavenProjectBuilder
|
||||||
project.setManagedVersionMap(
|
project.setManagedVersionMap(
|
||||||
createManagedVersionMap( projectId, superModel.getDependencyManagement(), null ) );
|
createManagedVersionMap( projectId, superModel.getDependencyManagement(), null ) );
|
||||||
|
|
||||||
|
getLogger().debug( "Activated the following profiles for standalone super-pom: " + activeProfiles );
|
||||||
project.setActiveProfiles( activeProfiles );
|
project.setActiveProfiles( activeProfiles );
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
project.setRemoteArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
|
processProjectLogic( project, null, true );
|
||||||
|
|
||||||
|
project.setRemoteArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
|
||||||
project.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
|
project.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
|
||||||
}
|
}
|
||||||
catch ( InvalidRepositoryException e )
|
catch ( InvalidRepositoryException e )
|
||||||
|
@ -256,6 +261,15 @@ public class DefaultMavenProjectBuilder
|
||||||
"Maven super-POM contains an invalid repository!",
|
"Maven super-POM contains an invalid repository!",
|
||||||
e );
|
e );
|
||||||
}
|
}
|
||||||
|
catch ( ModelInterpolationException e )
|
||||||
|
{
|
||||||
|
// we shouldn't be swallowing exceptions, no matter how unlikely.
|
||||||
|
// or, if we do, we should pay attention to the one coming from getSuperModel()...
|
||||||
|
throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":"
|
||||||
|
+ STANDALONE_SUPERPOM_ARTIFACTID,
|
||||||
|
"Maven super-POM contains an invalid expressions!",
|
||||||
|
e );
|
||||||
|
}
|
||||||
|
|
||||||
project.setOriginalModel( superModel );
|
project.setOriginalModel( superModel );
|
||||||
|
|
||||||
|
|
|
@ -1318,7 +1318,7 @@ public class MavenProject
|
||||||
*/
|
*/
|
||||||
public List getPluginArtifactRepositories()
|
public List getPluginArtifactRepositories()
|
||||||
{
|
{
|
||||||
return pluginArtifactRepositories;
|
return getRemoteArtifactRepositories();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository getDistributionManagementArtifactRepository()
|
public ArtifactRepository getDistributionManagementArtifactRepository()
|
||||||
|
@ -1330,7 +1330,7 @@ public class MavenProject
|
||||||
public List getPluginRepositories()
|
public List getPluginRepositories()
|
||||||
{
|
{
|
||||||
// return model.getPluginRepositories();
|
// return model.getPluginRepositories();
|
||||||
return Collections.EMPTY_LIST;
|
return model.getRepositories();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveProfiles( List activeProfiles )
|
public void setActiveProfiles( List activeProfiles )
|
||||||
|
|
|
@ -272,6 +272,14 @@ public class ProjectBuildingException
|
||||||
pomFile = new File ( pomLocation );
|
pomFile = new File ( pomLocation );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProjectBuildingException( String projectId,
|
||||||
|
String message,
|
||||||
|
ModelInterpolationException cause )
|
||||||
|
{
|
||||||
|
super( message, cause );
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
|
|
||||||
public File getPomFile()
|
public File getPomFile()
|
||||||
{
|
{
|
||||||
return pomFile;
|
return pomFile;
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class DefaultMavenProjectBuilderTest
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
projectBuilder = (DefaultMavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
projectBuilder = (DefaultMavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||||
|
|
||||||
localRepoDir = new File( System.getProperty( "java.io.tmpdir" ), "local-repo." + System.currentTimeMillis() );
|
localRepoDir = new File( System.getProperty( "java.io.tmpdir" ), "local-repo." + System.currentTimeMillis() );
|
||||||
localRepoDir.mkdirs();
|
localRepoDir.mkdirs();
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class DefaultMavenProjectBuilderTest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that we can build ok from the middle pom of a (parent,child,grandchild) heirarchy
|
* Check that we can build ok from the middle pom of a (parent,child,grandchild) heirarchy
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testBuildFromMiddlePom() throws Exception
|
public void testBuildFromMiddlePom() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -88,12 +88,12 @@ public class DefaultMavenProjectBuilderTest
|
||||||
File f2 = getTestFile( "src/test/resources/projects/grandchild-check/child/grandchild/pom.xml");
|
File f2 = getTestFile( "src/test/resources/projects/grandchild-check/child/grandchild/pom.xml");
|
||||||
|
|
||||||
getProject( f1 );
|
getProject( f1 );
|
||||||
|
|
||||||
// it's the building of the grandchild project, having already cached the child project
|
// it's the building of the grandchild project, having already cached the child project
|
||||||
// (but not the parent project), which causes the problem.
|
// (but not the parent project), which causes the problem.
|
||||||
getProject( f2 );
|
getProject( f2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository getLocalRepository()
|
protected ArtifactRepository getLocalRepository()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
package org.apache.maven.project;
|
package org.apache.maven.project;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.model.Profile;
|
||||||
|
import org.apache.maven.model.Repository;
|
||||||
|
import org.apache.maven.profiles.DefaultProfileManager;
|
||||||
|
import org.apache.maven.profiles.ProfileManager;
|
||||||
|
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
@ -19,7 +30,6 @@ package org.apache.maven.project;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class SuperPomProjectBuilderTest
|
public class SuperPomProjectBuilderTest
|
||||||
extends AbstractMavenProjectTestCase
|
extends AbstractMavenProjectTestCase
|
||||||
{
|
{
|
||||||
|
@ -31,12 +41,82 @@ public class SuperPomProjectBuilderTest
|
||||||
projectBuilder = (DefaultMavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
projectBuilder = (DefaultMavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBuildFromMiddlePom() throws Exception
|
public void testStandaloneSuperPomContainsInjectedExternalProfileRepositories()
|
||||||
|
throws ProjectBuildingException
|
||||||
|
{
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.setId( "test-profile" );
|
||||||
|
|
||||||
|
Repository repo = new Repository();
|
||||||
|
repo.setId( "test" );
|
||||||
|
repo.setUrl( "http://www.nowhere.com" );
|
||||||
|
|
||||||
|
profile.addRepository( repo );
|
||||||
|
|
||||||
|
ProfileManager pm = new DefaultProfileManager( getContainer(), new DefaultProfileActivationContext( new Properties(), true ) );
|
||||||
|
|
||||||
|
pm.addProfile( profile );
|
||||||
|
pm.explicitlyActivate( profile.getId() );
|
||||||
|
|
||||||
|
MavenProject project = projectBuilder.buildStandaloneSuperProject( pm );
|
||||||
|
|
||||||
|
assertRepository( repo.getId(), project.getRepositories() );
|
||||||
|
assertRepository( repo.getId(), project.getPluginRepositories() );
|
||||||
|
assertArtifactRepository( repo.getId(), project.getRemoteArtifactRepositories() );
|
||||||
|
assertArtifactRepository( repo.getId(), project.getPluginArtifactRepositories() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStandaloneSuperPomContainsCentralRepo()
|
||||||
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
MavenProject project = projectBuilder.buildStandaloneSuperProject();
|
MavenProject project = projectBuilder.buildStandaloneSuperProject();
|
||||||
|
|
||||||
assertNotNull( project.getRemoteArtifactRepositories() );
|
assertRepository( "central", project.getRepositories() );
|
||||||
//
|
assertRepository( "central", project.getPluginRepositories() );
|
||||||
// assertNotNull( project.getPluginArtifactRepositories() );
|
assertArtifactRepository( "central", project.getRemoteArtifactRepositories() );
|
||||||
|
assertArtifactRepository( "central", project.getPluginArtifactRepositories() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertArtifactRepository( String id,
|
||||||
|
List repos )
|
||||||
|
{
|
||||||
|
assertNotNull( repos );
|
||||||
|
assertFalse( repos.isEmpty() );
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
for ( Iterator it = repos.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
ArtifactRepository repo = (ArtifactRepository) it.next();
|
||||||
|
|
||||||
|
found = id.equals( repo.getId() );
|
||||||
|
if ( found )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue( found );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRepository( String id,
|
||||||
|
List repos )
|
||||||
|
{
|
||||||
|
assertNotNull( repos );
|
||||||
|
assertFalse( repos.isEmpty() );
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
for ( Iterator it = repos.iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
Repository repo = (Repository) it.next();
|
||||||
|
|
||||||
|
found = id.equals( repo.getId() );
|
||||||
|
if ( found )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue( found );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue