Author: jdcasey Date: Wed Jun 3 15:39:52 2009 New Revision: 781439 URL: http://svn.apache.org/viewvc?rev=781439&view=rev Log: [MNG-4166] Fixing commons-cli problem with plugins forced to use the same version the core uses; updating assembly plugin version to latest release; adding (commented) configuration for debugging the bootstrap maven execution; and, adding embedder.stop() call in a finally block in the MavenCli.main() method to clean up for IDEs, etc.
Modified: maven/components/branches/maven-2.2.0-RC/apache-maven/pom.xml maven/components/branches/maven-2.2.0-RC/build.xml maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java maven/components/branches/maven-2.2.0-RC/pom.xml Modified: maven/components/branches/maven-2.2.0-RC/apache-maven/pom.xml URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.2.0-RC/apache-maven/pom.xml?rev=781439&r1=781438&r2=781439&view=diff ============================================================================== --- maven/components/branches/maven-2.2.0-RC/apache-maven/pom.xml (original) +++ maven/components/branches/maven-2.2.0-RC/apache-maven/pom.xml Wed Jun 3 15:39:52 2009 @@ -124,7 +124,7 @@ </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> - <version>2.1</version> + <version>2.2-beta-4</version> <executions> <execution> <id>bin-assembly</id> Modified: maven/components/branches/maven-2.2.0-RC/build.xml URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.2.0-RC/build.xml?rev=781439&r1=781438&r2=781439&view=diff ============================================================================== --- maven/components/branches/maven-2.2.0-RC/build.xml (original) +++ maven/components/branches/maven-2.2.0-RC/build.xml Wed Jun 3 15:39:52 2009 @@ -186,6 +186,12 @@ <target name="maven-compile" depends="compile-boot" description="compiles Maven using the bootstrap Maven, skipping automated tests"> <java fork="true" classname="org.apache.maven.cli.MavenCli" failonerror="true"> <jvmarg value="-Xmx256M"/> + + <!-- <jvmarg value="-Xdebug"/> + <jvmarg value="-Xnoagent"/> + <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,address=8000"/> + <jvmarg value="-Djava.compiler=NONE"/> --> + <classpath refid="maven.classpath"/> <arg value="-e"/> <arg value="-B"/> Modified: maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java?rev=781439&r1=781438&r2=781439&view=diff ============================================================================== --- maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java (original) +++ maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java Wed Jun 3 15:39:52 2009 @@ -65,7 +65,7 @@ artifacts.add( "classworlds" ); artifacts.add( "jsch" ); - artifacts.add( "commons-cli" ); +// artifacts.add( "commons-cli" ); artifacts.add( "doxia-sink-api" ); artifacts.add( "doxia-logging-api" ); artifacts.add( "maven-artifact" ); Modified: maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java?rev=781439&r1=781438&r2=781439&view=diff ============================================================================== --- maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java (original) +++ maven/components/branches/maven-2.2.0-RC/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java Wed Jun 3 15:39:52 2009 @@ -180,184 +180,192 @@ return 1; } - // ---------------------------------------------------------------------- - // The execution properties need to be created before the settings - // are constructed. - // ---------------------------------------------------------------------- - - Properties executionProperties = new Properties(); - Properties userProperties = new Properties(); - populateProperties( commandLine, executionProperties, userProperties ); - - Settings settings; - + // wraps the following code to ensure the embedder is stopped no matter what else happens. try { - settings = buildSettings( commandLine ); - } - catch ( SettingsConfigurationException e ) - { - showError( "Error reading settings.xml: " + e.getMessage(), e, showErrors ); + // ---------------------------------------------------------------------- + // The execution properties need to be created before the settings + // are constructed. + // ---------------------------------------------------------------------- - return 1; - } - catch ( ComponentLookupException e ) - { - showFatalError( "Unable to read settings.xml", e, showErrors ); + Properties executionProperties = new Properties(); + Properties userProperties = new Properties(); + populateProperties( commandLine, executionProperties, userProperties ); - return 1; - } + Settings settings; - DefaultSecDispatcher dispatcher; - try - { - if ( commandLine.hasOption( CLIManager.ENCRYPT_MASTER_PASSWORD ) ) + try + { + settings = buildSettings( commandLine ); + } + catch ( SettingsConfigurationException e ) { - String passwd = commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD ); + showError( "Error reading settings.xml: " + e.getMessage(), e, showErrors ); - DefaultPlexusCipher cipher = new DefaultPlexusCipher(); + return 1; + } + catch ( ComponentLookupException e ) + { + showFatalError( "Unable to read settings.xml", e, showErrors ); - System.out.println( cipher.encryptAndDecorate( passwd, - DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); - - return 0; + return 1; } - else if ( commandLine.hasOption( CLIManager.ENCRYPT_PASSWORD ) ) + + DefaultSecDispatcher dispatcher; + try { - String passwd = commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD ); - - dispatcher = (DefaultSecDispatcher) embedder.lookup( SecDispatcher.ROLE ); - String configurationFile = dispatcher.getConfigurationFile(); - if ( configurationFile.startsWith( "~" ) ) + if ( commandLine.hasOption( CLIManager.ENCRYPT_MASTER_PASSWORD ) ) { - configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); + String passwd = commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD ); + + DefaultPlexusCipher cipher = new DefaultPlexusCipher(); + + System.out.println( cipher.encryptAndDecorate( passwd, + DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); + + return 0; } - String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); - embedder.release( dispatcher ); - - String master = null; - - SettingsSecurity sec = SecUtil.read( file, true ); - if ( sec != null ) + else if ( commandLine.hasOption( CLIManager.ENCRYPT_PASSWORD ) ) { - master = sec.getMaster(); - } + String passwd = commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD ); + + dispatcher = (DefaultSecDispatcher) embedder.lookup( SecDispatcher.ROLE ); + String configurationFile = dispatcher.getConfigurationFile(); + if ( configurationFile.startsWith( "~" ) ) + { + configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); + } + String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); + embedder.release( dispatcher ); + + String master = null; + + SettingsSecurity sec = SecUtil.read( file, true ); + if ( sec != null ) + { + master = sec.getMaster(); + } - if ( master == null ) - { - System.err.println( "Master password is not set in the setting security file" ); + if ( master == null ) + { + System.err.println( "Master password is not set in the setting security file" ); + + return 1; + } - return 1; + DefaultPlexusCipher cipher = new DefaultPlexusCipher(); + String masterPasswd = + cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); + System.out.println( cipher.encryptAndDecorate( passwd, masterPasswd ) ); + + return 0; } + } + catch ( Exception e ) + { + showFatalError( "Error encrypting password: " + e.getMessage(), e, showErrors ); - DefaultPlexusCipher cipher = new DefaultPlexusCipher(); - String masterPasswd = - cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); - System.out.println( cipher.encryptAndDecorate( passwd, masterPasswd ) ); - - return 0; + return 1; } - } - catch ( Exception e ) - { - showFatalError( "Error encrypting password: " + e.getMessage(), e, showErrors ); - - return 1; - } - - Maven maven = null; - - MavenExecutionRequest request = null; + + Maven maven = null; - LoggerManager loggerManager = null; + MavenExecutionRequest request = null; - try - { - // logger must be created first - loggerManager = (LoggerManager) embedder.lookup( LoggerManager.ROLE ); + LoggerManager loggerManager = null; - if ( debug ) - { - loggerManager.setThreshold( Logger.LEVEL_DEBUG ); - } - else if ( commandLine.hasOption( CLIManager.QUIET ) ) + try { - // 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 - loggerManager.setThreshold( Logger.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. - } + // logger must be created first + loggerManager = (LoggerManager) embedder.lookup( LoggerManager.ROLE ); - ProfileManager profileManager = new DefaultProfileManager( embedder.getContainer(), executionProperties ); + if ( debug ) + { + loggerManager.setThreshold( Logger.LEVEL_DEBUG ); + } + else if ( commandLine.hasOption( CLIManager.QUIET ) ) + { + // 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 + loggerManager.setThreshold( Logger.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. + } - if ( commandLine.hasOption( CLIManager.ACTIVATE_PROFILES ) ) - { - String [] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES ); + ProfileManager profileManager = new DefaultProfileManager( embedder.getContainer(), executionProperties ); - if ( profileOptionValues != null ) + if ( commandLine.hasOption( CLIManager.ACTIVATE_PROFILES ) ) { - for ( int i=0; i < profileOptionValues.length; ++i ) - { - StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i], "," ); + String [] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES ); - while ( profileTokens.hasMoreTokens() ) + if ( profileOptionValues != null ) + { + for ( int i=0; i < profileOptionValues.length; ++i ) { - String profileAction = profileTokens.nextToken().trim(); + StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i], "," ); - if ( profileAction.startsWith( "-" ) || profileAction.startsWith( "!" ) ) + while ( profileTokens.hasMoreTokens() ) { - profileManager.explicitlyDeactivate( profileAction.substring( 1 ) ); - } - else if ( profileAction.startsWith( "+" ) ) - { - profileManager.explicitlyActivate( profileAction.substring( 1 ) ); - } - else - { - profileManager.explicitlyActivate( profileAction ); + String profileAction = profileTokens.nextToken().trim(); + + if ( profileAction.startsWith( "-" ) || profileAction.startsWith( "!" ) ) + { + profileManager.explicitlyDeactivate( profileAction.substring( 1 ) ); + } + else if ( profileAction.startsWith( "+" ) ) + { + profileManager.explicitlyActivate( profileAction.substring( 1 ) ); + } + else + { + profileManager.explicitlyActivate( profileAction ); + } } } } } - } - request = createRequest( commandLine, settings, eventDispatcher, loggerManager, profileManager, - executionProperties, userProperties, showErrors ); + request = createRequest( commandLine, settings, eventDispatcher, loggerManager, profileManager, + executionProperties, userProperties, showErrors ); - setProjectFileOptions( commandLine, request ); + setProjectFileOptions( commandLine, request ); - maven = - createMavenInstance( settings.isInteractiveMode(), - loggerManager.getLoggerForComponent( WagonManager.ROLE ) ); - } - catch ( ComponentLookupException e ) - { - showFatalError( "Unable to configure the Maven application", e, showErrors ); + maven = + createMavenInstance( settings.isInteractiveMode(), + loggerManager.getLoggerForComponent( WagonManager.ROLE ) ); + } + catch ( ComponentLookupException e ) + { + showFatalError( "Unable to configure the Maven application", e, showErrors ); - return 1; - } - finally - { - if ( loggerManager != null ) + return 1; + } + finally { - try - { - embedder.release( loggerManager ); - } - catch ( ComponentLifecycleException e ) + if ( loggerManager != null ) { - showFatalError( "Error releasing logging manager", e, showErrors ); + try + { + embedder.release( loggerManager ); + } + catch ( ComponentLifecycleException e ) + { + showFatalError( "Error releasing logging manager", e, showErrors ); + } } } - } - try - { - maven.execute( request ); + try + { + maven.execute( request ); + } + catch ( MavenExecutionException e ) + { + return 1; + } } - catch ( MavenExecutionException e ) + finally { - return 1; + embedder.stop(); } return 0; Modified: maven/components/branches/maven-2.2.0-RC/pom.xml URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.2.0-RC/pom.xml?rev=781439&r1=781438&r2=781439&view=diff ============================================================================== --- maven/components/branches/maven-2.2.0-RC/pom.xml (original) +++ maven/components/branches/maven-2.2.0-RC/pom.xml Wed Jun 3 15:39:52 2009 @@ -140,7 +140,7 @@ </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> - <version>2.2-beta-1</version> + <version>2.2-beta-4</version> </plugin> <plugin> <artifactId>maven-shade-plugin</artifactId>