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: How to reference <path> elements in custom task
Date Mon, 14 Mar 2011 18:27:25 GMT
There is nothing in ant that would do that (it was
planned at one stage).

In any case, it is not good practice to place
any extra jars into $ANT_HOME/lib, as this
makes reproducible builds difficult.

The ant-classloader task
http://enitsys.sourceforge.net/ant-classloadertask/ (written by
Rainer Noack) will
solve your problem, but at the "cost" of an extra jar.

Peter


On Mon, Mar 14, 2011 at 5:56 PM, Jon Svede <jsvede@yahoo.com> wrote:
> Wolfgang,
>
> Thanks for the reply.
>
> So originally I had my tasks working by defining a <path> entry that included my
> tasks and their dependencies. This worked fine without me having to do anything
> other than define <taskdef> entries in my build file.
>
> Then I was asked to make it so that my tasks could be put into the $ANT_HOME/lib
> dir but be able to define the dependencies in the build.xml.  This did not work.
> My tasks would be found, but the dependencies were not. I am guessing it's
> parentage thing: my classes are higher in the classloader parentage than it's
> dependencies.  I then tested this by adding all the classes my tasks depend on
> to my jar file in the $ANT_HOME/lib - that worked too, but it failed when I
> added classes that implement my interfaces.  In this case,  I think it is again
> some sort of parentage issue.
>
> My specific use case is as follows:
>
> I have a set of ant tasks that depend on Apache POI for spreadsheet testing.  I
> do not want to package the POI classes into my jar.  Secondarily, my jar file of
> tasks defines an interface for users to implement; those implementations can be
> given to my ant tasks for execution.
>
> I thought, perhaps incorrectly, that if my tasks could access the path element
> and then "inject" those references into the execution environment I'd be able to
> move forward.  Am I mistaken?
>
> Most of what I found either didn't apply or I didn't understand.  What I did
> find outside of that didn't seem to help.  I found a reference to a Classloader
> task written by Peter Reilly but this is again an external task. I have been
> under the assumption that I would be able to resolve my issue with the core ant
> tasks rather than requiring additional non-core jars.
>
> Does that give you more insight into my problem?  It's entirely possible that
> what I want to do isn't feasible but that is what I am basically asking: can I
> do this as I've described or is there another, more preferable way to accomplish
> this?
>
> Sincerely,
>
> Jon
>
>
>
>
> ________________________________
> From: wolfgang haefelinger <whaefelinger@gmail.com>
> To: Ant Users List <user@ant.apache.org>
> Sent: Mon, March 14, 2011 11:21:57 AM
> Subject: Re: How to reference <path> elements in custom task
>
> Jon,
>
>>    <someCustomTask classpathref="some.path"/>
>
> This attribute of yours, "classpathref" is not a standard attribute:
> http://ant.apache.org/manual/Tasks/common.html
>
>> I've been searching for examples or forum posts related to this but everything
>> I've found  isn't working.
>
> How about sharing what you've found and what exactly is not working?
>
> // Wolfgang
>
> On Mon, Mar 14, 2011 at 5:50 PM, Jon Svede <jsvede@yahoo.com> wrote:
>> Hi,
>>
>> I have a set of custom tasks that need to be able to load  dependencies from
>> <path> element. In my case my tasks may be  defined in <taskdef> declarations
>>or
>> via adding the jar file to  the $ANT_HOME/lib dir.
>>
>> This is what I want to have in the build.xml file:
>>
>>
>> <path name="some.path">
>>    <pathelement location="some/local/dir/my.jar"/>
>> </path>
>>
>> <target name="mytarget">
>>    <someCustomTask classpathref="some.path"/>
>> </target>
>>
>>
>> In this example the task someCustomTask needs to be able to have classes from
>> the path 'some.path' to be able to execute.
>>
>> I've been searching for examples or forum posts related to this but everything
>> I've found  isn't working.  Does anyone have a good explanation of this is
> done
>> or are there some docs on this?
>>
>> Thanks in advance,
>>
>> Jon
>>
>>
>>
>
>
>
> --
> Wolfgang Häfelinger
> häfelinger IT - Applied Software Architecture
> http://www.haefelinger.it
> +31 648 27 61 59
>
> ---------------------------------------------------------------------
> 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