More info:

It's interesting to note that the output from Ant 1.5.4 shows:
   [script] 
[EMAIL PROTECTED]
   [script] [EMAIL PROTECTED]

...whereas the output from Ant 1.6.2 shows:
   [script] reportSet.toString=fileRealm.properties
   [script] [EMAIL PROTECTED]

Ant 1.5.4 seems to know what type the references are, whereas Ant 1.6.2 
uses "UnknownElement". Is that the problem?


When I run the build.xml from my previous message, the output from Ant 
1.5.4 is:

****** BEGIN ANT 1.5.4 OUTPUT *********

Apache Ant version 1.5.4 compiled on August 12 2003
Buildfile: build.xml
Detected Java version: 1.4 in: C:\Program Files\Java\jdk142_06\jre
Detected OS: Windows 2000
parsing buildfile build.xml with URI = file:M:/.../___test/build.xml
Project base dir set to: M:\...\___test
Build sequence for target `buildWar' is [addWarDynamic, buildWar]
Complete build sequence is [addWarDynamic, buildWar]

addWarDynamic:

   [script] reportSet.getName()=**/*.sh
   [script] 
[EMAIL PROTECTED]
   [script] [EMAIL PROTECTED]
   [script] warTask.getTaskName()=war
   [script] about to addZipfileset()...

buildWar:
   [delete] Deleting: M:\...\___test\deleteMe.war
      [war] Building war: M:\...\___test\deleteMe.war
      [war] adding directory META-INF/
      [war] adding entry META-INF/MANIFEST.MF
      [war] adding directory gfx/
      [war] adding directory gfx/included/
      [war] adding entry gfx/included/blank.gif
...
      [war] adding directory WEB-INF/
      [war] adding directory WEB-INF/classes/
      [war] adding directory WEB-INF/classes/com/
...
      [war] adding directory myStuff/
...
      [war] adding entry WEB-INF/web.xml

BUILD SUCCESSFUL
Total time: 3 seconds

****** END ANT 1.5.4 OUTPUT *********


... and the output from 1.6.2 is:


****** BEGIN ANT 1.6.2 OUTPUT *********

Apache Ant version 1.6.2 compiled on July 16 2004
Buildfile: build.xml
Detected Java version: 1.4 in: C:\Program Files\Java\jdk142_06\jre
Detected OS: Windows 2000
parsing buildfile M:\...\___test\build.xml with URI = 
file:///M:/.../___test/build.xml
Project base dir set to: M:\...\___test
Build sequence for target `buildWar' is [addWarDynamic, buildWar]
Complete build sequence is [addWarDynamic, buildWar, ]

