mirror of https://github.com/apache/maven.git
o Fixing resolution of LATEST in plugin-versions, when <useLatest/> is enabled in plugin-registry.xml, or when --check-plugin-latest is specified on the command line.
o Fixing core-library resolution for expression: ${plugin.artifacts} and ${plugin.artifactMap} (latter is keyed by g:a) o Modified maven-core-it-plugin to accept something like "-DartifactToFile=org.apache.maven:maven-artifact"...it'll lookup that artifact in ${plugin.artifactMap}, and touch a file that's a mutation of the abs. path for that artifact. o Added pomArtifact to ResolutionGroup, since the MavenMetadataSource ALWAYS creates a new Artifact for a pom...this allows us to retrieve the resolved Artifact for that pom. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@225234 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
96dfb0ba8f
commit
73e549b231
|
@ -115,7 +115,7 @@ public class ArtifactResolverTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResolutionGroup( dependencies, remoteRepositories );
|
return new ResolutionGroup( artifact, dependencies, remoteRepositories );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public class ArtifactResolverTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResolutionGroup( dependencies, remoteRepositories );
|
return new ResolutionGroup( artifact, dependencies, remoteRepositories );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.apache.maven.artifact.metadata;
|
package org.apache.maven.artifact.metadata;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -8,13 +10,20 @@ public class ResolutionGroup
|
||||||
|
|
||||||
private final Set artifacts;
|
private final Set artifacts;
|
||||||
private final List resolutionRepositories;
|
private final List resolutionRepositories;
|
||||||
|
private final Artifact pomArtifact;
|
||||||
|
|
||||||
public ResolutionGroup( Set artifacts, List resolutionRepositories )
|
public ResolutionGroup( Artifact pomArtifact, Set artifacts, List resolutionRepositories )
|
||||||
{
|
{
|
||||||
|
this.pomArtifact = pomArtifact;
|
||||||
this.artifacts = artifacts;
|
this.artifacts = artifacts;
|
||||||
this.resolutionRepositories = resolutionRepositories;
|
this.resolutionRepositories = resolutionRepositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Artifact getPomArtifact()
|
||||||
|
{
|
||||||
|
return pomArtifact;
|
||||||
|
}
|
||||||
|
|
||||||
public Set getArtifacts()
|
public Set getArtifacts()
|
||||||
{
|
{
|
||||||
return artifacts;
|
return artifacts;
|
||||||
|
|
|
@ -419,7 +419,7 @@ public class DefaultArtifactCollectorTest
|
||||||
ArtifactSpec a = (ArtifactSpec) artifacts.get( key );
|
ArtifactSpec a = (ArtifactSpec) artifacts.get( key );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new ResolutionGroup( createArtifacts( artifactFactory, a.dependencies, artifact.getScope(),
|
return new ResolutionGroup( artifact, createArtifacts( artifactFactory, a.dependencies, artifact.getScope(),
|
||||||
artifact.getDependencyFilter() ), Collections.EMPTY_LIST );
|
artifact.getDependencyFilter() ), Collections.EMPTY_LIST );
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
|
|
|
@ -17,5 +17,15 @@
|
||||||
<artifactId>maven-project</artifactId>
|
<artifactId>maven-project</artifactId>
|
||||||
<version>2.0-beta-1-SNAPSHOT</version>
|
<version>2.0-beta-1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact</artifactId>
|
||||||
|
<version>2.0-beta-1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jline</groupId>
|
||||||
|
<artifactId>jline</artifactId>
|
||||||
|
<version>0.9.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</model>
|
</model>
|
||||||
|
|
|
@ -16,14 +16,15 @@ package org.apache.maven.plugin.coreit;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.util.List;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @goal touch
|
* @goal touch
|
||||||
|
@ -47,10 +48,10 @@ public class CoreItMojo
|
||||||
private String outputDirectory;
|
private String outputDirectory;
|
||||||
|
|
||||||
/** Test setting of plugin-artifacts on the PluginDescriptor instance.
|
/** Test setting of plugin-artifacts on the PluginDescriptor instance.
|
||||||
* @parameter expression="${plugin.artifacts}"
|
* @parameter expression="${plugin.artifactMap}"
|
||||||
* @required
|
* @required
|
||||||
*/
|
*/
|
||||||
private List pluginArtifacts;
|
private Map pluginArtifacts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="target/test-basedir-alignment"
|
* @parameter expression="target/test-basedir-alignment"
|
||||||
|
@ -67,6 +68,11 @@ public class CoreItMojo
|
||||||
*/
|
*/
|
||||||
private String goalItem = "bar";
|
private String goalItem = "bar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @parameter expression="${artifactToFile}"
|
||||||
|
*/
|
||||||
|
private String artifactToFile;
|
||||||
|
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
|
@ -82,15 +88,28 @@ public class CoreItMojo
|
||||||
|
|
||||||
touch( basedirAlignmentDirectory, "touch.txt" );
|
touch( basedirAlignmentDirectory, "touch.txt" );
|
||||||
|
|
||||||
|
File outDir = new File( outputDirectory );
|
||||||
|
|
||||||
// Test parameter setting
|
// Test parameter setting
|
||||||
if ( pluginItem != null )
|
if ( pluginItem != null )
|
||||||
{
|
{
|
||||||
touch( new File( outputDirectory ), pluginItem );
|
touch( outDir, pluginItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( goalItem != null )
|
if ( goalItem != null )
|
||||||
{
|
{
|
||||||
touch( new File( outputDirectory ), goalItem );
|
touch( outDir, goalItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( artifactToFile != null )
|
||||||
|
{
|
||||||
|
Artifact artifact = (Artifact) pluginArtifacts.get( artifactToFile );
|
||||||
|
|
||||||
|
File artifactFile = artifact.getFile();
|
||||||
|
|
||||||
|
String filename = artifactFile.getAbsolutePath().replace('/', '_').replace(':', '_') + ".txt";
|
||||||
|
|
||||||
|
touch( outDir, filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
project.getBuild().setFinalName( "coreitified" );
|
project.getBuild().setFinalName( "coreitified" );
|
||||||
|
|
|
@ -493,17 +493,17 @@ public class MavenCli
|
||||||
|
|
||||||
public static final char ACTIVATE_PROFILES = 'P';
|
public static final char ACTIVATE_PROFILES = 'P';
|
||||||
|
|
||||||
public static final String FORCE_PLUGIN_UPDATES = "check-plugin-updates";
|
public static final String FORCE_PLUGIN_UPDATES = "cpu";
|
||||||
|
|
||||||
public static final String FORCE_PLUGIN_UPDATES2 = "update-plugins";
|
public static final String FORCE_PLUGIN_UPDATES2 = "up";
|
||||||
|
|
||||||
public static final String SUPPRESS_PLUGIN_UPDATES = "no-plugin-updates";
|
public static final String SUPPRESS_PLUGIN_UPDATES = "npu";
|
||||||
|
|
||||||
public static final String SUPPRESS_PLUGIN_REGISTRY = "no-plugin-registry";
|
public static final String SUPPRESS_PLUGIN_REGISTRY = "npr";
|
||||||
|
|
||||||
public static final String FORCE_PLUGIN_LATEST_CHECK = "check-plugin-latest";
|
public static final String FORCE_PLUGIN_LATEST_CHECK = "cpl";
|
||||||
|
|
||||||
public static final String SUPPRESS_PLUGIN_LATEST_CHECK = "no-plugin-latest";
|
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';
|
||||||
|
|
||||||
|
@ -545,19 +545,19 @@ public class MavenCli
|
||||||
options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription(
|
||||||
"Run in non-interactive (batch) mode" ).create( BATCH_MODE ) );
|
"Run in non-interactive (batch) mode" ).create( BATCH_MODE ) );
|
||||||
|
|
||||||
options.addOption( OptionBuilder.withLongOpt( FORCE_PLUGIN_UPDATES ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ).withDescription(
|
||||||
"Force upToDate check for any relevant registered plugins" ).create( "cpu" ) );
|
"Force upToDate check for any relevant registered plugins" ).create( FORCE_PLUGIN_UPDATES ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( FORCE_PLUGIN_UPDATES2 ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription(
|
||||||
"Synonym for " + FORCE_PLUGIN_UPDATES ).create( "up" ) );
|
"Synonym for " + FORCE_PLUGIN_UPDATES ).create( FORCE_PLUGIN_UPDATES2 ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( SUPPRESS_PLUGIN_UPDATES ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription(
|
||||||
"Suppress upToDate check for any relevant registered plugins" ).create( "npu" ) );
|
"Suppress upToDate check for any relevant registered plugins" ).create( SUPPRESS_PLUGIN_UPDATES ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( FORCE_PLUGIN_LATEST_CHECK ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "check-plugin-latest" ).withDescription(
|
||||||
"Force checking of LATEST metadata for plugin versions" ).create( "cpl" ) );
|
"Force checking of LATEST metadata for plugin versions" ).create( FORCE_PLUGIN_LATEST_CHECK ) );
|
||||||
options.addOption( OptionBuilder.withLongOpt( SUPPRESS_PLUGIN_LATEST_CHECK ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "no-plugin-latest" ).withDescription(
|
||||||
"Suppress checking of LATEST metadata for plugin versions" ).create( "npl" ) );
|
"Suppress checking of LATEST metadata for plugin versions" ).create( SUPPRESS_PLUGIN_LATEST_CHECK ) );
|
||||||
|
|
||||||
options.addOption( OptionBuilder.withLongOpt( SUPPRESS_PLUGIN_REGISTRY ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription(
|
||||||
"Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( "npr" ) );
|
"Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( SUPPRESS_PLUGIN_REGISTRY ) );
|
||||||
|
|
||||||
options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription(
|
options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription(
|
||||||
"Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) );
|
"Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) );
|
||||||
|
|
|
@ -624,6 +624,11 @@ public class DefaultPluginManager
|
||||||
{
|
{
|
||||||
String artifactPath = resourceUrl.getPath();
|
String artifactPath = resourceUrl.getPath();
|
||||||
|
|
||||||
|
if ( artifactPath.startsWith( "file:" ) )
|
||||||
|
{
|
||||||
|
artifactPath = artifactPath.substring( "file:".length() );
|
||||||
|
}
|
||||||
|
|
||||||
artifactPath = artifactPath.substring( 0, artifactPath.length() - resource.length() );
|
artifactPath = artifactPath.substring( 0, artifactPath.length() - resource.length() );
|
||||||
|
|
||||||
if ( artifactPath.endsWith( "/" ) )
|
if ( artifactPath.endsWith( "/" ) )
|
||||||
|
|
|
@ -20,8 +20,8 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
|
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.transform.LatestArtifactTransformation;
|
|
||||||
import org.apache.maven.artifact.transform.ReleaseArtifactTransformation;
|
import org.apache.maven.artifact.transform.ReleaseArtifactTransformation;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.apache.maven.execution.RuntimeInformation;
|
import org.apache.maven.execution.RuntimeInformation;
|
||||||
|
@ -149,7 +149,7 @@ public class DefaultPluginVersionManager
|
||||||
Boolean rtCheckLatest = settingsRTInfo.getCheckLatestPluginVersion();
|
Boolean rtCheckLatest = settingsRTInfo.getCheckLatestPluginVersion();
|
||||||
|
|
||||||
boolean checkLatestMetadata = Boolean.TRUE.equals( rtCheckLatest ) ||
|
boolean checkLatestMetadata = Boolean.TRUE.equals( rtCheckLatest ) ||
|
||||||
( !Boolean.FALSE.equals( rtCheckLatest ) && Boolean.valueOf( getPluginRegistry( groupId, artifactId).getCheckLatest() )
|
( !Boolean.FALSE.equals( rtCheckLatest ) && Boolean.valueOf( getPluginRegistry( groupId, artifactId ).getCheckLatest() )
|
||||||
.booleanValue() );
|
.booleanValue() );
|
||||||
|
|
||||||
// third pass...if we're checking for latest install/deploy, retrieve the version for LATEST metadata and also
|
// third pass...if we're checking for latest install/deploy, retrieve the version for LATEST metadata and also
|
||||||
|
@ -622,10 +622,18 @@ public class DefaultPluginVersionManager
|
||||||
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||||
|
|
||||||
String version = null;
|
String version = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifactMetadataSource.retrieve( artifact, localRepository, remoteRepositories );
|
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 )
|
||||||
|
{
|
||||||
MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
|
MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
|
||||||
localRepository );
|
localRepository );
|
||||||
|
|
||||||
|
@ -636,6 +644,7 @@ public class DefaultPluginVersionManager
|
||||||
{
|
{
|
||||||
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
|
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
|
||||||
project.getPrerequesites().getMaven() );
|
project.getPrerequesites().getMaven() );
|
||||||
|
|
||||||
if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
|
if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
|
||||||
{
|
{
|
||||||
getLogger().info( "Ignoring available plugin update: " + artifact.getVersion() +
|
getLogger().info( "Ignoring available plugin update: " + artifact.getVersion() +
|
||||||
|
@ -649,6 +658,7 @@ public class DefaultPluginVersionManager
|
||||||
version = artifact.getVersion();
|
version = artifact.getVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch ( ArtifactMetadataRetrievalException e )
|
catch ( ArtifactMetadataRetrievalException e )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Failed to resolve " + metaVersionId + " version", e );
|
getLogger().debug( "Failed to resolve " + metaVersionId + " version", e );
|
||||||
|
@ -663,6 +673,7 @@ public class DefaultPluginVersionManager
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class MavenMetadataSource
|
||||||
Set artifacts = createArtifacts( artifactFactory, p.getDependencies(), artifact.getScope(),
|
Set artifacts = createArtifacts( artifactFactory, p.getDependencies(), artifact.getScope(),
|
||||||
artifact.getDependencyFilter() );
|
artifact.getDependencyFilter() );
|
||||||
|
|
||||||
return new ResolutionGroup( artifacts, p.getRemoteArtifactRepositories() );
|
return new ResolutionGroup( pomArtifact, artifacts, p.getRemoteArtifactRepositories() );
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class TestArtifactResolver
|
||||||
throw new ArtifactMetadataRetrievalException( e );
|
throw new ArtifactMetadataRetrievalException( e );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResolutionGroup( artifacts, artifactRepositories );
|
return new ResolutionGroup( artifact, artifacts, artifactRepositories );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set createArtifacts( List dependencies, String inheritedScope )
|
protected Set createArtifacts( List dependencies, String inheritedScope )
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class DefaultMavenSettingsBuilder
|
||||||
|
|
||||||
private File globalSettingsFile;
|
private File globalSettingsFile;
|
||||||
|
|
||||||
|
private Settings loadedSettings;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Component Lifecycle
|
// Component Lifecycle
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -105,6 +107,8 @@ public class DefaultMavenSettingsBuilder
|
||||||
|
|
||||||
public Settings buildSettings()
|
public Settings buildSettings()
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
|
{
|
||||||
|
if ( loadedSettings == null )
|
||||||
{
|
{
|
||||||
Settings globalSettings = readSettings( globalSettingsFile );
|
Settings globalSettings = readSettings( globalSettingsFile );
|
||||||
Settings userSettings = readSettings( userSettingsFile );
|
Settings userSettings = readSettings( userSettingsFile );
|
||||||
|
@ -119,7 +123,10 @@ public class DefaultMavenSettingsBuilder
|
||||||
|
|
||||||
setLocalRepository( userSettings );
|
setLocalRepository( userSettings );
|
||||||
|
|
||||||
return userSettings;
|
loadedSettings = userSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
return loadedSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLocalRepository( Settings userSettings )
|
private void setLocalRepository( Settings userSettings )
|
||||||
|
|
Loading…
Reference in New Issue