Nick, Yegor - 

Regarding the excelant tasks and issue 50610: from the exchange below I don't 
think it's going to be feasible to put only the excelant tasks in a jar file in 
$ANT_HOME/lib dir.  Additionally, as the comment points out, this makes 
repeatability more difficult for users (because people would have to drop in 
the excelant.jar in to the lib dir of Ant).  Plus the solution to this requires 
another optional jar which puts us further from a clean solution.

I think the easiest thing to do for end users is to require users to define a 
path element with all of the dependencies - the POI jars, the ExcelAnt jar, any 
jars containing FreeRefFunction implementations or other excelant related 
classes. 

Do either of you have opinions about this?  

Thanks,

Jon







----- Forwarded Message ----
From: Peter Reilly <[email protected]>
To: Ant Users List <[email protected]>
Sent: Mon, March 14, 2011 12:27:25 PM
Subject: Re: How to reference <path> elements in custom task

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 <[email protected]> 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 <[email protected]>
> To: Ant Users List <[email protected]>
> 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 <[email protected]> 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
>>
>>
>>
>
>
>

Reply via email to