mirror of https://github.com/apache/maven.git
Cleaned up plugin-version resolution.
o Added four command-line options: --check-plugin-updates is a synonym for --update-plugins --no-plugin-registry turns off usage of plugin-registry.xml for plugin version resolution for the current build. --check-plugin-latest turns on usage of LATEST metadata for plugin version resolution for the current build. --no-plugin-latest turns off usage of LATEST metadata for plugin version resolution for the current build. o Added settings.xml configuration <usePluginRegistry>true|false</usePluginRegistry> to en/disable the use of plugin-registry.xml for plugin version resolution. The default value is true, to use the plugin-registry.xml. o Added plugin-registry.xml configuration <checkLatest>true|false</checkLatest> to en/disable the use of LATEST metadata when resolving plugin versions. The default value is false, or do not use LATEST. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219089 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
06597924cf
commit
3f47c60752
|
@ -122,7 +122,7 @@ echo Rebuilding maven2 plugins
|
|||
echo -----------------------------------------------------------------------
|
||||
cd maven-plugins
|
||||
@REM update the release info to ensure these versions get used in the integration tests
|
||||
call m2 --no-plugin-updates --batch-mode -DupdateReleaseInfo=true -e %MAVEN_CMD_LINE_ARGS% clean:clean install
|
||||
call m2 --no-plugin-registry --check-plugin-latest --batch-mode -DupdateReleaseInfo=true -e %MAVEN_CMD_LINE_ARGS% clean:clean install
|
||||
cd ..
|
||||
|
||||
echo
|
||||
|
@ -131,7 +131,7 @@ echo Rebuilding maven2 reports
|
|||
echo -----------------------------------------------------------------------
|
||||
cd maven-reports
|
||||
@REM update the release info to ensure these versions get used in the integration tests
|
||||
call m2 --no-plugin-updates --batch-mode -DupdateReleaseInfo=true -e %MAVEN_CMD_LINE_ARGS% clean:clean install
|
||||
call m2 --no-plugin-registry --check-plugin-latest --batch-mode -DupdateReleaseInfo=true -e %MAVEN_CMD_LINE_ARGS% clean:clean install
|
||||
cd ..
|
||||
|
||||
echo
|
||||
|
|
|
@ -57,7 +57,7 @@ ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
|||
|
||||
cd maven-plugins
|
||||
# update the release info to ensure these versions get used in the integration tests
|
||||
m2 --no-plugin-updates --batch-mode -DupdateReleaseInfo=true -e $ARGS clean:clean install
|
||||
m2 --no-plugin-registry --check-plugin-latest --batch-mode -DupdateReleaseInfo=true -e $ARGS clean:clean install
|
||||
ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
||||
)
|
||||
ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
||||
|
@ -69,7 +69,7 @@ ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
|||
|
||||
cd maven-reports
|
||||
# update the release info to ensure these versions get used in the integration tests
|
||||
m2 --no-plugin-updates --batch-mode -DupdateReleaseInfo=true -e $ARGS clean:clean install
|
||||
m2 --no-plugin-registry --check-plugin-latest --batch-mode -DupdateReleaseInfo=true -e $ARGS clean:clean install
|
||||
ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
||||
)
|
||||
ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
||||
|
@ -79,7 +79,7 @@ ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
|||
echo
|
||||
echo "Running maven-core integration tests ..."
|
||||
echo
|
||||
./maven-core-it.sh --batch-mode "$HOME_ARGS" $ARGS
|
||||
./maven-core-it.sh "$HOME_ARGS" $ARGS
|
||||
ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
||||
)
|
||||
ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
||||
|
|
|
@ -493,9 +493,12 @@ public class Verifier
|
|||
|
||||
cli.setExecutable( executable );
|
||||
|
||||
cli.createArgument().setValue( "-e" );
|
||||
// cli.createArgument().setValue( "-e" );
|
||||
cli.createArgument().setValue( "-X" );
|
||||
|
||||
cli.createArgument().setValue( "--no-plugin-updates" );
|
||||
cli.createArgument().setValue( "--no-plugin-registry" );
|
||||
|
||||
cli.createArgument().setValue( "--check-plugin-latest" );
|
||||
|
||||
cli.createArgument().setValue( "--batch-mode" );
|
||||
|
||||
|
|
|
@ -192,7 +192,8 @@ public class MavenCli
|
|||
settings.setInteractiveMode( false );
|
||||
}
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES ) )
|
||||
if ( commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES )
|
||||
|| commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES2 ) )
|
||||
{
|
||||
settings.getRuntimeInfo().setPluginUpdateOverride( Boolean.TRUE );
|
||||
}
|
||||
|
@ -201,6 +202,20 @@ public class MavenCli
|
|||
settings.getRuntimeInfo().setPluginUpdateOverride( Boolean.FALSE );
|
||||
}
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.FORCE_PLUGIN_LATEST_CHECK ) )
|
||||
{
|
||||
settings.getRuntimeInfo().setCheckLatestPluginVersion( Boolean.TRUE );
|
||||
}
|
||||
else if ( commandLine.hasOption( CLIManager.SUPPRESS_PLUGIN_LATEST_CHECK ) )
|
||||
{
|
||||
settings.getRuntimeInfo().setCheckLatestPluginVersion( Boolean.FALSE );
|
||||
}
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.SUPPRESS_PLUGIN_REGISTRY ) )
|
||||
{
|
||||
settings.setUsePluginRegistry( false );
|
||||
}
|
||||
|
||||
List projectFiles = null;
|
||||
try
|
||||
{
|
||||
|
@ -508,10 +523,18 @@ public class MavenCli
|
|||
|
||||
public static final char ACTIVATE_PROFILES = 'P';
|
||||
|
||||
public static final String FORCE_PLUGIN_UPDATES = "update-plugins";
|
||||
public static final String FORCE_PLUGIN_UPDATES = "check-plugin-updates";
|
||||
|
||||
public static final String FORCE_PLUGIN_UPDATES2 = "update-plugins";
|
||||
|
||||
public static final String SUPPRESS_PLUGIN_UPDATES = "no-plugin-updates";
|
||||
|
||||
public static final String SUPPRESS_PLUGIN_REGISTRY = "no-plugin-registry";
|
||||
|
||||
public static final String FORCE_PLUGIN_LATEST_CHECK = "check-plugin-latest";
|
||||
|
||||
public static final String SUPPRESS_PLUGIN_LATEST_CHECK = "no-plugin-latest";
|
||||
|
||||
public static final char CHECKSUM_FAILURE_POLICY = 'C';
|
||||
|
||||
public static final char CHECKSUM_WARNING_POLICY = 'c';
|
||||
|
@ -541,9 +564,17 @@ public class MavenCli
|
|||
"Update all snapshots regardless of repository policies" ).create( UPDATE_SNAPSHOTS ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "activate-profiles" ).withDescription(
|
||||
"Comma-delimited list of profiles to activate").hasArg().create( ACTIVATE_PROFILES ) );
|
||||
|
||||
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() );
|
||||
options.addOption( OptionBuilder.withLongOpt( FORCE_PLUGIN_UPDATES2 ).withDescription( "Synonym for " + FORCE_PLUGIN_UPDATES ).create() );
|
||||
options.addOption( OptionBuilder.withLongOpt( SUPPRESS_PLUGIN_UPDATES ).withDescription( "Suppress upToDate check for any relevant registered plugins" ).create() );
|
||||
options.addOption( OptionBuilder.withLongOpt( FORCE_PLUGIN_LATEST_CHECK ).withDescription( "Force checking of LATEST metadata for plugin versions" ).create() );
|
||||
options.addOption( OptionBuilder.withLongOpt( SUPPRESS_PLUGIN_LATEST_CHECK ).withDescription( "Suppress checking of LATEST metadata for plugin versions" ).create() );
|
||||
|
||||
options.addOption( OptionBuilder.withLongOpt( SUPPRESS_PLUGIN_REGISTRY ).withDescription( "Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create() );
|
||||
|
||||
options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription( "Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) );
|
||||
options.addOption( OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create( CHECKSUM_WARNING_POLICY ) );
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.apache.maven.plugin.registry.io.xpp3.PluginRegistryXpp3Writer;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.settings.RuntimeInfo;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.components.inputhandler.InputHandler;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
@ -82,11 +83,14 @@ public class DefaultPluginVersionManager
|
|||
// we're not going to prompt the user to accept a plugin update until we find one.
|
||||
boolean promptToPersist = false;
|
||||
|
||||
// determine the behavior WRT prompting the user and installing plugin updates.
|
||||
Boolean pluginUpdateOverride = settings.getRuntimeInfo().getPluginUpdateOverride();
|
||||
RuntimeInfo settingsRTInfo = settings.getRuntimeInfo();
|
||||
|
||||
// second pass...if the plugin is listed in the settings.xml, use the version from <useVersion/>.
|
||||
if ( StringUtils.isEmpty( version ) )
|
||||
// determine the behavior WRT prompting the user and installing plugin updates.
|
||||
Boolean pluginUpdateOverride = settingsRTInfo.getPluginUpdateOverride();
|
||||
|
||||
// second pass...if we're using the plugin registry, and the plugin is listed in the plugin-registry.xml, use
|
||||
// the version from <useVersion/>.
|
||||
if ( StringUtils.isEmpty( version ) && settings.isUsePluginRegistry() )
|
||||
{
|
||||
// resolve existing useVersion.
|
||||
version = resolveExistingFromPluginRegistry( groupId, artifactId );
|
||||
|
@ -102,8 +106,8 @@ public class DefaultPluginVersionManager
|
|||
if ( Boolean.TRUE.equals( pluginUpdateOverride )
|
||||
|| ( !Boolean.FALSE.equals( pluginUpdateOverride ) && shouldCheckForUpdates( groupId, artifactId ) ) )
|
||||
{
|
||||
updatedVersion = resolveMetaVersion( groupId, artifactId, project
|
||||
.getPluginArtifactRepositories(), localRepository, ReleaseArtifactTransformation.RELEASE_VERSION );
|
||||
updatedVersion = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(),
|
||||
localRepository, ReleaseArtifactTransformation.RELEASE_VERSION );
|
||||
|
||||
if ( StringUtils.isNotEmpty( updatedVersion ) && !updatedVersion.equals( version ) )
|
||||
{
|
||||
|
@ -120,8 +124,9 @@ public class DefaultPluginVersionManager
|
|||
}
|
||||
else
|
||||
{
|
||||
getLogger()
|
||||
.info( "Plugin \'" + constructPluginKey( groupId, artifactId ) + "\' has updates." );
|
||||
getLogger().info(
|
||||
"Plugin \'" + constructPluginKey( groupId, artifactId )
|
||||
+ "\' has updates." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,13 +135,20 @@ public class DefaultPluginVersionManager
|
|||
|
||||
boolean forcePersist = false;
|
||||
|
||||
// third pass...retrieve the version for RELEASE and also set that resolved version as the <useVersion/>
|
||||
// in settings.xml.
|
||||
if ( StringUtils.isEmpty( version ) )
|
||||
// are we using the LATEST metadata to resolve plugin version?
|
||||
Boolean rtCheckLatest = settingsRTInfo.getCheckLatestPluginVersion();
|
||||
|
||||
boolean checkLatestMetadata = Boolean.TRUE.equals( rtCheckLatest )
|
||||
|| ( !Boolean.FALSE.equals( rtCheckLatest ) && Boolean.valueOf( pluginRegistry.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
|
||||
version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(),
|
||||
localRepository, ReleaseArtifactTransformation.RELEASE_VERSION );
|
||||
localRepository, LatestArtifactTransformation.LATEST_VERSION );
|
||||
|
||||
// 2. Set the updatedVersion so the user will be prompted whether to make this version permanent.
|
||||
updatedVersion = version;
|
||||
|
@ -146,13 +158,13 @@ public class DefaultPluginVersionManager
|
|||
promptToPersist = false;
|
||||
}
|
||||
|
||||
// final pass...retrieve the version for LATEST 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.
|
||||
if ( StringUtils.isEmpty( version ) )
|
||||
{
|
||||
// 1. resolve the version to be used
|
||||
version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(),
|
||||
localRepository, LatestArtifactTransformation.LATEST_VERSION );
|
||||
localRepository, ReleaseArtifactTransformation.RELEASE_VERSION );
|
||||
|
||||
// 2. Set the updatedVersion so the user will be prompted whether to make this version permanent.
|
||||
updatedVersion = version;
|
||||
|
@ -169,6 +181,9 @@ public class DefaultPluginVersionManager
|
|||
"Failed to resolve a valid version for this plugin" );
|
||||
}
|
||||
|
||||
// if the plugin registry is inactive, then the rest of this goop is useless...
|
||||
if ( settings.isUsePluginRegistry() )
|
||||
{
|
||||
// determine whether this build is running in interactive mode
|
||||
// If it's not, then we'll defer to the autoUpdate setting from the registry
|
||||
// for a decision on updating the plugin in the registry...rather than prompting
|
||||
|
@ -197,8 +212,8 @@ public class DefaultPluginVersionManager
|
|||
// a. the registry is declared to be in autoUpdate mode
|
||||
//
|
||||
// NOTE: This is only the default value; it may be changed as the result of prompting the user.
|
||||
boolean persistUpdate = forcePersist || ( promptToPersist && !Boolean.FALSE.equals( pluginUpdateOverride )
|
||||
&& ( inInteractiveMode || autoUpdate ) );
|
||||
boolean persistUpdate = forcePersist
|
||||
|| ( promptToPersist && !Boolean.FALSE.equals( pluginUpdateOverride ) && ( inInteractiveMode || autoUpdate ) );
|
||||
|
||||
// retrieve the apply-to-all flag, if it's been set previously.
|
||||
Boolean applyToAll = settings.getRuntimeInfo().getApplyToAllPluginUpdates();
|
||||
|
@ -212,7 +227,8 @@ public class DefaultPluginVersionManager
|
|||
//
|
||||
// NOTE: We're incorporating here, to make the usages of this check more consistent and
|
||||
// resistant to change.
|
||||
promptToPersist = promptToPersist && pluginUpdateOverride == null && applyToAll == null && inInteractiveMode;
|
||||
promptToPersist = promptToPersist && pluginUpdateOverride == null && applyToAll == null
|
||||
&& inInteractiveMode;
|
||||
|
||||
if ( promptToPersist )
|
||||
{
|
||||
|
@ -237,6 +253,7 @@ public class DefaultPluginVersionManager
|
|||
{
|
||||
addNewVersionToRejectedListInExisting( groupId, artifactId, updatedVersion );
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
@ -590,8 +607,8 @@ public class DefaultPluginVersionManager
|
|||
ArtifactRepository localRepository, String metaVersionId )
|
||||
throws PluginVersionResolutionException
|
||||
{
|
||||
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, metaVersionId,
|
||||
Artifact.SCOPE_RUNTIME, "pom" );
|
||||
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, metaVersionId, Artifact.SCOPE_RUNTIME,
|
||||
"pom" );
|
||||
|
||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, projectBuilder, artifactFactory );
|
||||
|
||||
|
@ -600,7 +617,7 @@ public class DefaultPluginVersionManager
|
|||
{
|
||||
metadataSource.retrieve( artifact, localRepository, remoteRepositories );
|
||||
|
||||
version = artifact.getBaseVersion();
|
||||
version = artifact.getVersion();
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
|
|
|
@ -77,6 +77,12 @@
|
|||
<type>String</type>
|
||||
<description>Specifies whether the user should be prompted to update plugins.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>checkLatest</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>Whether to resolve plugin versions using LATEST metadata.</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>plugins</name>
|
||||
<version>1.0.0</version>
|
||||
|
|
|
@ -85,6 +85,13 @@
|
|||
<type>boolean</type>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>usePluginRegistry</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[Whether Maven should use the plugin-registry.xml file to manage plugin versions.]]></description>
|
||||
<type>boolean</type>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<!-- [JC] Not ready to use yet, so I'm making if unavailable for now. -->
|
||||
<!-- field>
|
||||
<name>passwordStore</name>
|
||||
|
|
|
@ -25,11 +25,17 @@ public class RuntimeInfo
|
|||
|
||||
private File file;
|
||||
|
||||
// using Boolean for 3VL (null for not-set, otherwise override with value)
|
||||
private Boolean pluginUpdateForced;
|
||||
|
||||
// using Boolean for 3VL (null, true-to-all, false-to-all)
|
||||
private Boolean applyToAllPluginUpdates;
|
||||
|
||||
private boolean pluginRegistryActive = true;
|
||||
|
||||
// using Boolean for 3VL (null for not-set, otherwise override with value)
|
||||
private Boolean checkLatest;
|
||||
|
||||
private Map activeProfileToSourceLevel = new HashMap();
|
||||
|
||||
private String localRepositorySourceLevel = TrackableBase.USER_LEVEL;
|
||||
|
@ -121,4 +127,14 @@ public class RuntimeInfo
|
|||
return localRepositorySourceLevel;
|
||||
}
|
||||
|
||||
public void setCheckLatestPluginVersion( Boolean checkLatest )
|
||||
{
|
||||
this.checkLatest = checkLatest;
|
||||
}
|
||||
|
||||
public Boolean getCheckLatestPluginVersion()
|
||||
{
|
||||
return checkLatest;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue