You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/03/16 15:54:36 UTC

svn commit: r518992 - in /maven/plugins/trunk/maven-assembly-plugin: ./ src/main/java/org/apache/maven/plugin/assembly/interpolation/ src/main/java/org/apache/maven/plugin/assembly/utils/

Author: jdcasey
Date: Fri Mar 16 07:54:35 2007
New Revision: 518992

URL: http://svn.apache.org/viewvc?view=rev&rev=518992
Log:
Adding utility from plexus-utils 1.4 so I can revert the dep on plexus-utils to 1.1 for maven 2.0.x compat.

Added:
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/CommandLineUtils.java   (with props)
Modified:
    maven/plugins/trunk/maven-assembly-plugin/pom.xml
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java

Modified: maven/plugins/trunk/maven-assembly-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/pom.xml?view=diff&rev=518992&r1=518991&r2=518992
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-assembly-plugin/pom.xml Fri Mar 16 07:54:35 2007
@@ -308,11 +308,16 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>1.4-alpha-1</version>
+      <version>1.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact</artifactId>
+      <version>2.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact-manager</artifactId>
       <version>2.0.4</version>
     </dependency>
     <dependency>

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java?view=diff&rev=518992&r1=518991&r2=518992
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java Fri Mar 16 07:54:35 2007
@@ -19,12 +19,12 @@
 import org.apache.maven.plugin.assembly.model.Assembly;
 import org.apache.maven.plugin.assembly.model.io.xpp3.AssemblyXpp3Reader;
 import org.apache.maven.plugin.assembly.model.io.xpp3.AssemblyXpp3Writer;
+import org.apache.maven.plugin.assembly.utils.CommandLineUtils;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
 import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
@@ -92,16 +92,7 @@
     public AssemblyInterpolator()
         throws IOException
     {
-        // FIXME: Once Maven (all supported versions in the wild) are using plexus-utils >= 1.3, 
-        // we should remove this.
-        try
-        {
-            envars = CommandLineUtils.getSystemEnvVars( false );
-        }
-        catch( NoSuchMethodError e )
-        {
-            envars = CommandLineUtils.getSystemEnvVars();
-        }
+        envars = CommandLineUtils.getSystemEnvVars( false );
     }
 
     public Assembly interpolate( Assembly assembly, MavenProject project, Map context )

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java?view=diff&rev=518992&r1=518991&r2=518992
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtils.java Fri Mar 16 07:54:35 2007
@@ -7,7 +7,6 @@
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
 import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 
 import java.io.BufferedReader;

Added: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/CommandLineUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/CommandLineUtils.java?view=auto&rev=518992
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/CommandLineUtils.java (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/CommandLineUtils.java Fri Mar 16 07:54:35 2007
@@ -0,0 +1,109 @@
+package org.apache.maven.plugin.assembly.utils;
+
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l </a>
+ * @version $Id$
+ */
+public abstract class CommandLineUtils
+{
+    /**
+     * Return the shell environment variables. If <code>caseSensitive == true</code>, then envar
+     * keys will all be upper-case.
+     *
+     * @param caseSensitive Whether environment variable keys should be treated case-sensitively.
+     * @return Properties object of (possibly modified) envar keys mapped to their values.
+     * @throws IOException
+     */
+    public static Properties getSystemEnvVars( boolean caseSensitive )
+        throws IOException
+    {
+        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;
+
+        String lastKey = null;
+        String lastVal = null;
+
+        while ( ( line = br.readLine() ) != null )
+        {
+            int idx = line.indexOf( '=' );
+
+            if ( idx > 1 )
+            {
+                lastKey = line.substring( 0, idx );
+
+                if ( !caseSensitive )
+                {
+                    lastKey = lastKey.toUpperCase();
+                }
+
+                lastVal = line.substring( idx + 1 );
+
+                envVars.setProperty( lastKey, lastVal );
+            }
+            else if ( lastKey != null )
+            {
+                lastVal += "\n" + line;
+
+                envVars.setProperty( lastKey, lastVal );
+            }
+        }
+
+        return envVars;
+    }
+
+}

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/CommandLineUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/CommandLineUtils.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"