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: Libraries for optional tasks defined from within build.xml
Date Sat, 15 Dec 2007 21:48:32 GMT
Ant 1.7.1 will be released soon.
And will fix this particular included optional task problem for the script task.

In the mean time, you can use the
antclassloader task from
http://enitsys.sourceforge.net/ant-classloadertask/

I use it like this:
--- ant-classloader.xml
<project>
  <!-- Set up the ant-classloader task. -->
  <typedef uri="antlib:net.jtools.classloadertask"
           resource="net/jtools/classloadertask/antlib.xml">
    <classpath>
      <fileset dir="${commons.dir}/lib/ant/ant-classloader"
               includes="*.jar"/>
    </classpath>
  </typedef>
</project>

-- beanshell.xml
<project name="beanshell"
         xmlns:cl="antlib:net.jtools.classloadertask">

  <!-- Enable beanshell
       With ant 1.7.0 the only way to do this
       within a project is to use cl:classloader
    -->
  <cl:classloader loader="project">
    <classpath>
      <fileset dir="${commons.dir}/lib/main/commons-logging"
               includes="*.jar"/>
      <fileset dir="${commons.dir}/lib/ant/bsf"
               includes="*.jar"/>
      <fileset dir="${commons.dir}/lib/ant/beanshell"
               includes="*.jar"/>
    </classpath>
  </cl:classloader>
</target>

--- setup.xml
<target name="ant.setup">
   <dirname property="ant.setup.dir" file="${ant.file.ant.setup}"/>
   <property name="commons.dir"
            location="${ant.setup.dir}/../.."/>
...
  <import file="ant-classloader.xml"/>
  <import file="beanshell.xml"/>
...
</target>


On Dec 15, 2007 5:22 PM, Scot P. Floess <floess@mindspring.com> wrote:
> If memory serves, there is an issue with Ant 1.7 and specifying a lib
> dir...  Ant 1.7.1 fixes the problem...  I assume 1.7.1+ fixes it too :)
> I had to build that from source...
>
> Then all you should have to do is use the <classpath> child element of
> <scriptdef>.  For example:
>
>     <scriptdef
>         name        = "compute-locale"
>         language    = "beanshell"
>         description = "Sets the locale of the current JVM."
>         uri         = "http://jplate.sourceforge.net/environment" >
>
>         <classpath>
>             <path  refid = "jplate.LIB_PATH_REF"/>
>         </classpath>
>
>         <attribute  name = "property"/>
>
>         <![CDATA[
>             project.setProperty ( attributes.get ( "property" ),
> java.util.Locale.getDefault ().toString () );
>         ]]>
>     </scriptdef>
>
>
>
>
> Klaus Malorny wrote:
> >
> > Hi,
> >
> > sorry if this is a newbie question, but I did not find an answer in
> > docs, faqs, google etc.
> >
> > I'm using Ant 1.7, and I would like to use the <script> and
> > <scriptdef> tasks to solve a particular problem. Since these are
> > optional tasks, they need various libraries when run under Java5. So
> > far, I was able to run a little "hello world" script. But what really
> > bothers me is that I either have to copy the libraries into my ant
> > installation or have to use the "-lib" option for each of the three
> > libraries. As I want to distribute the project and as it shall be
> > platform independent, writing a shell script or a Windows batch file
> > is not really the solution I imagine. I would prefer to reference the
> > libraries from within the build.xml file, like it is done with
> > <typedef>/<taskdef> for external tasks. Trying to use the <typedef>
> > mechanism for this purpose failed; An attempt to override the "script"
> > task results in an error "Trying to override old definition of task
> > script"; choosing a different name reveals that the libraries are not
> > found despite being referenced (maybe ant uses a different class
> > loader for that purpose).
> >
> >    <path id="lib.path">
> >       <fileset dir="lib" includes="**/*.jar"/>
> >     </path>
> >
> >     <typedef
> >       name="scriptx"
> >       classname="org.apache.tools.ant.taskdefs.optional.Script"
> >       classpathref="lib.path"/>
> >
> > Any help is highly appreciated.
> >
> > Klaus
> >
> >
> > ---------------------------------------------------------------------
> > 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
> QA Engineer OpenQabal    http://openqabal.dev.java.net
>
>
>
> ---------------------------------------------------------------------
> 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