private void version( CliRequest cliRequest ) { if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) ) { System.out.println( CLIReportingUtils.showVersion() ); } }
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(); }
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 ) ); }
/** * 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; }
Properties buildProperties = CLIReportingUtils.getBuildProperties(); String mavenBuildVersion = CLIReportingUtils.createMavenVersionString( buildProperties ); systemProperties.setProperty( "maven.build.version", mavenBuildVersion );
data.put( "systemProperties", cliRequest.systemProperties ); data.put( "userProperties", cliRequest.userProperties ); data.put( "versionProperties", CLIReportingUtils.getBuildProperties() ); eventSpyDispatcher.init( eventSpyContext );
if (!setres.isValid()) { if (setres.getUserSettingsException() != null) { CLIReportingUtils.showError("Error reading user settings: ", setres.getUserSettingsException(), req.isShowErrors(), new DefaultCoreErrorReporter(), out);//NOI18N - part of maven output CLIReportingUtils.showError("Error reading global settings: ", setres.getGlobalSettingsException(), req.isShowErrors(), new DefaultCoreErrorReporter(), out);//NOI18N - part of maven output req.setRecursive(config.isRecursive()); MavenExecutionResult res = embedder.execute(req); CLIReportingUtils.logResult(req, res, out); if (res.hasExceptions()) { CLIReportingUtils.showError("Runtime Exception thrown during execution", re, req.isShowErrors(), req.getErrorReporter(), out);//NOI18N - part of maven output LOGGER.log(Level.FINE, re.getMessage(), re); } catch (ThreadDeath death) { CLIReportingUtils.showError("Killed.", new Exception(""), false, req.getErrorReporter(), out); //NOI18N - part of maven output shutdownOutput(ioput); ioput = null;
/** * 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 ( timestamp != null ) { SimpleDateFormat fmt = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ssZ" ); String ts = fmt.format( new Date( Long.valueOf( timestamp ).longValue() ) ); msg += ( rev != null ? "; " : "" ) + ts; } msg += ")"; } return msg; }
String buildTimeDuration = formatDuration( buildSummary.getTime() ); int padSize = MAX_PADDED_BUILD_TIME_DURATION_LENGTH - buildTimeDuration.length(); if ( padSize > 0 ) String buildTimeDuration = formatDuration( buildSummary.getTime() ); int padSize = MAX_PADDED_BUILD_TIME_DURATION_LENGTH - buildTimeDuration.length(); if ( padSize > 0 )
static void populateProperties( CommandLine commandLine, Properties systemProperties, Properties userProperties ) { EnvironmentUtils.addEnvVars( systemProperties ); // ---------------------------------------------------------------------- // Options that are set on the command line become system properties // and therefore are set in the session properties. System properties // are most dominant. // ---------------------------------------------------------------------- if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) ) { String[] defStrs = commandLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY ); if ( defStrs != null ) { for ( String defStr : defStrs ) { setCliProperty( defStr, userProperties ); } } } systemProperties.putAll( System.getProperties() ); // ---------------------------------------------------------------------- // Properties containing info about the currently running version of Maven // These override any corresponding properties set on the command line // ---------------------------------------------------------------------- Properties buildProperties = CLIReportingUtils.getBuildProperties(); String mavenVersion = buildProperties.getProperty( CLIReportingUtils.BUILD_VERSION_PROPERTY ); systemProperties.setProperty( "maven.version", mavenVersion ); String mavenBuildVersion = CLIReportingUtils.createMavenVersionString( buildProperties ); systemProperties.setProperty( "maven.build.version", mavenBuildVersion ); }
data.put( "systemProperties", cliRequest.systemProperties ); data.put( "userProperties", cliRequest.userProperties ); data.put( "versionProperties", CLIReportingUtils.getBuildProperties() ); eventSpyDispatcher.init( eventSpyContext );
/** * 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; }
String buildTimeDuration = formatDuration( buildSummary.getTime() ); int padSize = MAX_PADDED_BUILD_TIME_DURATION_LENGTH - buildTimeDuration.length(); if ( padSize > 0 ) String buildTimeDuration = formatDuration( buildSummary.getTime() ); int padSize = MAX_PADDED_BUILD_TIME_DURATION_LENGTH - buildTimeDuration.length(); if ( padSize > 0 )
System.out.println( CLIReportingUtils.showVersion() ); throw new ExitException( 0 );
public static String showVersion() { final String LS = System.getProperty( "line.separator" ); Properties properties = getBuildProperties(); StringBuffer version = new StringBuffer(); version.append( createMavenVersionString( properties ) ).append( LS ); version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: " + System.getProperty( "maven.home", "<unknown maven home>" ) ) ).append( LS ); version.append( "Java version: " + System.getProperty( "java.version", "<unknown java version>" ) + ", vendor: " + System.getProperty( "java.vendor", "<unknown vendor>" ) ).append( LS ); version.append( "Java home: " + System.getProperty( "java.home", "<unknown java home>" ) ).append( LS ); version.append( "Default locale: " + Locale.getDefault() + ", platform encoding: " + System.getProperty( "file.encoding", "<unknown encoding>" ) ).append( LS ); version.append( "OS name: \"" + Os.OS_NAME + "\", version: \"" + Os.OS_VERSION + "\", arch: \"" + Os.OS_ARCH + "\", family: \"" + Os.OS_FAMILY + "\"" ); return version.toString(); }
Properties buildProperties = CLIReportingUtils.getBuildProperties(); String mavenBuildVersion = CLIReportingUtils.createMavenVersionString( buildProperties ); systemProperties.setProperty( "maven.build.version", mavenBuildVersion );
data.put( "systemProperties", cliRequest.systemProperties ); data.put( "userProperties", cliRequest.userProperties ); data.put( "versionProperties", CLIReportingUtils.getBuildProperties() ); eventSpyDispatcher.init( eventSpyContext );