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:
John Dennis Casey 2005-10-11 07:35:33 +00:00
parent 190362e6d3
commit f685d8605d
27 changed files with 423 additions and 257 deletions

View File

@ -1 +1 @@
--no-plugin-registry --check-plugin-latest --no-plugin-registry

View File

@ -1 +1 @@
--no-plugin-registry --check-plugin-latest --fail-never --no-plugin-registry --fail-never

View File

@ -1 +1 @@
--check-plugin-latest --no-plugin-registry -DperformRelease=true --no-plugin-registry -DperformRelease=true

View File

@ -1 +1 @@
--check-plugin-latest --no-plugin-registry --no-plugin-registry

View File

@ -1 +1 @@
--check-plugin-latest --no-plugin-registry --no-plugin-registry

View File

@ -448,7 +448,7 @@ public class DefaultMaven
DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() ); DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 ) 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() ); "; it requires Maven version " + version.toString() );
} }
} }
@ -500,7 +500,7 @@ public class DefaultMaven
if ( pom.length() == 0 ) if ( pom.length() == 0 )
{ {
throw new ProjectBuildingException( throw new ProjectBuildingException(
"The file " + pom.getAbsolutePath() + " you specified has zero length." ); "unknown", "The file " + pom.getAbsolutePath() + " you specified has zero length." );
} }
} }

View File

@ -350,15 +350,6 @@ public class MavenCli
runtimeInfo.setPluginUpdateOverride( Boolean.FALSE ); 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; return runtimeInfo;
} }
@ -633,10 +624,6 @@ public class MavenCli
public static final String SUPPRESS_PLUGIN_REGISTRY = "npr"; 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_FAILURE_POLICY = 'C';
public static final char CHECKSUM_WARNING_POLICY = 'c'; public static final char CHECKSUM_WARNING_POLICY = 'c';
@ -661,8 +648,6 @@ public class MavenCli
SET_SYSTEM_PROPERTY ) ); SET_SYSTEM_PROPERTY ) );
options.addOption( options.addOption(
OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) ); OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) );
// options.addOption( OptionBuilder.withLongOpt( "mojoDescriptors" ).withDescription(
// "Display available mojoDescriptors" ).create( LIST_GOALS ) );
options.addOption( options.addOption(
OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) ); OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) );
options.addOption( options.addOption(
@ -692,10 +677,6 @@ public class MavenCli
"Synonym for " + FORCE_PLUGIN_UPDATES ).create( FORCE_PLUGIN_UPDATES2 ) ); "Synonym for " + FORCE_PLUGIN_UPDATES ).create( FORCE_PLUGIN_UPDATES2 ) );
options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription( options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription(
"Suppress upToDate check for any relevant registered plugins" ).create( SUPPRESS_PLUGIN_UPDATES ) ); "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( options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription(
"Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( SUPPRESS_PLUGIN_REGISTRY ) ); "Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( SUPPRESS_PLUGIN_REGISTRY ) );

View File

@ -106,6 +106,8 @@ public class DefaultLifecycleExecutor
public MavenExecutionResponse execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher ) public MavenExecutionResponse execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher )
throws LifecycleExecutionException 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(); MavenProject rootProject = rm.getTopLevelProject();
List goals = session.getGoals(); List goals = session.getGoals();

View File

@ -171,49 +171,71 @@ public class DefaultPluginManager
// FIXME: need to find out how a plugin gets marked as 'installed' // FIXME: need to find out how a plugin gets marked as 'installed'
// and no ChildContainer exists. The check for that below fixes // and no ChildContainer exists. The check for that below fixes
// the 'Can't find plexus container for plugin: xxx' error. // 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(); PlexusContainer pluginContainer = container.getChildContainer( plugin.getKey() );
remoteRepositories.addAll( project.getPluginArtifactRepositories() );
remoteRepositories.addAll( project.getRemoteArtifactRepositories() );
checkRequiredMavenVersion( plugin, localRepository, remoteRepositories ); File pluginFile = pluginArtifact.getFile();
Artifact pluginArtifact = artifactFactory.createPluginArtifact( plugin.getGroupId(), if ( !pluginCollector.isPluginInstalled( plugin ) || pluginContainer == null )
plugin.getArtifactId(), versionRange ); {
addPlugin( plugin, pluginArtifact, project, localRepository ); addPlugin( plugin, pluginArtifact, project, localRepository );
project.addPlugin( plugin );
} }
catch ( ArtifactNotFoundException e ) else if ( pluginFile.lastModified() > pluginContainer.getCreationDate().getTime() )
{ {
String groupId = plugin.getGroupId(); getLogger().info( "Reloading plugin container for: " + plugin.getKey() + ". The plugin artifact has changed." );
String artifactId = plugin.getArtifactId();
String version = plugin.getVersion();
if ( groupId == null || artifactId == null || version == null ) pluginContainer.dispose();
{
throw new PluginNotFoundException( e ); addPlugin( plugin, pluginArtifact, project, localRepository );
}
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 )
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(), throw new PluginNotFoundException( e );
"Invalid version specification", 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 ); return pluginCollector.getPluginDescriptor( plugin );
@ -259,15 +281,6 @@ public class DefaultPluginManager
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws ArtifactResolutionException, PluginManagerException, ArtifactNotFoundException 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; PlexusContainer child;
try try
{ {
@ -380,7 +393,7 @@ public class DefaultPluginManager
} }
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
{ {
throw new MojoExecutionException( "Error looking up plugin: ", e ); throw new MojoExecutionException( "Error looking up mojo: " + goalName, e );
} }
// Event monitoring. // Event monitoring.
@ -503,6 +516,7 @@ public class DefaultPluginManager
{ {
throw new PluginManagerException( "Cannot find PlexusContainer for plugin: " + pluginKey ); throw new PluginManagerException( "Cannot find PlexusContainer for plugin: " + pluginKey );
} }
return pluginContainer; return pluginContainer;
} }

View File

@ -50,7 +50,6 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
public class DefaultPluginVersionManager public class DefaultPluginVersionManager
@ -65,7 +64,7 @@ public class DefaultPluginVersionManager
private ArtifactMetadataSource artifactMetadataSource; 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 PluginRegistry pluginRegistry;
private MavenProjectBuilder mavenProjectBuilder; private MavenProjectBuilder mavenProjectBuilder;
@ -90,14 +89,6 @@ public class DefaultPluginVersionManager
ArtifactRepository localRepository, boolean resolveAsReportPlugin ) ArtifactRepository localRepository, boolean resolveAsReportPlugin )
throws PluginVersionResolutionException 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. // first pass...if the plugin is specified in the pom, try to retrieve the version from there.
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin ); String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
@ -130,8 +121,8 @@ public class DefaultPluginVersionManager
if ( Boolean.TRUE.equals( pluginUpdateOverride ) || if ( Boolean.TRUE.equals( pluginUpdateOverride ) ||
( !Boolean.FALSE.equals( pluginUpdateOverride ) && shouldCheckForUpdates( groupId, artifactId ) ) ) ( !Boolean.FALSE.equals( pluginUpdateOverride ) && shouldCheckForUpdates( groupId, artifactId ) ) )
{ {
updatedVersion = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(), updatedVersion = resolveMetaVersion( groupId, artifactId, project,
localRepository, Artifact.RELEASE_VERSION ); localRepository, Artifact.LATEST_VERSION );
if ( StringUtils.isNotEmpty( updatedVersion ) && !updatedVersion.equals( version ) ) if ( StringUtils.isNotEmpty( updatedVersion ) && !updatedVersion.equals( version ) )
{ {
@ -158,20 +149,12 @@ public class DefaultPluginVersionManager
boolean forcePersist = false; boolean forcePersist = false;
// are we using the LATEST metadata to resolve plugin version? // third pass...we're always checking for latest install/deploy, so retrieve the version for LATEST metadata and
Boolean rtCheckLatest = settingsRTInfo.getCheckLatestPluginVersion(); // also set that resolved version as the <useVersion/> in settings.xml.
if ( StringUtils.isEmpty( version ) )
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 )
{ {
// 1. resolve the version to be used // 1. resolve the version to be used
version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(), localRepository, version = resolveMetaVersion( groupId, artifactId, project, localRepository,
Artifact.LATEST_VERSION ); Artifact.LATEST_VERSION );
if ( version != null ) if ( version != null )
@ -185,24 +168,26 @@ public class DefaultPluginVersionManager
} }
} }
// 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/> // final pass...retrieve the version for RELEASE and also set that resolved version as the <useVersion/>
// in settings.xml. // in settings.xml.
if ( StringUtils.isEmpty( version ) ) // if ( StringUtils.isEmpty( version ) )
{ // {
// 1. resolve the version to be used // // 1. resolve the version to be used
version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(), localRepository, // version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(), localRepository,
Artifact.RELEASE_VERSION ); // Artifact.RELEASE_VERSION );
//
if ( version != null ) // if ( version != null )
{ // {
// 2. Set the updatedVersion so the user will be prompted whether to make this version permanent. // // 2. Set the updatedVersion so the user will be prompted whether to make this version permanent.
updatedVersion = version; // updatedVersion = version;
//
// 3. Persist this version without prompting. // // 3. Persist this version without prompting.
forcePersist = true; // forcePersist = true;
promptToPersist = false; // promptToPersist = false;
} // }
} // }
// if we still haven't found a version, then fail early before we get into the update goop. // if we still haven't found a version, then fail early before we get into the update goop.
if ( StringUtils.isEmpty( version ) ) if ( StringUtils.isEmpty( version ) )
@ -633,66 +618,75 @@ public class DefaultPluginVersionManager
return pluginRegistry; return pluginRegistry;
} }
private String resolveMetaVersion( String groupId, String artifactId, List remoteRepositories, private String resolveMetaVersion( String groupId, String artifactId, MavenProject project,
ArtifactRepository localRepository, String metaVersionId ) ArtifactRepository localRepository, String metaVersionId )
throws PluginVersionResolutionException throws PluginVersionResolutionException
{ {
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId ); Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
project.replaceWithActiveArtifact( artifact );
String version = null; String version = null;
try if ( artifact.isResolved() )
{ {
ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository, version = artifact.getVersion();
remoteRepositories ); }
else
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom {
// artifact. try
artifact = resolutionGroup.getPomArtifact();
// make sure this artifact was actually resolved to a file in the repo...
if ( artifact.getFile() != null )
{ {
MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository,
localRepository, false ); 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 // make sure this artifact was actually resolved to a file in the repo...
if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null ) if ( artifact.getFile() != null )
{ {
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion( MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project
project.getPrerequisites().getMaven() ); .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() + DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
" as it requires Maven version " + requiredVersion ); pluginProject.getPrerequisites().getMaven() );
pluginValid = false;
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 )
catch ( ArtifactMetadataRetrievalException e ) {
{ getLogger().debug( "Failed to resolve " + metaVersionId + " version", e );
getLogger().debug( "Failed to resolve " + metaVersionId + " version", e ); }
} catch ( ProjectBuildingException e )
catch ( ProjectBuildingException e ) {
{ throw new PluginVersionResolutionException( groupId, artifactId,
throw new PluginVersionResolutionException( groupId, artifactId, "Unable to build resolve plugin project information", e );
"Unable to build resolve plugin project information", e ); }
} catch ( IOException e )
catch ( IOException e ) {
{ throw new PluginVersionResolutionException( groupId, artifactId,
throw new PluginVersionResolutionException( groupId, artifactId, "Unable to determine Maven version for comparison", e );
"Unable to determine Maven version for comparison", e ); }
} }
return version; return version;

View File

@ -37,9 +37,12 @@ public class ArtifactNotFoundDiagnoser
StringBuffer message = new StringBuffer(); 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( "\n\n" );
message.append( exception.getMessage() ); message.append( "Reason: " ).append( exception.getMessage() );
if ( !wagonManager.isOnline() ) if ( !wagonManager.isOnline() )
{ {

View File

@ -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();
}
}

View File

@ -93,6 +93,16 @@
</component> </component>
<!-- <!--
| |
|ProjectBuildDiagnoser
|
-->
<component>
<role>org.apache.maven.usability.ErrorDiagnoser</role>
<role-hint>ProjectBuildDiagnoser</role-hint>
<implementation>org.apache.maven.usability.ProjectBuildDiagnoser</implementation>
</component>
<!--
|
|ProfileActivationDiagnoser |ProfileActivationDiagnoser
| |
--> -->
@ -307,7 +317,8 @@
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile> <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test> <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
<package> <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> </package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install> <install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy> <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>

View File

@ -163,10 +163,25 @@ public class ArtifactDownloader
File file = localFile; File file = localFile;
if ( remoteFile.exists() ) if ( remoteFile.exists() )
{ {
if ( !localFile.exists() || localFile.lastModified() < remoteFile.lastModified() ) if ( !localFile.exists() )
{ {
file = remoteFile; 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() ) if ( file.exists() )

View File

@ -26,9 +26,14 @@ import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.TimeZone;
/** /**
* I/O for repository metadata. * I/O for repository metadata.
@ -176,6 +181,21 @@ public class RepositoryMetadata
return 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 ) public void setLastUpdated( String lastUpdated )
{ {
this.lastUpdated = lastUpdated; this.lastUpdated = lastUpdated;

View File

@ -1,6 +1,7 @@
package org.apache.maven.plugins.projecthelp; package org.apache.maven.plugins.projecthelp;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
@ -215,6 +216,11 @@ public class DescribeMojo
throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId
+ "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e ); + "\'\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; return descriptor;
@ -326,6 +332,26 @@ public class DescribeMojo
String eLife = md.getExecuteLifecycle(); String eLife = md.getExecuteLifecycle();
String ePhase = md.getExecutePhase(); 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 parameters = md.getParameters();
List requirements = md.getRequirements(); List requirements = md.getRequirements();

View File

@ -22,10 +22,6 @@
<version>3.8.1</version> <version>3.8.1</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</dependency>
<dependency> <dependency>
<groupId>surefire</groupId> <groupId>surefire</groupId>
<artifactId>surefire</artifactId> <artifactId>surefire</artifactId>
@ -55,5 +51,10 @@
<version>1.0.4-SNAPSHOT</version> <version>1.0.4-SNAPSHOT</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-4-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -268,14 +268,14 @@ public class SurefirePlugin
surefireBooter.addClassPathUrl( classpathElement ); surefireBooter.addClassPathUrl( classpathElement );
} }
for ( Iterator i = pluginArtifacts.iterator(); i.hasNext(); ) // for ( Iterator i = pluginArtifacts.iterator(); i.hasNext(); )
{ // {
Artifact artifact = (Artifact) i.next(); // Artifact artifact = (Artifact) i.next();
//
getLog().debug( artifact.getFile().getAbsolutePath() ); // getLog().debug( artifact.getFile().getAbsolutePath() );
//
surefireBooter.addClassPathUrl( artifact.getFile().getAbsolutePath() ); // surefireBooter.addClassPathUrl( artifact.getFile().getAbsolutePath() );
} // }
addReporters(surefireBooter); addReporters(surefireBooter);

View File

@ -175,7 +175,7 @@
<module>maven-javadoc-plugin</module> <module>maven-javadoc-plugin</module>
<module>maven-plugin-plugin</module> <module>maven-plugin-plugin</module>
<module>maven-pmd-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-project-info-reports-plugin</module>
<module>maven-rar-plugin</module> <module>maven-rar-plugin</module>
<module>maven-release-plugin</module> <module>maven-release-plugin</module>

View File

@ -18,6 +18,7 @@ package org.apache.maven.project;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactStatus; import org.apache.maven.artifact.ArtifactStatus;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@ -183,7 +184,7 @@ public class DefaultMavenProjectBuilder
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
Artifact projectArtifact = project.getArtifact(); Artifact projectArtifact = project.getArtifact();
Map managedVersions = createManagedVersionMap( project.getDependencyManagement() ); Map managedVersions = createManagedVersionMap( project.getId(), project.getDependencyManagement() );
ensureMetadataSourceIsInitialized(); ensureMetadataSourceIsInitialized();
@ -193,7 +194,7 @@ public class DefaultMavenProjectBuilder
} }
catch ( InvalidVersionSpecificationException e ) catch ( InvalidVersionSpecificationException e )
{ {
throw new ProjectBuildingException( "Error in dependency version", e ); throw new ProjectBuildingException( project.getId(), "Error in dependency version", e );
} }
if ( transferListener != null ) if ( transferListener != null )
@ -223,12 +224,12 @@ public class DefaultMavenProjectBuilder
} }
catch ( ComponentLookupException e ) 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 throws ProjectBuildingException
{ {
Map map; Map map;
@ -249,7 +250,7 @@ public class DefaultMavenProjectBuilder
} }
catch ( InvalidVersionSpecificationException e ) 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 @@ public class DefaultMavenProjectBuilder
ProfileManager profileManager ) ProfileManager profileManager )
throws ProjectBuildingException throws ProjectBuildingException
{ {
Model model = readModel( projectDescriptor ); Model model = readModel( "unknown", projectDescriptor );
// Always cache files in the source tree over those in the repository // Always cache files in the source tree over those in the repository
MavenProject p = new MavenProject( model ); MavenProject p = new MavenProject( model );
@ -284,7 +285,7 @@ public class DefaultMavenProjectBuilder
if ( project.getDistributionManagement() != null && project.getDistributionManagement().getStatus() != null ) 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" ); "Invalid project file: distribution status must not be specified for a project outside of the repository" );
} }
@ -350,6 +351,8 @@ public class DefaultMavenProjectBuilder
Model model; Model model;
if ( project == null ) if ( project == null )
{ {
String projectId = ArtifactUtils.versionlessKey( projectArtifact );
try try
{ {
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository ); artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
@ -358,7 +361,7 @@ public class DefaultMavenProjectBuilder
// TODO: how can this not be true? // TODO: how can this not be true?
if ( projectArtifact.isResolved() ) if ( projectArtifact.isResolved() )
{ {
model = readModel( file ); model = readModel( projectId, file );
String downloadUrl = null; String downloadUrl = null;
ArtifactStatus status = ArtifactStatus.NONE; ArtifactStatus status = ArtifactStatus.NONE;
@ -421,12 +424,12 @@ public class DefaultMavenProjectBuilder
} }
else 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 ) 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 ) catch ( ArtifactNotFoundException e )
{ {
@ -436,7 +439,7 @@ public class DefaultMavenProjectBuilder
} }
else else
{ {
throw new ProjectBuildingException( "POM not found in repository", e ); throw new ProjectBuildingException( projectId, "POM not found in repository", e );
} }
} }
} }
@ -514,6 +517,8 @@ public class DefaultMavenProjectBuilder
// Use a TreeSet to ensure ordering is retained // Use a TreeSet to ensure ordering is retained
Set aggregatedRemoteWagonRepositories = new LinkedHashSet(); Set aggregatedRemoteWagonRepositories = new LinkedHashSet();
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
List activeExternalProfiles; List activeExternalProfiles;
try try
{ {
@ -528,7 +533,7 @@ public class DefaultMavenProjectBuilder
} }
catch ( ProfileActivationException e ) 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(); ) for ( Iterator i = activeExternalProfiles.iterator(); i.hasNext(); )
@ -586,7 +591,7 @@ public class DefaultMavenProjectBuilder
} }
catch ( ModelInterpolationException e ) 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 ); e );
} }
projectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ), projectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ),
@ -594,6 +599,25 @@ public class DefaultMavenProjectBuilder
return project; 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 ) private List buildArtifactRepositories( Model model )
throws ProjectBuildingException throws ProjectBuildingException
{ {
@ -698,17 +722,16 @@ public class DefaultMavenProjectBuilder
if ( validationResult.getMessageCount() > 0 ) if ( validationResult.getMessageCount() > 0 )
{ {
throw new ProjectBuildingException( "Failed to validate POM for \'" + pomLocation + throw new InvalidProjectModelException( project.getId(), pomLocation, "Failed to validate POM", validationResult );
"\'.\n\n Reason(s):\n" + validationResult.render( " " ) );
} }
project.setRemoteArtifactRepositories( project.setRemoteArtifactRepositories(
ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) ); ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) );
// TODO: these aren't taking active project artifacts into consideration in the reactor // TODO: these aren't taking active project artifacts into consideration in the reactor
project.setPluginArtifacts( createPluginArtifacts( project.getBuildPlugins() ) ); project.setPluginArtifacts( createPluginArtifacts( project.getId(), project.getBuildPlugins() ) );
project.setReportArtifacts( createReportArtifacts( project.getReportPlugins() ) ); project.setReportArtifacts( createReportArtifacts( project.getId(), project.getReportPlugins() ) );
project.setExtensionArtifacts( createExtensionArtifacts( project.getBuildExtensions() ) ); project.setExtensionArtifacts( createExtensionArtifacts( project.getId(), project.getBuildExtensions() ) );
return project; return project;
} }
@ -756,7 +779,9 @@ public class DefaultMavenProjectBuilder
} }
catch ( ProfileActivationException e ) 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 ); MavenProject project = new MavenProject( model );
@ -769,17 +794,19 @@ public class DefaultMavenProjectBuilder
if ( parentModel != null ) if ( parentModel != null )
{ {
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
if ( StringUtils.isEmpty( parentModel.getGroupId() ) ) 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() ) ) 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() ) ) 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... // the only way this will have a value is if we find the parent on disk...
@ -818,7 +845,7 @@ public class DefaultMavenProjectBuilder
if ( parentDescriptor != null && parentDescriptor.exists() ) if ( parentDescriptor != null && parentDescriptor.exists() )
{ {
Model candidateParent = readModel( parentDescriptor ); Model candidateParent = readModel( projectId, parentDescriptor );
String candidateParentGroupId = candidateParent.getGroupId(); String candidateParentGroupId = candidateParent.getGroupId();
if ( candidateParentGroupId == null && candidateParent.getParent() != null ) if ( candidateParentGroupId == null && candidateParent.getParent() != null )
@ -908,7 +935,9 @@ public class DefaultMavenProjectBuilder
} }
catch ( ProfileActivationException e ) 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(); ) for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
@ -967,27 +996,27 @@ public class DefaultMavenProjectBuilder
} }
} }
private Model readModel( File file ) private Model readModel( String projectId, File file )
throws ProjectBuildingException throws ProjectBuildingException
{ {
Reader reader = null; Reader reader = null;
try try
{ {
reader = new FileReader( file ); reader = new FileReader( file );
return readModel( reader ); return readModel( projectId, file.getAbsolutePath(), reader );
} }
catch ( FileNotFoundException e ) 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 ) 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 ); "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
} }
catch ( XmlPullParserException 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 ); "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
} }
finally finally
@ -996,8 +1025,8 @@ public class DefaultMavenProjectBuilder
} }
} }
private Model readModel( Reader reader ) private Model readModel( String projectId, String pomLocation, Reader reader )
throws IOException, XmlPullParserException, InvalidModelException throws IOException, XmlPullParserException, InvalidProjectModelException
{ {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
@ -1007,7 +1036,7 @@ public class DefaultMavenProjectBuilder
if ( modelSource.indexOf( "<modelVersion>4.0.0" ) < 0 ) 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 ); StringReader sReader = new StringReader( modelSource );
@ -1015,23 +1044,23 @@ public class DefaultMavenProjectBuilder
return modelReader.read( sReader ); return modelReader.read( sReader );
} }
private Model readModel( URL url ) private Model readModel( String projectId, URL url )
throws ProjectBuildingException throws ProjectBuildingException
{ {
InputStreamReader reader = null; InputStreamReader reader = null;
try try
{ {
reader = new InputStreamReader( url.openStream() ); reader = new InputStreamReader( url.openStream() );
return readModel( reader ); return readModel( projectId, url.toExternalForm(), reader );
} }
catch ( IOException e ) 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 ); "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
} }
catch ( XmlPullParserException 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 ); "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
} }
finally finally
@ -1050,7 +1079,7 @@ public class DefaultMavenProjectBuilder
return groupId + ":" + artifactId + ":" + version; return groupId + ":" + artifactId + ":" + version;
} }
protected Set createPluginArtifacts( List plugins ) protected Set createPluginArtifacts( String projectId, List plugins )
throws ProjectBuildingException throws ProjectBuildingException
{ {
Set pluginArtifacts = new HashSet(); Set pluginArtifacts = new HashSet();
@ -1077,7 +1106,7 @@ public class DefaultMavenProjectBuilder
} }
catch ( InvalidVersionSpecificationException e ) 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 ) if ( artifact != null )
@ -1090,7 +1119,7 @@ public class DefaultMavenProjectBuilder
} }
// TODO: share with createPluginArtifacts? // TODO: share with createPluginArtifacts?
protected Set createReportArtifacts( List reports ) protected Set createReportArtifacts( String projectId, List reports )
throws ProjectBuildingException throws ProjectBuildingException
{ {
Set pluginArtifacts = new HashSet(); Set pluginArtifacts = new HashSet();
@ -1119,7 +1148,7 @@ public class DefaultMavenProjectBuilder
} }
catch ( InvalidVersionSpecificationException e ) 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 ) if ( artifact != null )
@ -1133,7 +1162,7 @@ public class DefaultMavenProjectBuilder
} }
// TODO: share with createPluginArtifacts? // TODO: share with createPluginArtifacts?
protected Set createExtensionArtifacts( List extensions ) protected Set createExtensionArtifacts( String projectId, List extensions )
throws ProjectBuildingException throws ProjectBuildingException
{ {
Set extensionArtifacts = new HashSet(); Set extensionArtifacts = new HashSet();
@ -1162,7 +1191,7 @@ public class DefaultMavenProjectBuilder
} }
catch ( InvalidVersionSpecificationException e ) 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 ) if ( artifact != null )
@ -1215,7 +1244,9 @@ public class DefaultMavenProjectBuilder
} }
catch ( ModelInterpolationException e ) 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 @@ public class DefaultMavenProjectBuilder
{ {
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" ); 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 ) public void contextualize( Context context )

View File

@ -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 );
}
}

View File

@ -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;
}
}

View File

@ -23,18 +23,22 @@ package org.apache.maven.project;
public class ProjectBuildingException public class ProjectBuildingException
extends Exception extends Exception
{ {
public ProjectBuildingException( String message ) private final String projectId;
public ProjectBuildingException( String projectId, String message )
{ {
super( message ); super( message );
this.projectId = projectId;
} }
public ProjectBuildingException( Throwable cause ) public ProjectBuildingException( String projectId, String message, Throwable cause )
{
super( cause );
}
public ProjectBuildingException( String message, Throwable cause )
{ {
super( message, cause ); super( message, cause );
this.projectId = projectId;
}
public String getProjectId()
{
return projectId;
} }
} }

View File

@ -139,7 +139,7 @@ public final class ProjectUtils
} }
catch ( ComponentLookupException e ) 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 ); "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
} }
return repositoryLayout; return repositoryLayout;

View File

@ -104,8 +104,6 @@ public class ActiveProjectArtifact
public void setFile( File destination ) public void setFile( File destination )
{ {
artifact.setFile( 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 ); project.getArtifact().setFile( destination );
} }

View File

@ -37,7 +37,7 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Exclusion; import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Relocation; 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.MavenProject;
import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingException;
@ -107,10 +107,10 @@ public class MavenMetadataSource
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository, project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository,
true ); true );
} }
catch ( InvalidModelException e ) catch ( InvalidProjectModelException e )
{ {
getLogger().warn( "POM for: \'" + pomArtifact + 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; project = null;
} }

View File

@ -34,7 +34,7 @@ public class RuntimeInfo
private boolean pluginRegistryActive = true; private boolean pluginRegistryActive = true;
// using Boolean for 3VL (null for not-set, otherwise override with value) // using Boolean for 3VL (null for not-set, otherwise override with value)
private Boolean checkLatest; // private Boolean checkLatest;
private Map activeProfileToSourceLevel = new HashMap(); private Map activeProfileToSourceLevel = new HashMap();
@ -127,14 +127,4 @@ public class RuntimeInfo
return localRepositorySourceLevel; return localRepositorySourceLevel;
} }
public void setCheckLatestPluginVersion( Boolean checkLatest )
{
this.checkLatest = checkLatest;
}
public Boolean getCheckLatestPluginVersion()
{
return checkLatest;
}
} }