git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278221 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -179,6 +179,8 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
| throw new BuildException("Could not find " + classname + "." | throw new BuildException("Could not find " + classname + "." | ||||
| + " Make sure you have it in your" | + " Make sure you have it in your" | ||||
| + " classpath"); | + " classpath"); | ||||
| } catch (BuildException e) { | |||||
| throw e; | |||||
| } catch (SecurityException e) { | } catch (SecurityException e) { | ||||
| throw e; | throw e; | ||||
| } catch (ThreadDeath e) { | } catch (ThreadDeath e) { | ||||
| @@ -141,6 +141,7 @@ public class CommandlineJava implements Cloneable { | |||||
| p.putAll(mergePropertySets()); | p.putAll(mergePropertySets()); | ||||
| for (Enumeration e = variables.elements(); e.hasMoreElements();) { | for (Enumeration e = variables.elements(); e.hasMoreElements();) { | ||||
| Environment.Variable v = (Environment.Variable) e.nextElement(); | Environment.Variable v = (Environment.Variable) e.nextElement(); | ||||
| v.validate(); | |||||
| p.put(v.getKey(), v.getValue()); | p.put(v.getKey(), v.getValue()); | ||||
| } | } | ||||
| System.setProperties(p); | System.setProperties(p); | ||||
| @@ -109,13 +109,21 @@ public class Environment { | |||||
| * @throws BuildException if key or value are unassigned | * @throws BuildException if key or value are unassigned | ||||
| */ | */ | ||||
| public String getContent() throws BuildException { | public String getContent() throws BuildException { | ||||
| validate(); | |||||
| StringBuffer sb = new StringBuffer(key.trim()); | |||||
| sb.append("=").append(value.trim()); | |||||
| return sb.toString(); | |||||
| } | |||||
| /** | |||||
| * checks whether all required attributes have been specified. | |||||
| * @throws BuildException if key or value are unassigned | |||||
| */ | |||||
| public void validate() { | |||||
| if (key == null || value == null) { | if (key == null || value == null) { | ||||
| throw new BuildException("key and value must be specified " | throw new BuildException("key and value must be specified " | ||||
| + "for environment variables."); | + "for environment variables."); | ||||
| } | } | ||||
| StringBuffer sb = new StringBuffer(key.trim()); | |||||
| sb.append("=").append(value.trim()); | |||||
| return sb.toString(); | |||||
| } | } | ||||
| } | } | ||||