Author: vsiveton Date: Mon Aug 18 07:39:06 2008 New Revision: 686774 URL: http://svn.apache.org/viewvc?rev=686774&view=rev Log: SCM-386: SCM plugin fails on "bootstrap" goal when shell environment has functions definitions
o using methods from p-u Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java?rev=686774&r1=686773&r2=686774&view=diff ============================================================================== --- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java (original) +++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java Mon Aug 18 07:39:06 2008 @@ -27,11 +27,7 @@ import org.codehaus.plexus.util.cli.DefaultConsumer; import org.codehaus.plexus.util.cli.StreamConsumer; -import java.io.BufferedReader; import java.io.File; -import java.io.InputStreamReader; -import java.util.Iterator; -import java.util.Properties; /** * Pull the project source from the configured scm and execute the configured goals. @@ -91,20 +87,16 @@ throws MojoExecutionException { Commandline cl = new Commandline(); - try { - addSystemEnvironment( cl ); + cl.addSystemEnvironment(); } catch ( Exception e ) { throw new MojoExecutionException( "Can't add system environment variables to mvn command line.", e ); } - cl.addEnvironment( "MAVEN_TERMINATE_CMD", "on" ); - cl.setExecutable( "mvn" ); - cl.setWorkingDirectory( determineWorkingDirectoryPath( this.getCheckoutDirectory(), relativePathProjectDirectory, goalsDirectory ) ); @@ -114,13 +106,13 @@ for ( int i = 0; i < tokens.length; ++i ) { - cl.createArgument().setValue( tokens[i] ); + cl.createArg().setValue( tokens[i] ); } } if ( ! StringUtils.isEmpty( this.profiles ) ) { - cl.createArgument().setValue( "-P" + this.profiles ); + cl.createArg().setValue( "-P" + this.profiles ); } StreamConsumer consumer = new DefaultConsumer(); @@ -167,73 +159,7 @@ { return projectDirectory.getPath(); } - else - { - return new File( projectDirectory, goalsDirectory ).getPath(); - } - } - - /** - * Add system environment variables - * Moved to plexus-utils 1.0.5 - */ - private void addSystemEnvironment( Commandline cl ) - throws Exception - { - Properties envVars = getSystemEnvVars(); - - for ( Iterator i = envVars.keySet().iterator(); i.hasNext(); ) - { - String key = (String) i.next(); - - cl.addEnvironment( key, envVars.getProperty( key ) ); - } - } - - private Properties getSystemEnvVars() - throws Exception - { - Process p = null; - - Properties envVars = new Properties(); - - Runtime r = Runtime.getRuntime(); - - String os = System.getProperty( "os.name" ).toLowerCase(); - - //If this is windows set the shell to command.com or cmd.exe with correct arguments. - if ( os.indexOf( "windows" ) != -1 ) - { - if ( os.indexOf( "95" ) != -1 || os.indexOf( "98" ) != -1 || os.indexOf( "Me" ) != -1 ) - { - p = r.exec( "command.com /c set" ); - } - else - { - p = r.exec( "cmd.exe /c set" ); - } - } - else - { - p = r.exec( "env" ); - } - - BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) ); - - String line; - - while ( ( line = br.readLine() ) != null ) - { - int idx = line.indexOf( '=' ); - - String key = line.substring( 0, idx ); - - String value = line.substring( idx + 1 ); - - envVars.setProperty( key, value ); - // System.out.println( key + " = " + value ); - } - return envVars; + return new File( projectDirectory, goalsDirectory ).getPath(); } }