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:
John Dennis Casey 2005-07-26 05:54:24 +00:00
parent 96dfb0ba8f
commit 73e549b231
11 changed files with 123 additions and 62 deletions

View File

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

View File

@ -1,5 +1,7 @@
package org.apache.maven.artifact.metadata;
import org.apache.maven.artifact.Artifact;
import java.util.List;
import java.util.Set;
@ -8,13 +10,20 @@ public class ResolutionGroup
private final Set artifacts;
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.resolutionRepositories = resolutionRepositories;
}
public Artifact getPomArtifact()
{
return pomArtifact;
}
public Set getArtifacts()
{
return artifacts;

View File

@ -419,7 +419,7 @@ public class DefaultArtifactCollectorTest
ArtifactSpec a = (ArtifactSpec) artifacts.get( key );
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 );
}
catch ( InvalidVersionSpecificationException e )

View File

@ -17,5 +17,15 @@
<artifactId>maven-project</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</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>
</model>

View File

@ -16,14 +16,15 @@ package org.apache.maven.plugin.coreit;
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import java.io.IOException;
import java.io.File;
import java.io.FileWriter;
import java.util.List;
import java.io.IOException;
import java.util.Map;
/**
* @goal touch
@ -47,10 +48,10 @@ public class CoreItMojo
private String outputDirectory;
/** Test setting of plugin-artifacts on the PluginDescriptor instance.
* @parameter expression="${plugin.artifacts}"
* @parameter expression="${plugin.artifactMap}"
* @required
*/
private List pluginArtifacts;
private Map pluginArtifacts;
/**
* @parameter expression="target/test-basedir-alignment"
@ -67,6 +68,11 @@ public class CoreItMojo
*/
private String goalItem = "bar";
/**
* @parameter expression="${artifactToFile}"
*/
private String artifactToFile;
public void execute()
throws MojoExecutionException
{
@ -82,15 +88,28 @@ public class CoreItMojo
touch( basedirAlignmentDirectory, "touch.txt" );
File outDir = new File( outputDirectory );
// Test parameter setting
if ( pluginItem != null )
{
touch( new File( outputDirectory ), pluginItem );
touch( outDir, pluginItem );
}
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" );

View File

@ -493,17 +493,17 @@ public class MavenCli
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';
@ -545,19 +545,19 @@ public class MavenCli
options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription(
"Run in non-interactive (batch) mode" ).create( BATCH_MODE ) );
options.addOption( OptionBuilder.withLongOpt( FORCE_PLUGIN_UPDATES ).withDescription(
"Force upToDate check for any relevant registered plugins" ).create( "cpu" ) );
options.addOption( OptionBuilder.withLongOpt( FORCE_PLUGIN_UPDATES2 ).withDescription(
"Synonym for " + FORCE_PLUGIN_UPDATES ).create( "up" ) );
options.addOption( OptionBuilder.withLongOpt( SUPPRESS_PLUGIN_UPDATES ).withDescription(
"Suppress upToDate check for any relevant registered plugins" ).create( "npu" ) );
options.addOption( OptionBuilder.withLongOpt( FORCE_PLUGIN_LATEST_CHECK ).withDescription(
"Force checking of LATEST metadata for plugin versions" ).create( "cpl" ) );
options.addOption( OptionBuilder.withLongOpt( SUPPRESS_PLUGIN_LATEST_CHECK ).withDescription(
"Suppress checking of LATEST metadata for plugin versions" ).create( "npl" ) );
options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ).withDescription(
"Force upToDate check for any relevant registered plugins" ).create( FORCE_PLUGIN_UPDATES ) );
options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription(
"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( SUPPRESS_PLUGIN_REGISTRY ).withDescription(
"Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( "npr" ) );
options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription(
"Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( SUPPRESS_PLUGIN_REGISTRY ) );
options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription(
"Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) );

View File

@ -624,6 +624,11 @@ public class DefaultPluginManager
{
String artifactPath = resourceUrl.getPath();
if ( artifactPath.startsWith( "file:" ) )
{
artifactPath = artifactPath.substring( "file:".length() );
}
artifactPath = artifactPath.substring( 0, artifactPath.length() - resource.length() );
if ( artifactPath.endsWith( "/" ) )

View File

@ -20,8 +20,8 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
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.transform.LatestArtifactTransformation;
import org.apache.maven.artifact.transform.ReleaseArtifactTransformation;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.execution.RuntimeInformation;
@ -622,10 +622,18 @@ public class DefaultPluginVersionManager
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
String version = null;
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,
localRepository );
@ -636,6 +644,7 @@ public class DefaultPluginVersionManager
{
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(
project.getPrerequesites().getMaven() );
if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
{
getLogger().info( "Ignoring available plugin update: " + artifact.getVersion() +
@ -649,6 +658,7 @@ public class DefaultPluginVersionManager
version = artifact.getVersion();
}
}
}
catch ( ArtifactMetadataRetrievalException e )
{
getLogger().debug( "Failed to resolve " + metaVersionId + " version", e );
@ -663,6 +673,7 @@ public class DefaultPluginVersionManager
throw new PluginVersionResolutionException( groupId, artifactId,
"Unable to determine Maven version for comparison", e );
}
return version;
}

View File

@ -130,7 +130,7 @@ public class MavenMetadataSource
Set artifacts = createArtifacts( artifactFactory, p.getDependencies(), artifact.getScope(),
artifact.getDependencyFilter() );
return new ResolutionGroup( artifacts, p.getRemoteArtifactRepositories() );
return new ResolutionGroup( pomArtifact, artifacts, p.getRemoteArtifactRepositories() );
}
catch ( InvalidVersionSpecificationException e )
{

View File

@ -132,7 +132,7 @@ public class TestArtifactResolver
throw new ArtifactMetadataRetrievalException( e );
}
return new ResolutionGroup( artifacts, artifactRepositories );
return new ResolutionGroup( artifact, artifacts, artifactRepositories );
}
protected Set createArtifacts( List dependencies, String inheritedScope )

View File

@ -53,6 +53,8 @@ public class DefaultMavenSettingsBuilder
private File globalSettingsFile;
private Settings loadedSettings;
// ----------------------------------------------------------------------
// Component Lifecycle
// ----------------------------------------------------------------------
@ -105,6 +107,8 @@ public class DefaultMavenSettingsBuilder
public Settings buildSettings()
throws IOException, XmlPullParserException
{
if ( loadedSettings == null )
{
Settings globalSettings = readSettings( globalSettingsFile );
Settings userSettings = readSettings( userSettingsFile );
@ -119,7 +123,10 @@ public class DefaultMavenSettingsBuilder
setLocalRepository( userSettings );
return userSettings;
loadedSettings = userSettings;
}
return loadedSettings;
}
private void setLocalRepository( Settings userSettings )