summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-17 23:22:39 +0200
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-17 23:22:39 +0200
commitd84b1eb2dc10f76e81a2c47399fd3192701408f9 (patch)
tree867df646e3c5425168a99d1aee05b5a3f859dc06
parenta1d36351fdbb686f7277d90dd7f58b6cab1e453a (diff)
downloadmaven-nar-plugin-d84b1eb2dc10f76e81a2c47399fd3192701408f9.tar.gz
maven-nar-plugin-d84b1eb2dc10f76e81a2c47399fd3192701408f9.tar.bz2
maven-nar-plugin-d84b1eb2dc10f76e81a2c47399fd3192701408f9.tar.xz
maven-nar-plugin-d84b1eb2dc10f76e81a2c47399fd3192701408f9.zip
More fix for NAR-25; System env passed when not given in NarUtil
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarUtil.java36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
index c65f3e6..4aad1fe 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
@@ -28,6 +28,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Vector;
import java.util.regex.Pattern;
import org.apache.bcel.classfile.ClassFormatException;
@@ -39,6 +40,7 @@ import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.PropertyUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
/**
@@ -461,10 +463,42 @@ public class NarUtil
extends Commandline
{
// Override this method to prevent addition (and obstruction) of system env variables
+ // but (for now) add them when no envVars are given.
+
+ // NOTE and FIXME: we need to properly put system variables in there
+ // mixed (overridden) by our own.
public String[] getEnvironmentVariables()
throws CommandLineException
{
- return (String[]) envVars.toArray( new String[envVars.size()] );
+ if ( envVars.size() == 0 )
+ {
+ try
+ {
+ Vector systemEnvVars = getSystemEnvironment();
+ return (String[]) systemEnvVars.toArray( new String[systemEnvVars.size()] );
+ }
+ catch ( IOException e )
+ {
+ throw new CommandLineException( "Error setting up environmental variables", e );
+ }
+ }
+ else
+ {
+ return (String[]) envVars.toArray( new String[envVars.size()] );
+ }
+ }
+
+ private Vector getSystemEnvironment() throws IOException {
+ Properties envVars = CommandLineUtils.getSystemEnvVars();
+ Vector systemEnvVars = new Vector(envVars.size());
+
+ for ( Iterator i = envVars.keySet().iterator(); i.hasNext(); )
+ {
+ String key = (String) i.next();
+ systemEnvVars.add( key + "=" + envVars.getProperty( key ) );
+ }
+
+ return systemEnvVars;
}
}