ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: Is there a way to use a <scriptdef> and place all needed jars in an arbitrary directory?
Date Thu, 07 Dec 2006 21:25:58 GMT
On 12/7/06, Scot P. Floess <floess@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
>
>

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


Mime
View raw message