in maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java [360:445]
private boolean promptToPersistPluginUpdate( String version, String updatedVersion, String groupId,
String artifactId, Settings settings )
throws PluginVersionResolutionException
{
try
{
StringBuffer message = new StringBuffer();
// this means that the plugin is not registered.
if ( version != null && version.equals( updatedVersion ) )
{
message.append( "Unregistered plugin detected.\n\n" );
}
else
{
message.append( "New plugin version detected.\n\n" );
}
message.append( "Group ID: " ).append( groupId ).append( "\n" );
message.append( "Artifact ID: " ).append( artifactId ).append( "\n" );
message.append( "\n" );
// this means that we've detected a new, non-rejected plugin version.
if ( version != null && !version.equals( updatedVersion ) )
{
message.append( "Registered Version: " ).append( version ).append( "\n" );
}
message.append( "Detected plugin version: " ).append( updatedVersion ).append( "\n" );
message.append( "\n" );
message.append( "Would you like to use this new version from now on? ( [Y]es, [n]o, [a]ll, n[o]ne ) " );
// TODO: check the GUI-friendliness of this approach to collecting input.
// If we can't port this prompt into a GUI, IDE-integration will not work well.
getLogger().info( message.toString() );
String persistAnswer = inputHandler.readLine();
boolean shouldPersist = true;
if ( !StringUtils.isEmpty( persistAnswer ) )
{
persistAnswer = persistAnswer.toLowerCase();
if ( persistAnswer.startsWith( "y" ) )
{
shouldPersist = true;
}
else if ( persistAnswer.startsWith( "a" ) )
{
shouldPersist = true;
settings.getRuntimeInfo().setApplyToAllPluginUpdates( Boolean.TRUE );
}
else if ( persistAnswer.indexOf( "o" ) > -1 )
{
settings.getRuntimeInfo().setApplyToAllPluginUpdates( Boolean.FALSE );
}
else if ( persistAnswer.startsWith( "n" ) )
{
shouldPersist = false;
}
else
{
// default to yes.
shouldPersist = true;
}
}
if ( shouldPersist )
{
getLogger().info( "Updating plugin version to " + updatedVersion );
}
else
{
getLogger().info( "NOT updating plugin version to " + updatedVersion );
}
return shouldPersist;
}
catch ( IOException e )
{
throw new PluginVersionResolutionException( groupId, artifactId, "Can't read user input.", e );
}
}