mirror of https://github.com/apache/maven.git
Resolving: MNG-449, MNG-152, MNG-1090, MNG-1089, MNG-1122
o Removed -cpl and related command line switches for controlling use of LATEST metadata for resolving plugin versions o Made LATEST the only metadata used to resolve plugin versions, since this is also available when releases are performed o Added various error diagnostics for project build exceptions o Enhanced artifact not found error diagnostics o Removed maven-project and added maven-artifact to maven-surefire-plugin's pom o Removed the stanza that added pluginArtifacts to the test-booter's classpath...they are already covered by the classpathElements o Fixed ITs in connection to the removal of -cpl o Changed the plugin manager to detect whether a plugin's artifact file has changed since the plugin container was created...if so, reload it. o Took the projecthelp plugin out of the build until I can diagnose the problems with its build (probably tomorrow). git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@312827 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
190362e6d3
commit
f685d8605d
|
@ -1 +1 @@
|
|||
--no-plugin-registry --check-plugin-latest
|
||||
--no-plugin-registry
|
||||
|
|
|
@ -1 +1 @@
|
|||
--no-plugin-registry --check-plugin-latest --fail-never
|
||||
--no-plugin-registry --fail-never
|
||||
|
|
|
@ -1 +1 @@
|
|||
--check-plugin-latest --no-plugin-registry -DperformRelease=true
|
||||
--no-plugin-registry -DperformRelease=true
|
||||
|
|
|
@ -1 +1 @@
|
|||
--check-plugin-latest --no-plugin-registry
|
||||
--no-plugin-registry
|
||||
|
|
|
@ -1 +1 @@
|
|||
--check-plugin-latest --no-plugin-registry
|
||||
--no-plugin-registry
|
||||
|
|
|
@ -448,7 +448,7 @@ private List collectProjects( List files, ArtifactRepository localRepository, bo
|
|||
DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
|
||||
if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 )
|
||||
{
|
||||
throw new ProjectBuildingException( "Unable to build project '" + project.getFile() +
|
||||
throw new ProjectBuildingException( project.getId(), "Unable to build project '" + project.getFile() +
|
||||
"; it requires Maven version " + version.toString() );
|
||||
}
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ public MavenProject getProject( File pom, ArtifactRepository localRepository, Se
|
|||
if ( pom.length() == 0 )
|
||||
{
|
||||
throw new ProjectBuildingException(
|
||||
"The file " + pom.getAbsolutePath() + " you specified has zero length." );
|
||||
"unknown", "The file " + pom.getAbsolutePath() + " you specified has zero length." );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -350,15 +350,6 @@ else if ( commandLine.hasOption( CLIManager.SUPPRESS_PLUGIN_UPDATES ) )
|
|||
runtimeInfo.setPluginUpdateOverride( Boolean.FALSE );
|
||||
}
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.FORCE_PLUGIN_LATEST_CHECK ) )
|
||||
{
|
||||
runtimeInfo.setCheckLatestPluginVersion( Boolean.TRUE );
|
||||
}
|
||||
else if ( commandLine.hasOption( CLIManager.SUPPRESS_PLUGIN_LATEST_CHECK ) )
|
||||
{
|
||||
runtimeInfo.setCheckLatestPluginVersion( Boolean.FALSE );
|
||||
}
|
||||
|
||||
return runtimeInfo;
|
||||
}
|
||||
|
||||
|
@ -633,10 +624,6 @@ static class CLIManager
|
|||
|
||||
public static final String SUPPRESS_PLUGIN_REGISTRY = "npr";
|
||||
|
||||
public static final String FORCE_PLUGIN_LATEST_CHECK = "cpl";
|
||||
|
||||
public static final String SUPPRESS_PLUGIN_LATEST_CHECK = "npl";
|
||||
|
||||
public static final char CHECKSUM_FAILURE_POLICY = 'C';
|
||||
|
||||
public static final char CHECKSUM_WARNING_POLICY = 'c';
|
||||
|
@ -661,8 +648,6 @@ public CLIManager()
|
|||
SET_SYSTEM_PROPERTY ) );
|
||||
options.addOption(
|
||||
OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) );
|
||||
// options.addOption( OptionBuilder.withLongOpt( "mojoDescriptors" ).withDescription(
|
||||
// "Display available mojoDescriptors" ).create( LIST_GOALS ) );
|
||||
options.addOption(
|
||||
OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) );
|
||||
options.addOption(
|
||||
|
@ -692,10 +677,6 @@ public CLIManager()
|
|||
"Synonym for " + FORCE_PLUGIN_UPDATES ).create( FORCE_PLUGIN_UPDATES2 ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription(
|
||||
"Suppress upToDate check for any relevant registered plugins" ).create( SUPPRESS_PLUGIN_UPDATES ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "check-plugin-latest" ).withDescription(
|
||||
"Force checking of LATEST metadata for plugin versions" ).create( FORCE_PLUGIN_LATEST_CHECK ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "no-plugin-latest" ).withDescription(
|
||||
"Suppress checking of LATEST metadata for plugin versions" ).create( SUPPRESS_PLUGIN_LATEST_CHECK ) );
|
||||
|
||||
options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription(
|
||||
"Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( SUPPRESS_PLUGIN_REGISTRY ) );
|
||||
|
|
|
@ -106,6 +106,8 @@ public class DefaultLifecycleExecutor
|
|||
public MavenExecutionResponse execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
// TODO: This is dangerous, particularly when it's just a collection of loose-leaf projects being built
|
||||
// within the same reactor (using an inclusion pattern to gather them up)...
|
||||
MavenProject rootProject = rm.getTopLevelProject();
|
||||
|
||||
List goals = session.getGoals();
|
||||
|
|
|
@ -171,49 +171,71 @@ private PluginDescriptor verifyVersionedPlugin( Plugin plugin, MavenProject proj
|
|||
// FIXME: need to find out how a plugin gets marked as 'installed'
|
||||
// and no ChildContainer exists. The check for that below fixes
|
||||
// the 'Can't find plexus container for plugin: xxx' error.
|
||||
if ( !pluginCollector.isPluginInstalled( plugin ) || container.getChildContainer( plugin.getKey() ) == null )
|
||||
try
|
||||
{
|
||||
try
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() );
|
||||
|
||||
List remoteRepositories = new ArrayList();
|
||||
remoteRepositories.addAll( project.getPluginArtifactRepositories() );
|
||||
remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
|
||||
|
||||
checkRequiredMavenVersion( plugin, localRepository, remoteRepositories );
|
||||
|
||||
Artifact pluginArtifact = artifactFactory.createPluginArtifact( plugin.getGroupId(),
|
||||
plugin.getArtifactId(), versionRange );
|
||||
|
||||
pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
|
||||
|
||||
artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
|
||||
|
||||
if ( !pluginArtifact.isResolved() )
|
||||
{
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() );
|
||||
throw new PluginContainerException( plugin, "Cannot resolve artifact for plugin." );
|
||||
}
|
||||
|
||||
List remoteRepositories = new ArrayList();
|
||||
remoteRepositories.addAll( project.getPluginArtifactRepositories() );
|
||||
remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
|
||||
PlexusContainer pluginContainer = container.getChildContainer( plugin.getKey() );
|
||||
|
||||
checkRequiredMavenVersion( plugin, localRepository, remoteRepositories );
|
||||
File pluginFile = pluginArtifact.getFile();
|
||||
|
||||
Artifact pluginArtifact = artifactFactory.createPluginArtifact( plugin.getGroupId(),
|
||||
plugin.getArtifactId(), versionRange );
|
||||
if ( !pluginCollector.isPluginInstalled( plugin ) || pluginContainer == null )
|
||||
{
|
||||
addPlugin( plugin, pluginArtifact, project, localRepository );
|
||||
|
||||
project.addPlugin( plugin );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
else if ( pluginFile.lastModified() > pluginContainer.getCreationDate().getTime() )
|
||||
{
|
||||
String groupId = plugin.getGroupId();
|
||||
String artifactId = plugin.getArtifactId();
|
||||
String version = plugin.getVersion();
|
||||
getLogger().info( "Reloading plugin container for: " + plugin.getKey() + ". The plugin artifact has changed." );
|
||||
|
||||
if ( groupId == null || artifactId == null || version == null )
|
||||
{
|
||||
throw new PluginNotFoundException( e );
|
||||
}
|
||||
else if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
|
||||
version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) )
|
||||
{
|
||||
throw new PluginNotFoundException( e );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
pluginContainer.dispose();
|
||||
|
||||
addPlugin( plugin, pluginArtifact, project, localRepository );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
|
||||
project.addPlugin( plugin );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
String groupId = plugin.getGroupId();
|
||||
String artifactId = plugin.getArtifactId();
|
||||
String version = plugin.getVersion();
|
||||
|
||||
if ( groupId == null || artifactId == null || version == null )
|
||||
{
|
||||
throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(),
|
||||
"Invalid version specification", e );
|
||||
throw new PluginNotFoundException( e );
|
||||
}
|
||||
else if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
|
||||
version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) )
|
||||
{
|
||||
throw new PluginNotFoundException( e );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(),
|
||||
"Invalid version specification", e );
|
||||
}
|
||||
|
||||
return pluginCollector.getPluginDescriptor( plugin );
|
||||
|
@ -259,15 +281,6 @@ protected void addPlugin( Plugin plugin, Artifact pluginArtifact, MavenProject p
|
|||
ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, PluginManagerException, ArtifactNotFoundException
|
||||
{
|
||||
pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
|
||||
|
||||
artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
|
||||
|
||||
if ( !pluginArtifact.isResolved() )
|
||||
{
|
||||
throw new PluginContainerException( plugin, "Cannot resolve artifact for plugin." );
|
||||
}
|
||||
|
||||
PlexusContainer child;
|
||||
try
|
||||
{
|
||||
|
@ -380,7 +393,7 @@ public void executeMojo( MavenProject project, MojoExecution mojoExecution, Mave
|
|||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Error looking up plugin: ", e );
|
||||
throw new MojoExecutionException( "Error looking up mojo: " + goalName, e );
|
||||
}
|
||||
|
||||
// Event monitoring.
|
||||
|
@ -503,6 +516,7 @@ private PlexusContainer getPluginContainer( PluginDescriptor pluginDescriptor )
|
|||
{
|
||||
throw new PluginManagerException( "Cannot find PlexusContainer for plugin: " + pluginKey );
|
||||
}
|
||||
|
||||
return pluginContainer;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DefaultPluginVersionManager
|
||||
|
@ -65,7 +64,7 @@ public class DefaultPluginVersionManager
|
|||
|
||||
private ArtifactMetadataSource artifactMetadataSource;
|
||||
|
||||
// calculated.
|
||||
// TODO: [jc] Revisit to remove this piece of state. PLUGIN REGISTRY MAY BE UPDATED ON DISK OUT-OF-PROCESS!
|
||||
private PluginRegistry pluginRegistry;
|
||||
|
||||
private MavenProjectBuilder mavenProjectBuilder;
|
||||
|
@ -90,14 +89,6 @@ private String resolvePluginVersion( String groupId, String artifactId, MavenPro
|
|||
ArtifactRepository localRepository, boolean resolveAsReportPlugin )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
// before we do anything else, if this is a self-reference we need to short-circuit the resolution process.
|
||||
String projectKey = constructPluginKey( project.getGroupId(), project.getArtifactId() );
|
||||
|
||||
if ( projectKey.equals( constructPluginKey( groupId, artifactId ) ) )
|
||||
{
|
||||
return project.getVersion();
|
||||
}
|
||||
|
||||
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
||||
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
|
||||
|
||||
|
@ -130,8 +121,8 @@ private String resolvePluginVersion( String groupId, String artifactId, MavenPro
|
|||
if ( Boolean.TRUE.equals( pluginUpdateOverride ) ||
|
||||
( !Boolean.FALSE.equals( pluginUpdateOverride ) && shouldCheckForUpdates( groupId, artifactId ) ) )
|
||||
{
|
||||
updatedVersion = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(),
|
||||
localRepository, Artifact.RELEASE_VERSION );
|
||||
updatedVersion = resolveMetaVersion( groupId, artifactId, project,
|
||||
localRepository, Artifact.LATEST_VERSION );
|
||||
|
||||
if ( StringUtils.isNotEmpty( updatedVersion ) && !updatedVersion.equals( version ) )
|
||||
{
|
||||
|
@ -158,20 +149,12 @@ private String resolvePluginVersion( String groupId, String artifactId, MavenPro
|
|||
|
||||
boolean forcePersist = false;
|
||||
|
||||
// are we using the LATEST metadata to resolve plugin version?
|
||||
Boolean rtCheckLatest = settingsRTInfo.getCheckLatestPluginVersion();
|
||||
|
||||
boolean checkLatestMetadata = Boolean.TRUE.equals( rtCheckLatest ) || (
|
||||
!Boolean.FALSE.equals( rtCheckLatest ) &&
|
||||
Boolean.valueOf( getPluginRegistry( groupId, artifactId ).getCheckLatest() )
|
||||
.booleanValue() );
|
||||
|
||||
// third pass...if we're checking for latest install/deploy, retrieve the version for LATEST metadata and also
|
||||
// set that resolved version as the <useVersion/> in settings.xml.
|
||||
if ( StringUtils.isEmpty( version ) && checkLatestMetadata )
|
||||
// third pass...we're always checking for latest install/deploy, so retrieve the version for LATEST metadata and
|
||||
// also set that resolved version as the <useVersion/> in settings.xml.
|
||||
if ( StringUtils.isEmpty( version ) )
|
||||
{
|
||||
// 1. resolve the version to be used
|
||||
version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(), localRepository,
|
||||
version = resolveMetaVersion( groupId, artifactId, project, localRepository,
|
||||
Artifact.LATEST_VERSION );
|
||||
|
||||
if ( version != null )
|
||||
|
@ -185,24 +168,26 @@ private String resolvePluginVersion( String groupId, String artifactId, MavenPro
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this...it shouldn't be needed anymore.
|
||||
|
||||
// final pass...retrieve the version for RELEASE and also set that resolved version as the <useVersion/>
|
||||
// in settings.xml.
|
||||
if ( StringUtils.isEmpty( version ) )
|
||||
{
|
||||
// 1. resolve the version to be used
|
||||
version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(), localRepository,
|
||||
Artifact.RELEASE_VERSION );
|
||||
|
||||
if ( version != null )
|
||||
{
|
||||
// 2. Set the updatedVersion so the user will be prompted whether to make this version permanent.
|
||||
updatedVersion = version;
|
||||
|
||||
// 3. Persist this version without prompting.
|
||||
forcePersist = true;
|
||||
promptToPersist = false;
|
||||
}
|
||||
}
|
||||
// if ( StringUtils.isEmpty( version ) )
|
||||
// {
|
||||
// // 1. resolve the version to be used
|
||||
// version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(), localRepository,
|
||||
// Artifact.RELEASE_VERSION );
|
||||
//
|
||||
// if ( version != null )
|
||||
// {
|
||||
// // 2. Set the updatedVersion so the user will be prompted whether to make this version permanent.
|
||||
// updatedVersion = version;
|
||||
//
|
||||
// // 3. Persist this version without prompting.
|
||||
// forcePersist = true;
|
||||
// promptToPersist = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if we still haven't found a version, then fail early before we get into the update goop.
|
||||
if ( StringUtils.isEmpty( version ) )
|
||||
|
@ -633,66 +618,75 @@ private PluginRegistry getPluginRegistry( String groupId, String artifactId )
|
|||
return pluginRegistry;
|
||||
}
|
||||
|
||||
private String resolveMetaVersion( String groupId, String artifactId, List remoteRepositories,
|
||||
private String resolveMetaVersion( String groupId, String artifactId, MavenProject project,
|
||||
ArtifactRepository localRepository, String metaVersionId )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||
|
||||
project.replaceWithActiveArtifact( artifact );
|
||||
|
||||
String version = null;
|
||||
|
||||
try
|
||||
if ( artifact.isResolved() )
|
||||
{
|
||||
ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository,
|
||||
remoteRepositories );
|
||||
|
||||
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
|
||||
// artifact.
|
||||
artifact = resolutionGroup.getPomArtifact();
|
||||
|
||||
// make sure this artifact was actually resolved to a file in the repo...
|
||||
if ( artifact.getFile() != null )
|
||||
version = artifact.getVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
|
||||
localRepository, false );
|
||||
ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository,
|
||||
project.getPluginArtifactRepositories() );
|
||||
|
||||
boolean pluginValid = true;
|
||||
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
|
||||
// artifact.
|
||||
artifact = resolutionGroup.getPomArtifact();
|
||||
|
||||
// if we don't have the required Maven version, then ignore an update
|
||||
if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
|
||||
// make sure this artifact was actually resolved to a file in the repo...
|
||||
if ( artifact.getFile() != null )
|
||||
{
|
||||
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
|
||||
project.getPrerequisites().getMaven() );
|
||||
MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project
|
||||
.getPluginArtifactRepositories(), localRepository, false );
|
||||
|
||||
if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
|
||||
boolean pluginValid = true;
|
||||
|
||||
// if we don't have the required Maven version, then ignore an update
|
||||
if ( pluginProject.getPrerequisites() != null && pluginProject.getPrerequisites().getMaven() != null )
|
||||
{
|
||||
getLogger().info( "Ignoring available plugin update: " + artifact.getVersion() +
|
||||
" as it requires Maven version " + requiredVersion );
|
||||
pluginValid = false;
|
||||
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
|
||||
pluginProject.getPrerequisites().getMaven() );
|
||||
|
||||
if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
|
||||
{
|
||||
getLogger().info( "Ignoring available plugin update: " + artifact.getVersion() +
|
||||
" as it requires Maven version " + requiredVersion );
|
||||
pluginValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
String artifactVersion = artifact.getVersion();
|
||||
|
||||
if ( pluginValid && !metaVersionId.equals( artifactVersion ) )
|
||||
{
|
||||
version = artifactVersion;
|
||||
}
|
||||
}
|
||||
|
||||
String artifactVersion = artifact.getVersion();
|
||||
|
||||
if ( pluginValid && !metaVersionId.equals( artifactVersion ) )
|
||||
{
|
||||
version = artifactVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
getLogger().debug( "Failed to resolve " + metaVersionId + " version", e );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
||||
"Unable to build resolve plugin project information", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
||||
"Unable to determine Maven version for comparison", e );
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
getLogger().debug( "Failed to resolve " + metaVersionId + " version", e );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
||||
"Unable to build resolve plugin project information", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
||||
"Unable to determine Maven version for comparison", e );
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
|
|
|
@ -37,9 +37,12 @@ public String diagnose( Throwable error )
|
|||
|
||||
StringBuffer message = new StringBuffer();
|
||||
|
||||
message.append( "Failed to resolve artifact." );
|
||||
message.append( "Failed to resolve artifact.\n" );
|
||||
message.append( "\nGroupId: " ).append( exception.getGroupId() );
|
||||
message.append( "\nArtifactId: " ).append( exception.getArtifactId() );
|
||||
message.append( "\nVersion: " ).append( exception.getVersion() );
|
||||
message.append( "\n\n" );
|
||||
message.append( exception.getMessage() );
|
||||
message.append( "Reason: " ).append( exception.getMessage() );
|
||||
|
||||
if ( !wagonManager.isOnline() )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package org.apache.maven.usability;
|
||||
|
||||
import org.apache.maven.project.InvalidProjectModelException;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.validation.ModelValidationResult;
|
||||
|
||||
public class ProjectBuildDiagnoser
|
||||
implements ErrorDiagnoser
|
||||
{
|
||||
|
||||
public boolean canDiagnose( Throwable error )
|
||||
{
|
||||
return DiagnosisUtils.containsInCausality( error, ProjectBuildingException.class );
|
||||
}
|
||||
|
||||
public String diagnose( Throwable error )
|
||||
{
|
||||
ProjectBuildingException pbe = (ProjectBuildingException) DiagnosisUtils.getFromCausality( error, ProjectBuildingException.class );
|
||||
|
||||
StringBuffer message = new StringBuffer();
|
||||
|
||||
message.append( "Error building POM (may not be this project's POM)." ).append( "\n\n" );
|
||||
|
||||
message.append( "\nProject ID: " ).append( pbe.getProjectId() );
|
||||
|
||||
if ( pbe instanceof InvalidProjectModelException )
|
||||
{
|
||||
InvalidProjectModelException ipme = (InvalidProjectModelException) pbe;
|
||||
|
||||
message.append( "\nPOM Location: " ).append( ipme.getPomLocation() );
|
||||
|
||||
ModelValidationResult result = ipme.getValidationResult();
|
||||
|
||||
if ( result != null )
|
||||
{
|
||||
message.append( "\nValidation Messages:\n\n" ).append( ipme.getValidationResult().render( " " ) );
|
||||
}
|
||||
}
|
||||
|
||||
message.append( "\n\n" ).append( "Reason: " ).append( pbe.getMessage() );
|
||||
|
||||
Throwable t = DiagnosisUtils.getRootCause( error );
|
||||
|
||||
if ( t != null && t != pbe )
|
||||
{
|
||||
message.append( "\n" ).append( "Root Cause: " ).append( t.getMessage() );
|
||||
}
|
||||
|
||||
message.append( "\n\n" );
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -93,6 +93,16 @@
|
|||
</component>
|
||||
<!--
|
||||
|
|
||||
|ProjectBuildDiagnoser
|
||||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role-hint>ProjectBuildDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.ProjectBuildDiagnoser</implementation>
|
||||
</component>
|
||||
<!--
|
||||
|
|
||||
|ProfileActivationDiagnoser
|
||||
|
|
||||
-->
|
||||
|
@ -307,7 +317,8 @@
|
|||
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
|
||||
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
||||
<package>
|
||||
org.apache.maven.plugins:maven-jar-plugin:jar
|
||||
org.apache.maven.plugins:maven-jar-plugin:jar,
|
||||
org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata
|
||||
</package>
|
||||
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
||||
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
|
||||
|
|
|
@ -163,10 +163,25 @@ private boolean getRemoteArtifact( Dependency dep, File destinationFile )
|
|||
File file = localFile;
|
||||
if ( remoteFile.exists() )
|
||||
{
|
||||
if ( !localFile.exists() || localFile.lastModified() < remoteFile.lastModified() )
|
||||
if ( !localFile.exists() )
|
||||
{
|
||||
file = remoteFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
RepositoryMetadata localMetadata = RepositoryMetadata.read( localFile );
|
||||
|
||||
RepositoryMetadata remoteMetadata = RepositoryMetadata.read( remoteFile );
|
||||
|
||||
if ( remoteMetadata.getLastUpdatedUtc() > localMetadata.getLastUpdatedUtc() )
|
||||
{
|
||||
file = remoteFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
file = localFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( file.exists() )
|
||||
|
|
|
@ -26,9 +26,14 @@
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* I/O for repository metadata.
|
||||
|
@ -176,6 +181,21 @@ public String constructVersion( String baseVersion )
|
|||
return baseVersion;
|
||||
}
|
||||
|
||||
public long getLastUpdatedUtc()
|
||||
{
|
||||
TimeZone timezone = TimeZone.getTimeZone( "UTC" );
|
||||
DateFormat fmt = new SimpleDateFormat( "yyyyMMddHHmmss" );
|
||||
|
||||
try
|
||||
{
|
||||
return fmt.parse( lastUpdated ).getTime();
|
||||
}
|
||||
catch ( ParseException e )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLastUpdated( String lastUpdated )
|
||||
{
|
||||
this.lastUpdated = lastUpdated;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.apache.maven.plugins.projecthelp;
|
||||
|
||||
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.execution.MavenSession;
|
||||
import org.apache.maven.model.Plugin;
|
||||
|
@ -215,6 +216,11 @@ else if ( pi.groupId != null && pi.artifactId != null )
|
|||
throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId
|
||||
+ "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId
|
||||
+ "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
|
||||
}
|
||||
}
|
||||
|
||||
return descriptor;
|
||||
|
@ -326,6 +332,26 @@ private void describeMojoGuts( MojoDescriptor md, StringBuffer buffer )
|
|||
String eLife = md.getExecuteLifecycle();
|
||||
String ePhase = md.getExecutePhase();
|
||||
|
||||
if ( eGoal != null || ePhase != null )
|
||||
{
|
||||
buffer.append( "\n\nBefore this mojo executes, it will call:\n" );
|
||||
|
||||
if ( eGoal != null )
|
||||
{
|
||||
buffer.append( "\nSingle mojo: \'" ).append( eGoal ).append( "\'" );
|
||||
}
|
||||
|
||||
if ( ePhase != null )
|
||||
{
|
||||
buffer.append( "\nPhase: \'" ).append( ePhase ).append( "\'" );
|
||||
|
||||
if ( eLife != null )
|
||||
{
|
||||
buffer.append( " in Lifecycle Overlay: \'" ).append( eLife ).append( "\'" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List parameters = md.getParameters();
|
||||
|
||||
List requirements = md.getRequirements();
|
||||
|
|
|
@ -22,10 +22,6 @@
|
|||
<version>3.8.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>surefire</groupId>
|
||||
<artifactId>surefire</artifactId>
|
||||
|
@ -55,5 +51,10 @@
|
|||
<version>1.0.4-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>2.0-beta-4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -268,14 +268,14 @@ public void execute()
|
|||
surefireBooter.addClassPathUrl( classpathElement );
|
||||
}
|
||||
|
||||
for ( Iterator i = pluginArtifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
|
||||
getLog().debug( artifact.getFile().getAbsolutePath() );
|
||||
|
||||
surefireBooter.addClassPathUrl( artifact.getFile().getAbsolutePath() );
|
||||
}
|
||||
// for ( Iterator i = pluginArtifacts.iterator(); i.hasNext(); )
|
||||
// {
|
||||
// Artifact artifact = (Artifact) i.next();
|
||||
//
|
||||
// getLog().debug( artifact.getFile().getAbsolutePath() );
|
||||
//
|
||||
// surefireBooter.addClassPathUrl( artifact.getFile().getAbsolutePath() );
|
||||
// }
|
||||
|
||||
addReporters(surefireBooter);
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
<module>maven-javadoc-plugin</module>
|
||||
<module>maven-plugin-plugin</module>
|
||||
<module>maven-pmd-plugin</module>
|
||||
<module>maven-projecthelp-plugin</module>
|
||||
<!-- module>maven-projecthelp-plugin</module -->
|
||||
<module>maven-project-info-reports-plugin</module>
|
||||
<module>maven-rar-plugin</module>
|
||||
<module>maven-release-plugin</module>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactStatus;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
|
@ -183,7 +184,7 @@ public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepos
|
|||
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||
Artifact projectArtifact = project.getArtifact();
|
||||
|
||||
Map managedVersions = createManagedVersionMap( project.getDependencyManagement() );
|
||||
Map managedVersions = createManagedVersionMap( project.getId(), project.getDependencyManagement() );
|
||||
|
||||
ensureMetadataSourceIsInitialized();
|
||||
|
||||
|
@ -193,7 +194,7 @@ public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepos
|
|||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Error in dependency version", e );
|
||||
throw new ProjectBuildingException( project.getId(), "Error in dependency version", e );
|
||||
}
|
||||
|
||||
if ( transferListener != null )
|
||||
|
@ -223,12 +224,12 @@ private void ensureMetadataSourceIsInitialized()
|
|||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Cannot lookup metadata source for building the project.", e );
|
||||
throw new ProjectBuildingException( "all", "Cannot lookup metadata source for building the project.", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map createManagedVersionMap( DependencyManagement dependencyManagement )
|
||||
private Map createManagedVersionMap( String projectId, DependencyManagement dependencyManagement )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Map map;
|
||||
|
@ -249,7 +250,7 @@ private Map createManagedVersionMap( DependencyManagement dependencyManagement )
|
|||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Unable to parse dependency version", e );
|
||||
throw new ProjectBuildingException( projectId, "Unable to parse dependency version", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +272,7 @@ private MavenProject buildFromSourceFile( File projectDescriptor, ArtifactReposi
|
|||
ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Model model = readModel( projectDescriptor );
|
||||
Model model = readModel( "unknown", projectDescriptor );
|
||||
|
||||
// Always cache files in the source tree over those in the repository
|
||||
MavenProject p = new MavenProject( model );
|
||||
|
@ -284,7 +285,7 @@ private MavenProject buildFromSourceFile( File projectDescriptor, ArtifactReposi
|
|||
|
||||
if ( project.getDistributionManagement() != null && project.getDistributionManagement().getStatus() != null )
|
||||
{
|
||||
throw new ProjectBuildingException(
|
||||
throw new ProjectBuildingException( project.getId(),
|
||||
"Invalid project file: distribution status must not be specified for a project outside of the repository" );
|
||||
}
|
||||
|
||||
|
@ -350,6 +351,8 @@ private Model findModelFromRepository( Artifact artifact, List remoteArtifactRep
|
|||
Model model;
|
||||
if ( project == null )
|
||||
{
|
||||
String projectId = ArtifactUtils.versionlessKey( projectArtifact );
|
||||
|
||||
try
|
||||
{
|
||||
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
|
||||
|
@ -358,7 +361,7 @@ private Model findModelFromRepository( Artifact artifact, List remoteArtifactRep
|
|||
// TODO: how can this not be true?
|
||||
if ( projectArtifact.isResolved() )
|
||||
{
|
||||
model = readModel( file );
|
||||
model = readModel( projectId, file );
|
||||
|
||||
String downloadUrl = null;
|
||||
ArtifactStatus status = ArtifactStatus.NONE;
|
||||
|
@ -421,12 +424,12 @@ else if ( allowStubModel )
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ProjectBuildingException( "POM could not be resolved from the repository" );
|
||||
throw new ProjectBuildingException( projectId, "POM could not be resolved from the repository" );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Error getting the POM in the repository", e );
|
||||
throw new ProjectBuildingException( projectId, "Error getting the POM in the repository", e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
|
@ -436,7 +439,7 @@ else if ( allowStubModel )
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ProjectBuildingException( "POM not found in repository", e );
|
||||
throw new ProjectBuildingException( projectId, "POM not found in repository", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -514,6 +517,8 @@ private MavenProject build( String pomLocation, Model model, ArtifactRepository
|
|||
// Use a TreeSet to ensure ordering is retained
|
||||
Set aggregatedRemoteWagonRepositories = new LinkedHashSet();
|
||||
|
||||
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||
|
||||
List activeExternalProfiles;
|
||||
try
|
||||
{
|
||||
|
@ -528,7 +533,7 @@ private MavenProject build( String pomLocation, Model model, ArtifactRepository
|
|||
}
|
||||
catch ( ProfileActivationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Failed to calculate active external profiles.", e );
|
||||
throw new ProjectBuildingException( projectId, "Failed to calculate active external profiles.", e );
|
||||
}
|
||||
|
||||
for ( Iterator i = activeExternalProfiles.iterator(); i.hasNext(); )
|
||||
|
@ -586,7 +591,7 @@ private MavenProject build( String pomLocation, Model model, ArtifactRepository
|
|||
}
|
||||
catch ( ModelInterpolationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Error building project from \'" + pomLocation + "\': " + model.getId(),
|
||||
throw new ProjectBuildingException( project.getId(), "Error building project from \'" + pomLocation + "\': " + model.getId(),
|
||||
e );
|
||||
}
|
||||
projectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ),
|
||||
|
@ -594,6 +599,25 @@ private MavenProject build( String pomLocation, Model model, ArtifactRepository
|
|||
return project;
|
||||
}
|
||||
|
||||
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 List buildArtifactRepositories( Model model )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
@ -698,17 +722,16 @@ private MavenProject processProjectLogic( String pomLocation, MavenProject proje
|
|||
|
||||
if ( validationResult.getMessageCount() > 0 )
|
||||
{
|
||||
throw new ProjectBuildingException( "Failed to validate POM for \'" + pomLocation +
|
||||
"\'.\n\n Reason(s):\n" + validationResult.render( " " ) );
|
||||
throw new InvalidProjectModelException( project.getId(), pomLocation, "Failed to validate POM", validationResult );
|
||||
}
|
||||
|
||||
project.setRemoteArtifactRepositories(
|
||||
ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) );
|
||||
|
||||
// TODO: these aren't taking active project artifacts into consideration in the reactor
|
||||
project.setPluginArtifacts( createPluginArtifacts( project.getBuildPlugins() ) );
|
||||
project.setReportArtifacts( createReportArtifacts( project.getReportPlugins() ) );
|
||||
project.setExtensionArtifacts( createExtensionArtifacts( project.getBuildExtensions() ) );
|
||||
project.setPluginArtifacts( createPluginArtifacts( project.getId(), project.getBuildPlugins() ) );
|
||||
project.setReportArtifacts( createReportArtifacts( project.getId(), project.getReportPlugins() ) );
|
||||
project.setExtensionArtifacts( createExtensionArtifacts( project.getId(), project.getBuildExtensions() ) );
|
||||
|
||||
return project;
|
||||
}
|
||||
|
@ -756,7 +779,9 @@ private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactR
|
|||
}
|
||||
catch ( ProfileActivationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Failed to activate local (project-level) build profiles.", e );
|
||||
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||
|
||||
throw new ProjectBuildingException( projectId, "Failed to activate local (project-level) build profiles.", e );
|
||||
}
|
||||
|
||||
MavenProject project = new MavenProject( model );
|
||||
|
@ -769,17 +794,19 @@ private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactR
|
|||
|
||||
if ( parentModel != null )
|
||||
{
|
||||
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||
|
||||
if ( StringUtils.isEmpty( parentModel.getGroupId() ) )
|
||||
{
|
||||
throw new ProjectBuildingException( "Missing groupId element from parent element" );
|
||||
throw new ProjectBuildingException( projectId, "Missing groupId element from parent element" );
|
||||
}
|
||||
else if ( StringUtils.isEmpty( parentModel.getArtifactId() ) )
|
||||
{
|
||||
throw new ProjectBuildingException( "Missing artifactId element from parent element" );
|
||||
throw new ProjectBuildingException( projectId, "Missing artifactId element from parent element" );
|
||||
}
|
||||
else if ( StringUtils.isEmpty( parentModel.getVersion() ) )
|
||||
{
|
||||
throw new ProjectBuildingException( "Missing version element from parent element" );
|
||||
throw new ProjectBuildingException( projectId, "Missing version element from parent element" );
|
||||
}
|
||||
|
||||
// the only way this will have a value is if we find the parent on disk...
|
||||
|
@ -818,7 +845,7 @@ else if ( StringUtils.isEmpty( parentModel.getVersion() ) )
|
|||
|
||||
if ( parentDescriptor != null && parentDescriptor.exists() )
|
||||
{
|
||||
Model candidateParent = readModel( parentDescriptor );
|
||||
Model candidateParent = readModel( projectId, parentDescriptor );
|
||||
|
||||
String candidateParentGroupId = candidateParent.getGroupId();
|
||||
if ( candidateParentGroupId == null && candidateParent.getParent() != null )
|
||||
|
@ -908,7 +935,9 @@ private List injectActiveProfiles( ProfileManager profileManager, Model model )
|
|||
}
|
||||
catch ( ProfileActivationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Failed to calculate active build profiles.", e );
|
||||
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
|
||||
|
||||
throw new ProjectBuildingException( projectId, "Failed to calculate active build profiles.", e );
|
||||
}
|
||||
|
||||
for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
|
||||
|
@ -967,27 +996,27 @@ private void loadProjectExternalProfiles( ProfileManager profileManager, File pr
|
|||
}
|
||||
}
|
||||
|
||||
private Model readModel( File file )
|
||||
private Model readModel( String projectId, File file )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Reader reader = null;
|
||||
try
|
||||
{
|
||||
reader = new FileReader( file );
|
||||
return readModel( reader );
|
||||
return readModel( projectId, file.getAbsolutePath(), reader );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Could not find the model file '" + file.getAbsolutePath() + "'.", e );
|
||||
throw new ProjectBuildingException( projectId, "Could not find the model file '" + file.getAbsolutePath() + "'.", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Failed to build model from file '" + file.getAbsolutePath() +
|
||||
throw new ProjectBuildingException( projectId, "Failed to build model from file '" + file.getAbsolutePath() +
|
||||
"'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Failed to parse model from file '" + file.getAbsolutePath() +
|
||||
throw new ProjectBuildingException( projectId, "Failed to parse model from file '" + file.getAbsolutePath() +
|
||||
"'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||
}
|
||||
finally
|
||||
|
@ -996,8 +1025,8 @@ private Model readModel( File file )
|
|||
}
|
||||
}
|
||||
|
||||
private Model readModel( Reader reader )
|
||||
throws IOException, XmlPullParserException, InvalidModelException
|
||||
private Model readModel( String projectId, String pomLocation, Reader reader )
|
||||
throws IOException, XmlPullParserException, InvalidProjectModelException
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
|
@ -1007,7 +1036,7 @@ private Model readModel( Reader reader )
|
|||
|
||||
if ( modelSource.indexOf( "<modelVersion>4.0.0" ) < 0 )
|
||||
{
|
||||
throw new InvalidModelException( "Invalid POM (not v4.0.0 modelVersion)" );
|
||||
throw new InvalidProjectModelException( projectId, pomLocation, "Invalid POM (not v4.0.0 modelVersion)" );
|
||||
}
|
||||
|
||||
StringReader sReader = new StringReader( modelSource );
|
||||
|
@ -1015,23 +1044,23 @@ private Model readModel( Reader reader )
|
|||
return modelReader.read( sReader );
|
||||
}
|
||||
|
||||
private Model readModel( URL url )
|
||||
private Model readModel( String projectId, URL url )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
InputStreamReader reader = null;
|
||||
try
|
||||
{
|
||||
reader = new InputStreamReader( url.openStream() );
|
||||
return readModel( reader );
|
||||
return readModel( projectId, url.toExternalForm(), reader );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Failed build model from URL \'" + url.toExternalForm() +
|
||||
throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() +
|
||||
"\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Failed to parse model from URL \'" + url.toExternalForm() +
|
||||
throw new ProjectBuildingException( projectId, "Failed to parse model from URL \'" + url.toExternalForm() +
|
||||
"\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||
}
|
||||
finally
|
||||
|
@ -1050,7 +1079,7 @@ private static String createCacheKey( String groupId, String artifactId, String
|
|||
return groupId + ":" + artifactId + ":" + version;
|
||||
}
|
||||
|
||||
protected Set createPluginArtifacts( List plugins )
|
||||
protected Set createPluginArtifacts( String projectId, List plugins )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Set pluginArtifacts = new HashSet();
|
||||
|
@ -1077,7 +1106,7 @@ protected Set createPluginArtifacts( List plugins )
|
|||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Unable to parse plugin version", e );
|
||||
throw new ProjectBuildingException( projectId, "Unable to parse plugin version", e );
|
||||
}
|
||||
|
||||
if ( artifact != null )
|
||||
|
@ -1090,7 +1119,7 @@ protected Set createPluginArtifacts( List plugins )
|
|||
}
|
||||
|
||||
// TODO: share with createPluginArtifacts?
|
||||
protected Set createReportArtifacts( List reports )
|
||||
protected Set createReportArtifacts( String projectId, List reports )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Set pluginArtifacts = new HashSet();
|
||||
|
@ -1119,7 +1148,7 @@ protected Set createReportArtifacts( List reports )
|
|||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Unable to parse plugin version", e );
|
||||
throw new ProjectBuildingException( projectId, "Unable to parse plugin version", e );
|
||||
}
|
||||
|
||||
if ( artifact != null )
|
||||
|
@ -1133,7 +1162,7 @@ protected Set createReportArtifacts( List reports )
|
|||
}
|
||||
|
||||
// TODO: share with createPluginArtifacts?
|
||||
protected Set createExtensionArtifacts( List extensions )
|
||||
protected Set createExtensionArtifacts( String projectId, List extensions )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Set extensionArtifacts = new HashSet();
|
||||
|
@ -1162,7 +1191,7 @@ protected Set createExtensionArtifacts( List extensions )
|
|||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Unable to parse extension version", e );
|
||||
throw new ProjectBuildingException( projectId, "Unable to parse extension version", e );
|
||||
}
|
||||
|
||||
if ( artifact != null )
|
||||
|
@ -1215,7 +1244,9 @@ public MavenProject buildStandaloneSuperProject( ArtifactRepository localReposit
|
|||
}
|
||||
catch ( ModelInterpolationException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Error building super-project", e );
|
||||
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
|
||||
|
||||
throw new ProjectBuildingException( projectId, "Error building super-project", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1228,7 +1259,9 @@ private Model getSuperModel()
|
|||
{
|
||||
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" );
|
||||
|
||||
return readModel( url );
|
||||
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
|
||||
|
||||
return readModel( projectId, url );
|
||||
}
|
||||
|
||||
public void contextualize( Context context )
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
public class InvalidModelException
|
||||
extends ProjectBuildingException
|
||||
{
|
||||
|
||||
public InvalidModelException( String message, Throwable cause )
|
||||
{
|
||||
super( message, cause );
|
||||
}
|
||||
|
||||
public InvalidModelException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
import org.apache.maven.project.validation.ModelValidationResult;
|
||||
|
||||
public class InvalidProjectModelException
|
||||
extends ProjectBuildingException
|
||||
{
|
||||
|
||||
private final String pomLocation;
|
||||
private ModelValidationResult validationResult;
|
||||
|
||||
public InvalidProjectModelException( String projectId, String pomLocation, String message, ModelValidationResult validationResult )
|
||||
{
|
||||
super( projectId, message );
|
||||
|
||||
this.pomLocation = pomLocation;
|
||||
this.validationResult = validationResult;
|
||||
}
|
||||
|
||||
public InvalidProjectModelException( String projectId, String pomLocation, String message )
|
||||
{
|
||||
super( projectId, message );
|
||||
|
||||
this.pomLocation = pomLocation;
|
||||
}
|
||||
|
||||
public final String getPomLocation()
|
||||
{
|
||||
return pomLocation;
|
||||
}
|
||||
|
||||
public final ModelValidationResult getValidationResult()
|
||||
{
|
||||
return validationResult;
|
||||
}
|
||||
|
||||
}
|
|
@ -23,18 +23,22 @@
|
|||
public class ProjectBuildingException
|
||||
extends Exception
|
||||
{
|
||||
public ProjectBuildingException( String message )
|
||||
private final String projectId;
|
||||
|
||||
public ProjectBuildingException( String projectId, String message )
|
||||
{
|
||||
super( message );
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public ProjectBuildingException( Throwable cause )
|
||||
{
|
||||
super( cause );
|
||||
}
|
||||
|
||||
public ProjectBuildingException( String message, Throwable cause )
|
||||
public ProjectBuildingException( String projectId, String message, Throwable cause )
|
||||
{
|
||||
super( message, cause );
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public String getProjectId()
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ private static ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mave
|
|||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Cannot find layout implementation corresponding to: \'" + layout +
|
||||
throw new ProjectBuildingException( "all", "Cannot find layout implementation corresponding to: \'" + layout +
|
||||
"\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
|
||||
}
|
||||
return repositoryLayout;
|
||||
|
|
|
@ -104,8 +104,6 @@ public boolean hasClassifier()
|
|||
public void setFile( File destination )
|
||||
{
|
||||
artifact.setFile( destination );
|
||||
|
||||
// TODO: [jc; 29-jul-05] Is this appropriate? I mean, isn't the point to use the project-file instead??
|
||||
project.getArtifact().setFile( destination );
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.Relocation;
|
||||
import org.apache.maven.project.InvalidModelException;
|
||||
import org.apache.maven.project.InvalidProjectModelException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
|
@ -107,10 +107,10 @@ public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepo
|
|||
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository,
|
||||
true );
|
||||
}
|
||||
catch ( InvalidModelException e )
|
||||
catch ( InvalidProjectModelException e )
|
||||
{
|
||||
getLogger().warn( "POM for: \'" + pomArtifact +
|
||||
"\' does not appear to be valid. Its will be ignored for artifact resolution." );
|
||||
"\' does not appear to be valid. Its will be ignored for artifact resolution.\n\nReason: " + e.getMessage() + "\n\n" );
|
||||
|
||||
project = null;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class RuntimeInfo
|
|||
private boolean pluginRegistryActive = true;
|
||||
|
||||
// using Boolean for 3VL (null for not-set, otherwise override with value)
|
||||
private Boolean checkLatest;
|
||||
// private Boolean checkLatest;
|
||||
|
||||
private Map activeProfileToSourceLevel = new HashMap();
|
||||
|
||||
|
@ -127,14 +127,4 @@ public String getLocalRepositorySourceLevel()
|
|||
return localRepositorySourceLevel;
|
||||
}
|
||||
|
||||
public void setCheckLatestPluginVersion( Boolean checkLatest )
|
||||
{
|
||||
this.checkLatest = checkLatest;
|
||||
}
|
||||
|
||||
public Boolean getCheckLatestPluginVersion()
|
||||
{
|
||||
return checkLatest;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue