mirror of https://github.com/apache/maven.git
Fixing standalone maven-core build...fixing metadata merge where lastUpdated == "null" (null-string)...and finally, disabling plugin resolution from referencing the current project, since this will really screw up builds of plugins that are referenced in the plugin lifecycle mapping...like maven-surefire-plugin.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@312948 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
637a4df7f3
commit
32841e4e03
|
@ -93,23 +93,33 @@ public class DefaultPluginVersionManager
|
||||||
// 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 );
|
||||||
|
|
||||||
|
// NOTE: [jc; 11-Oct-2005] We CANNOT have this type of code in here. It will prevent plugins from building themselves,
|
||||||
|
// if they are part of the lifecycle mapping. For example, try the following:
|
||||||
|
//
|
||||||
|
// 1. Uncomment the remainder of the following code block and rebuild the core jar; put it in the m2 distro
|
||||||
|
// 2. rm -Rf <local-repo>/org/apache/maven/plugins/maven-surefire-plugin
|
||||||
|
// 3. go to <maven>/maven-plugins/maven-surefire-plugin, and try to build it.
|
||||||
|
//
|
||||||
|
// In the above example, the surefire plugin fails to build because the version used for testing is
|
||||||
|
// resolved to the version currently being built...which obviously doesn't exist yet.
|
||||||
|
|
||||||
// if there was no explicit version, try for one in the reactor
|
// if there was no explicit version, try for one in the reactor
|
||||||
if ( version == null )
|
if ( version == null )
|
||||||
{
|
{
|
||||||
// check self
|
// check self
|
||||||
if ( project.getGroupId().equals( groupId ) && project.getArtifactId().equals( artifactId ) )
|
// if ( project.getGroupId().equals( groupId ) && project.getArtifactId().equals( artifactId ) )
|
||||||
{
|
// {
|
||||||
version = project.getVersion();
|
// version = project.getVersion();
|
||||||
}
|
// }
|
||||||
else if ( project.getProjectReferences() != null )
|
// else if ( project.getProjectReferences() != null )
|
||||||
{
|
// {
|
||||||
String refId = ArtifactUtils.versionlessKey( groupId, artifactId );
|
String refId = ArtifactUtils.versionlessKey( groupId, artifactId );
|
||||||
MavenProject ref = (MavenProject) project.getProjectReferences().get( refId );
|
MavenProject ref = (MavenProject) project.getProjectReferences().get( refId );
|
||||||
if ( ref != null )
|
if ( ref != null )
|
||||||
{
|
{
|
||||||
version = ref.getVersion();
|
version = ref.getVersion();
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're NEVER going to persist POM-derived plugin versions.
|
// we're NEVER going to persist POM-derived plugin versions.
|
||||||
|
@ -640,70 +650,61 @@ public class DefaultPluginVersionManager
|
||||||
{
|
{
|
||||||
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||||
|
|
||||||
project.replaceWithActiveArtifact( artifact );
|
|
||||||
|
|
||||||
String version = null;
|
String version = null;
|
||||||
|
|
||||||
if ( artifact.isResolved() )
|
try
|
||||||
{
|
{
|
||||||
version = artifact.getVersion();
|
ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository,
|
||||||
}
|
project.getPluginArtifactRepositories() );
|
||||||
else
|
|
||||||
{
|
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
|
||||||
try
|
// artifact.
|
||||||
|
artifact = resolutionGroup.getPomArtifact();
|
||||||
|
|
||||||
|
// make sure this artifact was actually resolved to a file in the repo...
|
||||||
|
if ( artifact.getFile() != null )
|
||||||
{
|
{
|
||||||
ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository,
|
MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project
|
||||||
project.getPluginArtifactRepositories() );
|
.getPluginArtifactRepositories(), localRepository, false );
|
||||||
|
|
||||||
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
|
boolean pluginValid = true;
|
||||||
// artifact.
|
|
||||||
artifact = resolutionGroup.getPomArtifact();
|
|
||||||
|
|
||||||
// make sure this artifact was actually resolved to a file in the repo...
|
// if we don't have the required Maven version, then ignore an update
|
||||||
if ( artifact.getFile() != null )
|
if ( pluginProject.getPrerequisites() != null &&
|
||||||
|
pluginProject.getPrerequisites().getMaven() != null )
|
||||||
{
|
{
|
||||||
MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project
|
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
|
||||||
.getPluginArtifactRepositories(), localRepository, false );
|
pluginProject.getPrerequisites().getMaven() );
|
||||||
|
|
||||||
boolean pluginValid = true;
|
if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
|
||||||
|
|
||||||
// if we don't have the required Maven version, then ignore an update
|
|
||||||
if ( pluginProject.getPrerequisites() != null &&
|
|
||||||
pluginProject.getPrerequisites().getMaven() != null )
|
|
||||||
{
|
{
|
||||||
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
|
getLogger().info( "Ignoring available plugin update: " + artifact.getVersion() +
|
||||||
pluginProject.getPrerequisites().getMaven() );
|
" as it requires Maven version " + requiredVersion );
|
||||||
|
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,
|
{
|
||||||
"Unable to build resolve plugin project information", e );
|
throw new PluginVersionResolutionException( groupId, artifactId,
|
||||||
}
|
"Unable to build resolve plugin project information", e );
|
||||||
catch ( IOException e )
|
}
|
||||||
{
|
catch ( IOException e )
|
||||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
{
|
||||||
"Unable to determine Maven version for comparison", e );
|
throw new PluginVersionResolutionException( groupId, artifactId,
|
||||||
}
|
"Unable to determine Maven version for comparison", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
|
|
|
@ -108,6 +108,16 @@
|
||||||
v.getVersions().add( version );
|
v.getVersions().add( version );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( "null".equals( versioning.getLastUpdated() ) )
|
||||||
|
{
|
||||||
|
versioning.setLastUpdated( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( "null".equals( v.getLastUpdated() ) )
|
||||||
|
{
|
||||||
|
v.setLastUpdated( null );
|
||||||
|
}
|
||||||
|
|
||||||
if ( versioning.getLastUpdated() == null || versioning.getLastUpdated().length() == 0 )
|
if ( versioning.getLastUpdated() == null || versioning.getLastUpdated().length() == 0 )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue