mirror of https://github.com/apache/maven.git
o Fixed regressions after refactoring
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@830017 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8f85d87b5c
commit
611bd1c998
|
@ -116,7 +116,7 @@ public class DefaultMavenExecutionRequest
|
||||||
|
|
||||||
private int loggingLevel = LOGGING_LEVEL_INFO;
|
private int loggingLevel = LOGGING_LEVEL_INFO;
|
||||||
|
|
||||||
private String globalChecksumPolicy = CHECKSUM_POLICY_WARN;
|
private String globalChecksumPolicy;
|
||||||
|
|
||||||
private boolean updateSnapshots = false;
|
private boolean updateSnapshots = false;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.maven.exception.ExceptionHandler;
|
||||||
import org.apache.maven.exception.ExceptionSummary;
|
import org.apache.maven.exception.ExceptionSummary;
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
|
import org.apache.maven.execution.MavenExecutionRequestPopulator;
|
||||||
import org.apache.maven.execution.MavenExecutionResult;
|
import org.apache.maven.execution.MavenExecutionResult;
|
||||||
import org.apache.maven.model.building.ModelProcessor;
|
import org.apache.maven.model.building.ModelProcessor;
|
||||||
import org.apache.maven.repository.ArtifactTransferListener;
|
import org.apache.maven.repository.ArtifactTransferListener;
|
||||||
|
@ -84,11 +85,13 @@ public class MavenCli
|
||||||
|
|
||||||
private Maven maven;
|
private Maven maven;
|
||||||
|
|
||||||
|
private MavenExecutionRequestPopulator executionRequestPopulator;
|
||||||
|
|
||||||
private SettingsBuilder settingsBuilder;
|
private SettingsBuilder settingsBuilder;
|
||||||
|
|
||||||
private DefaultSecDispatcher dispatcher;
|
private DefaultSecDispatcher dispatcher;
|
||||||
|
|
||||||
private enum Exit { EXIT_WITH_ERROR, EXIT_WITHOUT_ERROR }
|
private enum Exit { EXIT_WITHOUT_ERROR, EXIT_WITH_ERROR }
|
||||||
|
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
{
|
{
|
||||||
|
@ -144,6 +147,17 @@ public class MavenCli
|
||||||
|
|
||||||
private void initialize( CliRequest cliRequest )
|
private void initialize( CliRequest cliRequest )
|
||||||
{
|
{
|
||||||
|
if ( cliRequest.stdout == null )
|
||||||
|
{
|
||||||
|
cliRequest.stdout = System.out;
|
||||||
|
}
|
||||||
|
if ( cliRequest.stderr == null )
|
||||||
|
{
|
||||||
|
cliRequest.stderr = System.err;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger = new PrintStreamLogger( cliRequest.stdout );
|
||||||
|
|
||||||
if ( cliRequest.workingDirectory == null )
|
if ( cliRequest.workingDirectory == null )
|
||||||
{
|
{
|
||||||
cliRequest.workingDirectory = System.getProperty( "user.dir" );
|
cliRequest.workingDirectory = System.getProperty( "user.dir" );
|
||||||
|
@ -166,16 +180,27 @@ public class MavenCli
|
||||||
//
|
//
|
||||||
private void logging( CliRequest cliRequest )
|
private void logging( CliRequest cliRequest )
|
||||||
{
|
{
|
||||||
if ( cliRequest.stdout == null )
|
cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG );
|
||||||
|
cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption( CLIManager.QUIET );
|
||||||
|
cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.ERRORS );
|
||||||
|
|
||||||
|
if ( cliRequest.debug )
|
||||||
{
|
{
|
||||||
cliRequest.stdout = System.out;
|
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG );
|
||||||
}
|
}
|
||||||
if ( cliRequest.stderr == null )
|
else if ( cliRequest.quiet )
|
||||||
{
|
{
|
||||||
cliRequest.stderr = System.err;
|
// TODO: we need to do some more work here. Some plugins use sys out or log errors at info level.
|
||||||
|
// Ideally, we could use Warn across the board
|
||||||
|
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR );
|
||||||
|
// TODO:Additionally, we can't change the mojo level because the component key includes the version and it isn't known ahead of time. This seems worth changing.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_INFO );
|
||||||
}
|
}
|
||||||
|
|
||||||
logger = new PrintStreamLogger( System.out );
|
logger.setThreshold( cliRequest.request.getLoggingLevel() );
|
||||||
|
|
||||||
if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
|
if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) )
|
||||||
{
|
{
|
||||||
|
@ -204,37 +229,33 @@ public class MavenCli
|
||||||
//
|
//
|
||||||
// Every bit of information taken from the CLI should be processed here.
|
// Every bit of information taken from the CLI should be processed here.
|
||||||
//
|
//
|
||||||
private void cli( CliRequest request )
|
private void cli( CliRequest cliRequest )
|
||||||
{
|
{
|
||||||
CLIManager cliManager = new CLIManager();
|
CLIManager cliManager = new CLIManager();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
request.commandLine = cliManager.parse( request.args );
|
cliRequest.commandLine = cliManager.parse( cliRequest.args );
|
||||||
}
|
}
|
||||||
catch ( ParseException e )
|
catch ( ParseException e )
|
||||||
{
|
{
|
||||||
request.stderr.println( "Unable to parse command line options: " + e.getMessage() );
|
cliRequest.stderr.println( "Unable to parse command line options: " + e.getMessage() );
|
||||||
cliManager.displayHelp( request.stdout );
|
cliManager.displayHelp( cliRequest.stdout );
|
||||||
request.exit = Exit.EXIT_WITH_ERROR;
|
cliRequest.exit = Exit.EXIT_WITH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
request.debug = request.commandLine.hasOption( CLIManager.DEBUG );
|
|
||||||
request.quiet = !request.debug && request.commandLine.hasOption( CLIManager.QUIET );
|
|
||||||
request.showErrors = request.debug || request.commandLine.hasOption( CLIManager.ERRORS );
|
|
||||||
|
|
||||||
// TODO: these should be moved out of here. Wrong place.
|
// TODO: these should be moved out of here. Wrong place.
|
||||||
//
|
//
|
||||||
if ( request.commandLine.hasOption( CLIManager.HELP ) )
|
if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) )
|
||||||
{
|
{
|
||||||
cliManager.displayHelp( request.stdout );
|
cliManager.displayHelp( cliRequest.stdout );
|
||||||
request.exit = Exit.EXIT_WITHOUT_ERROR;
|
cliRequest.exit = Exit.EXIT_WITHOUT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( request.commandLine.hasOption( CLIManager.VERSION ) )
|
if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) )
|
||||||
{
|
{
|
||||||
CLIReportingUtils.showVersion( request.stdout );
|
CLIReportingUtils.showVersion( cliRequest.stdout );
|
||||||
request.exit = Exit.EXIT_WITHOUT_ERROR;
|
cliRequest.exit = Exit.EXIT_WITHOUT_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +298,7 @@ public class MavenCli
|
||||||
|
|
||||||
DefaultPlexusContainer container = new DefaultPlexusContainer( cc );
|
DefaultPlexusContainer container = new DefaultPlexusContainer( cc );
|
||||||
|
|
||||||
container.setLoggerManager( new MavenLoggerManager( new PrintStreamLogger( System.out ) ) );
|
container.setLoggerManager( new MavenLoggerManager( logger ) );
|
||||||
|
|
||||||
container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() );
|
container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() );
|
||||||
|
|
||||||
|
@ -285,6 +306,8 @@ public class MavenCli
|
||||||
|
|
||||||
maven = container.lookup( Maven.class );
|
maven = container.lookup( Maven.class );
|
||||||
|
|
||||||
|
executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class );
|
||||||
|
|
||||||
modelProcessor = createModelProcessor( container );
|
modelProcessor = createModelProcessor( container );
|
||||||
|
|
||||||
settingsBuilder = container.lookup( SettingsBuilder.class );
|
settingsBuilder = container.lookup( SettingsBuilder.class );
|
||||||
|
@ -475,6 +498,8 @@ public class MavenCli
|
||||||
|
|
||||||
SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
|
SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
|
||||||
|
|
||||||
|
executionRequestPopulator.populateFromSettings( cliRequest.request, settingsResult.getEffectiveSettings() );
|
||||||
|
|
||||||
if ( !settingsResult.getProblems().isEmpty() && logger.isWarnEnabled() )
|
if ( !settingsResult.getProblems().isEmpty() && logger.isWarnEnabled() )
|
||||||
{
|
{
|
||||||
logger.warn( "" );
|
logger.warn( "" );
|
||||||
|
|
Loading…
Reference in New Issue