You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Peter Reilly <pe...@gmail.com> on 2006/12/07 23:02:25 UTC

Fwd: Is there a way to use a and place all needed jars in an arbitrary directory?

Opps, did not notice that the e-mail thread was not on dev@ant.apache.org
Peter

---------- Forwarded message ----------
From: Peter Reilly <pe...@gmail.com>
Date: Dec 7, 2006 10:00 PM
Subject: Re: Is there a way to use a <scriptdef> and place all needed
jars in an arbitrary directory?
To: floess@mindspring.com


On 12/7/06, Scot P. Floess <fl...@mindspring.com> wrote:
> Peter:
>
> Thanks for the reply...
>
> I am not specifically married to beanshell...  So (forgive my stupidity)
> - the markup you mention (like the classpath element in scriptdef) - is
> that part of ant 1.6.5?

Yes and no, it is in ant 1.6.5, *but* it is ignored.
Ant 1.7.0 (but not rc1) now uses the attributes and elements.

>
> You also mention javascript being built in...which version of the jdk?

Ant 1.7.0 allows the use of the javax.scripting engine manager that
is part of JDK6.
Ant will use bsf if it is in the project classloader and if not, Ant will
attempt to use the javax scripting.
One can also force the usage of javax scripting by using the
new attribute  """ manager='javax' """

This means that ant 1.7.0 will be able to use the javascript
language that is included in JDK6 **without** any extra jar
files.

Peter

> I tried using language="javascript" but unless I had js.jar and bsf.jar
> in $ANT_HOME/lib...I didn't have any luck...
>
> Thanks!
>
> Scot
>
> Peter Reilly wrote:
> > On 12/7/06, Scot P. Floess <fl...@mindspring.com> wrote:
> >> I am trying to define an arbitrary directory to hold all jar files I
> >> need in a <scriptdef> and "somehow" force ant to use that directory (and
> >> its contents) as part of the classpath...
> >>
> >> I know I can use -lib option for ant, but I am hoping there is something
> >> I can do inside my ant script.  I was able to include the ant-contrib
> >> package programatically using:
> >>
> >> <taskdef classpath = "/foo/bar/ant-contrib.jar"  resource =
> >> "net/sf/antcontrib/antlib.xml"/>
> >>
> >> I'm hoping there is a similar mechanism I am missing.
> >>
> >> The script language I am trying to use is beanshell.  For various
> >> reasons (long story) I want to do this inside an ant script if
> >> possible.  I do know I can also put the jars in $ANT_HOME/lib - again
> >> I'm not wanting to do that...
> >>
> >> Thanks ahead of time...
> >
> > This has (nearly) already been done.
> >
> > In the lastest nightly build
> > (http://people.apache.org/builds/ant/nightly/)
> > the classpath attributes/nested elements from <scriptdef/> has been
> > linked to the
> > bsf/jsr classloader so the following now works:
> >
> >    <scriptdef name="b1" language="beanshell" loaderref="beanshell">
> >      <attribute name="a"/>
> >      <classpath path="${user.home}/.ant/lib/x/bsh-1.3b1.jar"/>
> >      self.log("attribute a is " + attributes.get("a"));
> >    </scriptdef>
> >
> >    <scriptdef name="b2" language="beanshell" loaderref="beanshell">
> >      <attribute name="a"/>
> >      self.log("attribute a is " + attributes.get("a"));
> >    </scriptdef>
> >
> >    <b1 a="this is an 'a'"/>
> >    <b2 a="this is an 'a' for b2"/>
> >
> > However there are some shortcomings due to classloading issues:
> >
> >  * the bsf.jar must still be in the project classpath (i.e. in
> > $ANT_HOME/lib
> >    or ~/.ant/lib or in a -lib command line dir).
> >  * any language that have engines in bsf.jar also have to be in the
> >    project classpath (these are javascript, jython, jacl, netrexx and
> > xslt)
> >
> > I have a fix for this, however as it is messes with classloading, I am
> > hesitant to commit it for ant 1.7.0.
> >
> > On can use JDK scripting without these issues, except that javascript
> > is built-in to the JDK and one cannot easily change the javascript
> > implementation.
> >
> > Peter
> >
> >
> >>
> >> Scot
> >>
> >> --
> >> Scot P. Floess
> >> 27 Lake Royale
> >> Louisburg, NC  27549
> >>
> >> 252-478-8087 (Home)
> >> 919-754-4592 (Work)
> >>
> >> Chief Architect JPlate  http://sourceforge.net/projects/jplate
> >> Chief Architect JavaPIM http://sourceforge.net/projects/javapim
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >> For additional commands, e-mail: user-help@ant.apache.org
> >>
> >>
> >
>
> --
> Scot P. Floess
> 27 Lake Royale
> Louisburg, NC  27549
>
> 252-478-8087 (Home)
> 919-754-4592 (Work)
>
> Chief Architect JPlate  http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM http://sourceforge.net/projects/javapim
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org