You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bret Marzolf <ma...@excite.com> on 2003/12/26 18:53:16 UTC
Environment.Variable in dynamic exec task within the script task
I'm trying to recreate the following in the build.xml using the <script> task and javascript: <exec executable="${exe_location}" dir="${exe_dir}"> <env key="${env_var_key}" value="${env_var_value}"/> <arg value="${arg1}"/> <arg value="${arg2}"/></exec> Here's what I tried to do: <target name="testme"><script language="javascript"> <![CDATA[ execTask = MyProject.createTask("exec"); MyTarget.addTask(execTask); execTask.setExecutable( MyProject.getProperty("exe_location")); execTask.setDir( new java.io.File(MyProject.getProperty("exe_dir"))); // simulate <env> child element of <exec> task // ---------------- // Try #1: envVar = new org.apache.tools.ant.types.Environment.Variable; // Try #2: envVar = BatchAppTemplate.createDataType("Environment.Variable"); // ---------------- envVar.setKey("SampleKey1"); envVar.setValue("SampleValue1"); execTask.addEnv(envVar); ]]> </script></target> Try #1, results in: file:c:/build.xml:253: ReferenceError: "org" is not defined. (<ANT>; line 10) Try #2, results in: file:c:/build.xml:253: TypeError: Cannot convert null to an object. (<ANT>; line 14) I can understand why neither try works. So, what is the proper way to do this? What am I doing wrong?
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!