addWarDynamic:
   [script]
   [script] reportSet.getName()=**/*.sh
   [script] reportSet.toString=fileRealm.properties
   [script] [EMAIL PROTECTED]
   [script] warTask.getTaskName()=war
   [script] about to addZipfileset()...

BUILD FAILED
M:\...\___test\build.xml:20: TypeError: undefined is not a function.
        at 
org.apache.tools.ant.util.ScriptRunner.executeScript(ScriptRunner.jav
a:139)
        at 
org.apache.tools.ant.taskdefs.optional.Script.execute(Script.java:60)

        at 
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
        at org.apache.tools.ant.Main.runBuild(Main.java:673)
        at org.apache.tools.ant.Main.startAnt(Main.java:188)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Caused by: TypeError: undefined is not a function.
        at org.mozilla.javascript.NativeGlobal.constructError(Unknown 
Source)
        at org.mozilla.javascript.NativeGlobal.constructError(Unknown 
Source)
        at org.mozilla.javascript.NativeGlobal.typeError1(Unknown Source)
        at org.mozilla.javascript.ScriptRuntime.call(Unknown Source)
        at org.mozilla.javascript.gen.c1.call(Unknown Source)
        at org.mozilla.javascript.gen.c1.exec(Unknown Source)
        at org.mozilla.javascript.Context.evaluateReader(Unknown Source)
        at org.mozilla.javascript.Context.evaluateString(Unknown Source)
        at org.apache.bsf.engines.javascript.JavaScriptEngine.eval(Unknown 
Sourc
e)
        at org.apache.bsf.util.BSFEngineImpl.exec(Unknown Source)
        at org.apache.bsf.BSFManager$6.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.bsf.BSFManager.exec(Unknown Source)
        at 
org.apache.tools.ant.util.ScriptRunner.executeScript(ScriptRunner.jav
a:128)
        ... 11 more
--- Nested Exception ---
TypeError: undefined is not a function.
        at org.mozilla.javascript.NativeGlobal.constructError(Unknown 
Source)
        at org.mozilla.javascript.NativeGlobal.constructError(Unknown 
Source)
        at org.mozilla.javascript.NativeGlobal.typeError1(Unknown Source)
        at org.mozilla.javascript.ScriptRuntime.call(Unknown Source)
        at org.mozilla.javascript.gen.c1.call(Unknown Source)
        at org.mozilla.javascript.gen.c1.exec(Unknown Source)
        at org.mozilla.javascript.Context.evaluateReader(Unknown Source)
        at org.mozilla.javascript.Context.evaluateString(Unknown Source)
        at org.apache.bsf.engines.javascript.JavaScriptEngine.eval(Unknown 
Sourc
e)
        at org.apache.bsf.util.BSFEngineImpl.exec(Unknown Source)
        at org.apache.bsf.BSFManager$6.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.bsf.BSFManager.exec(Unknown Source)
        at 
org.apache.tools.ant.util.ScriptRunner.executeScript(ScriptRunner.jav
a:128)
        at 
org.apache.tools.ant.taskdefs.optional.Script.execute(Script.java:60)

        at 
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
        at org.apache.tools.ant.Main.runBuild(Main.java:673)
        at org.apache.tools.ant.Main.startAnt(Main.java:188)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

Total time: 3 seconds

****** END ANT 1.6.2 OUTPUT *********

[EMAIL PROTECTED] wrote on 06/23/2005 01:56:55 PM:

> 
> I have an Ant 1.5.4 build script that doesn't work in Ant 1.6 (Ant 1.6.2 

> or 1.6.5). It has some embedded JavaScript that is calling the Ant API 
to 
> add a ZipFileSet to the War task.
> 
> What we're trying to do is dynamically add directories to the War task 
at 
> runtime. We decided to use JavaScript to calculate which directories 
need 
> to be added, and then modify the War task via JavaScript before the War 
> task is run. Using the Ant API worked straightforward for us in Ant 
1.5.4.
> 
> Below is an example build.xml file that shows what we are doing. I took 
> out the logic that dynamically builds the directories to include, in 
order 
> to keep the example simple and straightforward. (Obviously, I wouldn't 
use 
> JavaScript to add a static, known path to the War task.)
> 
> If I add the appropriate BSF and Rhino libraries to Ant 1.5.4 and Ant 
> 1.6.2 and run this exact same build file, it works fine in Ant 1.5.4 but 

> throws an exception in Ant 1.6.2. The exception starts out like this:
> 
>        build.xml:20: Type Error: undefined is not a function.
> 
> Pretty vague error message!
> 
> With some testing, I determined that I can't call a number of War task 
> methods from JavaScript in Ant 1.6.2. These include addZipfileset(), 
> addLib(), and addClasses(). Not sure if I'm doing something wrong, or if 

> something changed in Ant 1.6. Any ideas? Thanks!
> 
> The build.xml file below has 2 tasks: buildWar and addWarDynamic. 
> Basically we use JavaScript in addWarDynamic to modify the War task in 
> buildWar before it's run. As I said, this works fine in Ant 1.5.4, but 
> throws that vague exception in Ant 1.6.2.
> 
> Example build.xml file:
> 
> 
> <project name="SelfServiceReporting" default="buildWar" basedir=".">
> 
>         <!-- 

> ================================================================= -->
>         <!-- make WAR file     -->
>         <!-- 

> ================================================================= -->
>         <target name="buildWar" depends="addWarDynamic" >
>         <delete file="deleteMe.war"/>
>         <!-- build a .war file for the application -->
>                 <war destfile="deleteMe.war" webxml="junk-web.xml" 
update=
> "false">
>                         <zipfileset dir="images" prefix="gfx/included" >
>                                 <patternset>
>                                         <include name="**/*" />
>                                 </patternset>
>                         </zipfileset>
>                         <classes dir="classes" />
>                 </war>
>         </target>
> 
>         <target name="addWarDynamic">
>                 <script language="javascript">
>                         <![CDATA[
>         // get ahold of the "war" task in the "buildWar" target
>         var buildWarTasks = buildWar.getTasks();
>         var warTask = null; 
>         for (var i = 0; i < buildWarTasks.length; ++i) {
>             var aTask = buildWarTasks[i];
>             if (aTask.getTaskName() == "war") {
>                 warTask = aTask;
>                 break;
>             }
>         }
> 
>         // create a ZipFileSet to hold just the reports we've specified
>         var reportSet = new 
> Packages.org.apache.tools.ant.types.ZipFileSet();
>         var srcRoot = new java.io.File("includeTest");
>         reportSet.setDir(srcRoot);
>         reportSet.setPrefix("myStuff");
>         reportSet.setIncludes("*");
>         // exclude certain files
>         var xxx = reportSet.createExclude();
>         xxx.setName("**/*.sh");
> 
>         // due to a bug in Ant 1.6.x, we have to set the project 
> explicitly,
>         // otherwise we get a null pointer exception in 
> ZipFileSet.toString()
>         reportSet.setProject(project) 
>         java.lang.System.out.println("\nreportSet.getName()=" + 
> xxx.getName()); 
>         java.lang.System.out.println("reportSet.toString=" + 
> reportSet.toString()); 
>         java.lang.System.out.println("warTask=" + warTask.toString()); 
>         java.lang.System.out.println("warTask.getTaskName()=" + 
> warTask.getTaskName()); 
>         java.lang.System.out.println("about to addZipfileset()..."); 
>         warTask.addZipfileset(reportSet);
>     ]]> </script>
>         </target>
> 
> </project>
> 
> 
> 
> ---------------------------- 
> Important news about email communications: 
> 
> If our business rules identify sensitive information, you will 
> receive a ZixMail Secure Message with a link to view your message. 
> First-time recipients will be asked to create a password before they
> are granted access. To learn more about ZixMail, ZixCorp Secure 
> Email Message Center, and other ZixCorp offerings, please go to 
> http://userawareness.zixcorp.com/secure4/index.php 
> ---------------------------- 
> 
> The information contained in this communication may be confidential,
> and is intended only for the use of the recipient(s) named above.
> If the reader of this message is not the intended recipient, you
> are hereby notified that any dissemination, distribution, or
> copying of this communication, or any of its contents, is strictly
> prohibited. If you have received this communication in error,
> please return it to the sender immediately and delete the original
> message and any copy of it from your computer system. If you have
> any questions concerning this message, please contact the sender.
> 
> Unencrypted, unauthenticated Internet e-mail is inherently insecure.
> Internet messages may be corrupted or incomplete, or may incorrectly
> identify the sender.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------- 
Important news about email communications: 

If our business rules identify sensitive information, you will receive a 
ZixMail Secure Message with a link to view your message. First-time recipients 
will be asked to create a password before they are granted access. To learn 
more about ZixMail, ZixCorp Secure Email Message Center, and other ZixCorp 
offerings, please go to http://userawareness.zixcorp.com/secure4/index.php 
---------------------------- 

The information contained in this communication may be confidential,
and is intended only for the use of the recipient(s) named above.
If the reader of this message is not the intended recipient, you
are hereby notified that any dissemination, distribution, or
copying of this communication, or any of its contents, is strictly
prohibited. If you have received this communication in error,
please return it to the sender immediately and delete the original
message and any copy of it from your computer system. If you have
any questions concerning this message, please contact the sender.

Unencrypted, unauthenticated Internet e-mail is inherently insecure.
Internet messages may be corrupted or incomplete, or may incorrectly
identify the sender.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to