It might be simpler, and probably less problematic, to create a new ant
task and use it instead of the javascript. I've had nothing but problems
with using javascript, the least of which is getting all the
dependencies correctly installed.

Try this:

********* MyProperty.java ************
package <your package path>;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;

public class MyProperty extends Task {
   private String data = null;

   public String getValue() {
      return this.data;
   }

   public String getName() {
      return this.name;
   }

   public void setValue(String value) {
      this.data = value;
   }

   public void setName(String newname) {
      this.name = newname;
   }

   public void execute() throws BuildException {
      try {
         java.io.File file = new java.io.File(getValue());
      }
      catch (java.io.IOException exc) {
         throw new BuildException(exc);
      }
      getProject().setNewProperty(getName(), file.getName());
   }
}


And in your ant script, use the following:

   <taskdef name="myProperty" classname="<your package
path>/MyProperty"/>

   <myproperty name="try_it" value="${basedir}"/>


That should do it! Just replace "<your package path>" with the package
path that you use, and everything's set...


On Thu, 2005-01-27 at 07:35 -0800, michael sorens wrote:
> I tried your JavaScript example; after adding bsf.jar and js.jar to my 
> ant/lib directory, I still had this runtime error:
> 
> java.lang.NoSuchMethodError: 
> org.mozilla.javascript.Context.getDebuggableEngine()Lorg/mozilla/javascript/debug/DebuggableEngine;
> 
> This was the piece of JavaScript in question:
>               <script language="javascript"> <![CDATA[
>                       var data = myProject.getProperty("try_it");
>                       var result = data;
>                       myProject.setProperty("try_it",result);
>               ]]> </script>
> 
> Is there another library I am missing...?
> 
> 
> On Thu, 27 Jan 2005 07:52:51 +0100, <[EMAIL PROTECTED]> wrote:
> 
> > oh, you can use other languages as well, python, groovy, bsh, ...
> > it has to be supported by then BeanScriptingFramework.
> >
> > Jan
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Nat Gross [mailto:[EMAIL PROTECTED]
> >> Gesendet am: Mittwoch, 26. Januar 2005 16:44
> >> An: Ant Users List
> >> Betreff: Re: AW: Last element of current directory name.
> >>
> >> Hey! I didn't know you can use Javascript in Ant, (not that I know
> >> Javascript well, but still..) it's cool.
> >> Thanks
> >> -nat
> >> ps. oh, thats what Matt meant by 'using a script'.
> >>
> >> [EMAIL PROTECTED] wrote:
> >>
> >> >The upcase part can be done with <script>.
> >> >See http://marc.theaimsgroup.com/?l=ant-user&m=104486168926737&w=2
> >> >
> >> >Jan
> >> >
> >> >
> >> >
> >> >>-----Ursprüngliche Nachricht-----
> >> >>Von: Nat Gross [mailto:[EMAIL PROTECTED]
> >> >>Gesendet am: Dienstag, 25. Januar 2005 23:20
> >> >>An: Ant Users List
> >> >>Betreff: Re: Last element of current directory name.
> >> >>
> >> >>Matt Benson wrote:
> >> >>
> >> >>
> >> >>
> >> >>>--- Nat Gross <[EMAIL PROTECTED]>
> >> >>>wrote:
> >> >>>
> >> >>>
> >> >>>
> >> >>>
> >> >>>
> >> >>>>How do I get just the last element of the current
> >> >>>>directory.
> >> >>>>Suppose basedir = dira/dirb/dirc. (Or any path for
> >> >>>>that matter.)
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>Whatever is "the current directory"--${user.dir}?
> >> >>>${basedir}?... You can use the basename task to get
> >> >>>the last element of a path.
> >> >>>
> >> >>>
> >> >>>
> >> >>>
> >> >>I have used basename for filenames without realizing that it
> >> >>also works
> >> >>for directory names.
> >> >>Thanks.
> >> >>
> >> >>
> >> >>
> >> >>>>I need a property to = "Dirc". (1st character
> >> >>>>uppercased, if possible.)
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>Changing case is more problematical.  I would either
> >> >>>try ant-contrib's propertyregex (though I'm not good
> >> >>>with changing case in regular expressions either),
> >> >>>write something in Java, or deal with the case as-is.
> >> >>>Others might use a script.
> >> >>>
> >> >>>
> >> >>>
> >> >>>
> >> >>Thanks. I need to explore regex, I guess.
> >> >>
> >> >>
> >> >>
> >> >>>>For the pros out there it should be 123, but for
> >> >>>>me... forget it!
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>HTH,
> >> >>>Matt
> >> >>>
> >> >>>
> >> >>>
> >> >>>
> >> >>>>Thanks
> >> >>>>-nat
> >> >>>>
> >> >>>>
> >> >>>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
-- 
David A. Bartmess
Software Configuration Manager / Sr. Software Developer
eDingo Enterprises
http://edingo.net
_________________________________________________________________
jSyncManager Development Team (http://www.jsyncmanager.org)
jSyncManager Email List
(https://lists.sourceforge.net/lists/listinfo/jsyncmanager-devel)
 
 But one should not forget that money can buy a bed but not sleep, 
 finery but not beauty, a house but not a home, 
 medicine but not health, luxuries but not culture, 
 sex but not love, and amusements but not happiness.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to