public static int doMain( String[] args, ClassWorld classWorld ) { MavenCli cli = new MavenCli(); return cli.doMain( new CliRequest( args, classWorld ) ); }
void properties( CliRequest cliRequest ) { populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties ); }
private MavenExecutionRequest populateRequest( CliRequest cliRequest ) { return populateRequest( cliRequest, cliRequest.request ); }
slf4jLogger = new Slf4jStdoutLogger(); CLIManager cliManager = new CLIManager(); mavenConfig = cliManager.parse( args.toArray( new String[0] ) ); List<?> unrecongized = mavenConfig.getArgList(); if ( !unrecongized.isEmpty() ) cliManager.displayHelp( System.out ); throw e; cliRequest.commandLine = cliManager.parse( cliRequest.args ); cliRequest.commandLine = cliMerge( cliManager.parse( cliRequest.args ), mavenConfig ); cliManager.displayHelp( System.out ); throw e; cliManager.displayHelp( System.out ); throw new ExitException( 0 ); System.out.println( CLIReportingUtils.showVersion() ); throw new ExitException( 0 );
try initialize( cliRequest ); cli( cliRequest ); properties( cliRequest ); logging( cliRequest ); version( cliRequest ); localContainer = container( cliRequest ); commands( cliRequest ); configure( cliRequest ); toolchains( cliRequest ); populateRequest( cliRequest ); encryption( cliRequest ); repository( cliRequest ); return execute( cliRequest ); CLIReportingUtils.showError( slf4jLogger, "ABORTED", e, cliRequest.showErrors ); CLIReportingUtils.showError( slf4jLogger, "Error executing Maven.", e, cliRequest.showErrors );
Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory ); slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.DEBUG ); slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.ERROR ); String styleColor = cliRequest.getUserProperties().getProperty( STYLE_COLOR_PROPERTY, "auto" ); if ( "always".equals( styleColor ) ) logFile = resolveFile( logFile, cliRequest.workingDirectory ); slf4jConfiguration.activate(); plexusLoggerManager = new Slf4jLoggerManager(); slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
CliRequest cliRequest = new CliRequest( args, classWorld ); cliRequest.workingDirectory = workingDirectory; return doMain( cliRequest );
public static String showVersion() { final String ls = System.getProperty( "line.separator" ); Properties properties = getBuildProperties(); StringBuilder version = new StringBuilder( 256 ); version.append( buffer().strong( createMavenVersionString( properties ) ) ).append( ls ); version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: " + System.getProperty( "maven.home", "<unknown Maven " + "home>" ) ) ) .append( ls ); version.append( "Java version: " ).append( System.getProperty( "java.version", "<unknown Java version>" ) ).append( ", vendor: " ).append( System.getProperty( "java.vendor", "<unknown vendor>" ) ).append( ", runtime: " ).append( System.getProperty( "java.home", "<unknown runtime>" ) ).append( ls ); version.append( "Default locale: " ).append( Locale.getDefault() ).append( ", platform encoding: " ).append( System.getProperty( "file.encoding", "<unknown encoding>" ) ).append( ls ); version.append( "OS name: \"" ).append( Os.OS_NAME ).append( "\", version: \"" ).append( Os.OS_VERSION ).append( "\", arch: \"" ).append( Os.OS_ARCH ).append( "\", family: \"" ).append( Os.OS_FAMILY ).append( '\"' ); return version.toString(); }
Properties buildProperties = CLIReportingUtils.getBuildProperties(); String mavenBuildVersion = CLIReportingUtils.createMavenVersionString( buildProperties ); systemProperties.setProperty( "maven.build.version", mavenBuildVersion );
private void version( CliRequest cliRequest ) { if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) ) { System.out.println( CLIReportingUtils.showVersion() ); } }
throw new ExitException( 1 );
/** * Create a human readable string containing the Maven version, buildnumber, and time of build * * @param buildProperties The build properties * @return Readable build info */ static String createMavenVersionString( Properties buildProperties ) { String timestamp = reduce( buildProperties.getProperty( "timestamp" ) ); String version = reduce( buildProperties.getProperty( BUILD_VERSION_PROPERTY ) ); String rev = reduce( buildProperties.getProperty( "buildNumber" ) ); String distributionName = reduce( buildProperties.getProperty( "distributionName" ) ); String msg = distributionName + " "; msg += ( version != null ? version : "<version unknown>" ); if ( rev != null || timestamp != null ) { msg += " ("; msg += ( rev != null ? rev : "" ); if ( StringUtils.isNotBlank( timestamp ) ) { String ts = formatTimestamp( Long.valueOf( timestamp ) ); msg += ( rev != null ? "; " : "" ) + ts; } msg += ")"; } return msg; }
private void logStats( MavenSession session ) { infoLine( '-' ); long finish = System.currentTimeMillis(); long time = finish - session.getRequest().getStartTime().getTime(); String wallClock = session.getRequest().getDegreeOfConcurrency() > 1 ? " (Wall Clock)" : ""; logger.info( "Total time: " + formatDuration( time ) + wallClock ); logger.info( "Finished at: " + formatTimestamp( finish ) ); }
public static void main( String[] args ) { int result = main( args, null ); System.exit( result ); }
private List<File> parseExtClasspath( CliRequest cliRequest ) { String extClassPath = cliRequest.userProperties.getProperty( EXT_CLASS_PATH ); if ( extClassPath == null ) { extClassPath = cliRequest.systemProperties.getProperty( EXT_CLASS_PATH ); } List<File> jars = new ArrayList<>(); if ( StringUtils.isNotEmpty( extClassPath ) ) { for ( String jar : StringUtils.split( extClassPath, File.pathSeparator ) ) { File file = resolveFile( new File( jar ), cliRequest.workingDirectory ); slf4jLogger.debug( " Included " + file ); jars.add( file ); } } return jars; }
@Override protected void configure() { bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory ); } } );
public CommandLine parse( String[] args ) throws ParseException { // We need to eat any quotes surrounding arguments... String[] cleanArgs = CleanArgument.cleanArgs( args ); CommandLineParser parser = new DefaultParser(); return parser.parse( options, cleanArgs ); }
for ( CoreExtensionEntry entry : reverse( extensions ) )
public static int main( String[] args, ClassWorld classWorld ) { MavenCli cli = new MavenCli(); MessageUtils.systemInstall(); MessageUtils.registerShutdownHook(); int result = cli.doMain( new CliRequest( args, classWorld ) ); MessageUtils.systemUninstall(); return result; }