You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Diane Holt <ho...@yahoo.com> on 2000/10/02 10:30:02 UTC
"undefined is not a function" error running
I get an error at the <script> task when I run this target (it all works
as expected up until it gets to there):
<target name="genNewBuildnum" depends="checkForOld"
if="haveOldBuildnum">
<rename src="buildnum.properties" dest="oldBuildnum.properties"/>
<replace token="buildnum" value="oldBuildnum"
file="oldBuildnum.properties"/>
<antcall target="buildnum"/>
<property file="buildnum.properties"/>
<property file="oldBuildnum.properties"/>
<script language="javascript"> <![CDATA[
var newnum = parseInt(nightly.getProperty('buildnum'));
var oldnum = parseInt(nightly.getProperty('oldBuildnum'));
if ( newnum == oldnum ) nightly.setProperty('nochgs', true);
]]>
</script>
<antcall target="notifyNochgs"/>
</target>
I ran the <script> task that Nico included in a mail a little while back
that does an increment on a number, and that runs fine -- and I thought
I'd basically done the same sort of thing in this one, but for some reason
it doesn't like what this one does. Any pointers as to where I've gone
wrong muchly appreciated. Thanks, Diane.
Here's the output:
Buildfile: nightly.xml
checkForOld:
genNewBuildnum:
[replace] Replacing buildnum --> oldBuildnum
setBuildnum:
Generating build number...
checkBuildnum:
buildnum:
Build number is 16580
BUILD FAILED
nightly.xml:377: TypeError: undefined is not a function.
TypeError: undefined is not a function.
at
org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:496)
at
org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:467)
at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1203)
at org.mozilla.javascript.gen.c1.call(<ANT>:1)
at org.mozilla.javascript.gen.c1.exec(<ANT>)
at org.mozilla.javascript.Context.evaluateReader(Context.java:741)
at org.mozilla.javascript.Context.evaluateString(Context.java:705)
at
com.ibm.bsf.engines.javascript.JavaScriptEngine.eval(JavaScriptEngine.java:82)
at com.ibm.bsf.util.BSFEngineImpl.exec(BSFEngineImpl.java:112)
at com.ibm.bsf.BSFManager.exec(BSFManager.java:482)
at
org.apache.tools.ant.taskdefs.optional.Script.execute(Script.java:110)
at org.apache.tools.ant.Target.execute(Target.java:142)
at org.apache.tools.ant.Project.runTarget(Project.java:807)
at org.apache.tools.ant.Project.executeTarget(Project.java:532)
at org.apache.tools.ant.Project.executeTargets(Project.java:506)
at org.apache.tools.ant.Main.runBuild(Main.java:400)
at org.apache.tools.ant.Main.main(Main.java:130)
Total time: 5 seconds
TypeError: undefined is not a function.
=====
(holtdl@yahoo.com)
__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/
Re: "undefined is not a function" error running
Posted by Nico Seessle <ni...@seessle.de>.
----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>
To: <an...@jakarta.apache.org>
Sent: Monday, October 02, 2000 10:30 AM
Subject: "undefined is not a function" error running <script>
> I get an error at the <script> task when I run this target (it all works
> as expected up until it gets to there):
>
> <target name="genNewBuildnum" depends="checkForOld"
> if="haveOldBuildnum">
> <rename src="buildnum.properties" dest="oldBuildnum.properties"/>
> <replace token="buildnum" value="oldBuildnum"
> file="oldBuildnum.properties"/>
> <antcall target="buildnum"/>
> <property file="buildnum.properties"/>
> <property file="oldBuildnum.properties"/>
> <script language="javascript"> <![CDATA[
> var newnum = parseInt(nightly.getProperty('buildnum'));
> var oldnum = parseInt(nightly.getProperty('oldBuildnum'));
> if ( newnum == oldnum ) nightly.setProperty('nochgs', true);
> ]]>
> </script>
> <antcall target="notifyNochgs"/>
> </target>
>
Are you sure 'nightly' refers to a project (i.e. your buildfile states
<project name="nightly" ..) ?
Give the following a try (works for me)
<?xml version="1.0"?>
<project name="nightly" default="default" basedir=".">
<target name="default">
<property name="buildnum" value="100"/>
<property id="foo" name="oldBuildnum" value="100"/>
<script language="javascript"> <![CDATA[
var newnum = parseInt(nightly.getProperty('buildnum'));
var oldnum = parseInt(nightly.getProperty('oldBuildnum'));
if ( newnum == oldnum ) nightly.setProperty('nochgs', true);
]]>
</script>
<echo message="${buildnum} / ${oldBuildnum} / ${nochgs}"/>
</target>
</project>
Does it work for you? It gives me the same error if I replace "nighlty" in
the first line of the script with "foo" which for sure has no method
"getProperty".