ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bickford, Mark" <>
Subject SCRIPTDEF using Java: how to access attributes?
Date Wed, 28 Jul 2010 14:36:16 GMT

I'm a newbie to the list, but not to Ant; this is the first time I
haven't been able to find an answer on my own.  I've tried everything I
can think of to get this to work, but so far all have failed.  I am
writing a scriptdef using Java as the language, but I can't find how to
access any of the predefined beans like attributes and elements.  This
much works:

<project name="javaScriptingTest" default="script.test">

   <scriptdef name="javatest" manager="javax" language="java">
      <attribute name="teststring"/>
      class javatest
      	public static void main(String[] args) {
      		System.out.println("Number of args: "+args.length);
      		//System.out.println("The list is: "+
      		System.out.println("Hello world!");
   <target name="script.test">
      <javatest teststring="Success!!!  Can you believe it???"/>

The command-line I am using (on WinXP) is 
> ant -lib C:\work\lib\java-script-engine\ -f mini-build.xml

(java-script-engine holds the java-engine.jar from ). 

When I run it as I have things above, it works (shows 0 args and the
"Hello world" message).  When I uncomment any of the println's shown, I
get (e.g.):

 [javatest] mfm:///$ cannot find symbol
 [javatest] symbol  : variable attributes
 [javatest] location: class javatest

I realize that println of attributes wouldn't give anything really
meaningful, but it would prove the object exists.  How can we access
those beans when Java is the script language?  Am I missing an import,
or is there something else that needs to happen?

Java and ant info:
C:\Subversion>java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

C:\Subversion>ant -version
Apache Ant version 1.7.0 compiled on December 13 2006

Mark Bickford 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message