maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r351829 - in /maven/scm/trunk/maven-scm-plugin: pom.xml src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java
Date Fri, 02 Dec 2005 20:21:02 GMT
Author: evenisse
Date: Fri Dec  2 12:20:57 2005
New Revision: 351829

URL: http://svn.apache.org/viewcvs?rev=351829&view=rev
Log:
Don't use plexus-1.0.5 for backward compatibility

Modified:
    maven/scm/trunk/maven-scm-plugin/pom.xml
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java

Modified: maven/scm/trunk/maven-scm-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/pom.xml?rev=351829&r1=351828&r2=351829&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/pom.xml (original)
+++ maven/scm/trunk/maven-scm-plugin/pom.xml Fri Dec  2 12:20:57 2005
@@ -56,10 +56,5 @@
       <artifactId>maven-scm-provider-svn</artifactId>
       <version>1.0-beta-2-SNAPSHOT</version>
     </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-      <version>1.0.5-SNAPSHOT</version>
-    </dependency>
   </dependencies>
 </project>

Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java?rev=351829&r1=351828&r2=351829&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
Fri Dec  2 12:20:57 2005
@@ -24,6 +24,10 @@
 import org.codehaus.plexus.util.cli.DefaultConsumer;
 import org.codehaus.plexus.util.cli.StreamConsumer;
 
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.Iterator;
+import java.util.Properties;
 
 /**
  * @goal bootstrap
@@ -61,7 +65,7 @@
 
         try
         {
-            cl.addSystemEnvironment();
+            addSystemEnvironment( cl );
         }
         catch( Exception e )
         {
@@ -100,5 +104,68 @@
              throw new MojoExecutionException( "Can't run goal " + goals, e );
         }
     }
-    
+
+    /**
+     * 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;
+    }
 }



Mime
View raw message