You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Andreas Krey <a....@gmx.de> on 2010/10/31 16:53:56 UTC

Getting task class *only* from specified path

Question: I need a user task; I do load it via explicit class path in
the taskdef. Unfortunately I need to use that version, but users may
have older ones in their .ant/lib. How can I keep ant (1.7) from
loading that version?

Andreas

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


Re: UNS: Re: Getting task class *only* from specified path

Posted by Andreas Krey <a....@gmx.de>.
On Mon, 01 Nov 2010 12:23:48 +0000, David Weintraub wrote:
> When you use a <taskdef>, you can specify the classpath to use to
> point to the jarfile. ut the jarfile used by <taskdef> inside your
> project, and then set classpath to load that jarfile.

This is what I do (and what I said to do). Unfortunately, ant seems *not*
to look there *first*; instead it will happily load older versions of
those classes that are in $HOME/.ant/lib.

I want to avoid that.

Andreas

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


Re: Getting task class *only* from specified path

Posted by David Weintraub <qa...@gmail.com>.
On Mon, Nov 1, 2010 at 1:07 PM, Peter Reilly
<pe...@gmail.com> wrote:
> That will not work.
> The jars in $ant.home/lib or ~/.ant/lib will
> be in front in the classloader.

That's true even if I specify the exact jarfile I want to use in my
classpath? I never realized that.

What is the purpose of specifying a classpath in a taskdef if Ant's
going to ignore it anyway?

-- 
David Weintraub
qazwart@gmail.com

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


Re: Getting task class *only* from specified path

Posted by Peter Reilly <pe...@gmail.com>.
You may be able to use <classloader> from

http://enitsys.sourceforge.net/ant-classloadertask/

but with the same class in two places in the classpath,
you will have problems.

Peter




On Mon, Nov 1, 2010 at 11:46 PM, Peter Reilly
<pe...@gmail.com> wrote:
> It would be good to understand one word in three of that ;-)
> Peter
>
>
> On Mon, Nov 1, 2010 at 9:18 PM, Stephen Connolly
> <st...@gmail.com> wrote:
>> You could shade your ant task using a shading tool, eg maven-shade-plugin
>> then it would be in a different package and depend on classes in a different
>> package also (there may be non-maven shading tools for the maven averse ;-)
>> )
>>
>> On 1 Nov 2010 17:07, "Peter Reilly" <pe...@gmail.com> wrote:
>>
>> That will not work.
>> The jars in $ant.home/lib or ~/.ant/lib will
>> be in front in the classloader.
>>
>> Peter
>>
>>
>>
>> On Mon, Nov 1, 2010 at 4:23 PM, David Weintraub <qa...@gmail.com> wrote:
>>> When you use a <taskd...
>>
>

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


Re: Getting task class *only* from specified path

Posted by Stephen Connolly <st...@gmail.com>.
The maven-shade-plugin (yes, yes, peter, I know it's maven and this is the
ANT list) is used to take jar files and reprocess them. You can relocate
packages, as well as mask class names. The main use-cases are:

1. Bundling your dependencies to produce an uber jar which will be safe in
the presence of other versions of its dependencies. Eg what is done in
maven-ant-tasks; and animalsniffer-ant-tasks where I shaded ASM so that
another version will not cause class loader issues

2. Hiding the implementation classes of an API by moving the non-contract to
a random package name every build, thus preventing people relying on private
classes that haber to be public (OSGi removes the need for this if you have
an OSGi container handy)

Hope that helps.

- Stephen

P.S. Books

On 1 Nov 2010 23:47, "Peter Reilly" <pe...@gmail.com> wrote:

It would be good to understand one word in three of that ;-)
Peter



On Mon, Nov 1, 2010 at 9:18 PM, Stephen Connolly
<st...@gmail.com> wrote:
> You co...

---------------------------------------------------------------------
To unsubscribe, e-mail: user-u...

Re: Getting task class *only* from specified path

Posted by Peter Reilly <pe...@gmail.com>.
It would be good to understand one word in three of that ;-)
Peter


On Mon, Nov 1, 2010 at 9:18 PM, Stephen Connolly
<st...@gmail.com> wrote:
> You could shade your ant task using a shading tool, eg maven-shade-plugin
> then it would be in a different package and depend on classes in a different
> package also (there may be non-maven shading tools for the maven averse ;-)
> )
>
> On 1 Nov 2010 17:07, "Peter Reilly" <pe...@gmail.com> wrote:
>
> That will not work.
> The jars in $ant.home/lib or ~/.ant/lib will
> be in front in the classloader.
>
> Peter
>
>
>
> On Mon, Nov 1, 2010 at 4:23 PM, David Weintraub <qa...@gmail.com> wrote:
>> When you use a <taskd...
>

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


Re: Getting task class *only* from specified path

Posted by Stephen Connolly <st...@gmail.com>.
You could shade your ant task using a shading tool, eg maven-shade-plugin
then it would be in a different package and depend on classes in a different
package also (there may be non-maven shading tools for the maven averse ;-)
)

On 1 Nov 2010 17:07, "Peter Reilly" <pe...@gmail.com> wrote:

That will not work.
The jars in $ant.home/lib or ~/.ant/lib will
be in front in the classloader.

Peter



On Mon, Nov 1, 2010 at 4:23 PM, David Weintraub <qa...@gmail.com> wrote:
> When you use a <taskd...

Re: Getting task class *only* from specified path

Posted by Peter Reilly <pe...@gmail.com>.
That will not work.
The jars in $ant.home/lib or ~/.ant/lib will
be in front in the classloader.

Peter


On Mon, Nov 1, 2010 at 4:23 PM, David Weintraub <qa...@gmail.com> wrote:
> When you use a <taskdef>, you can specify the classpath to use to
> point to the jarfile. ut the jarfile used by <taskdef> inside your
> project, and then set classpath to load that jarfile. For example, Put
> the jarfile in "${basedir}/antlib" and then define your taskdef like
> this:
>
> <taskdef resource="path/to/resource.xml">
>    <classpath>
>        <fileset dir="${basedir}/antlib"/>
>    </classpath>
> </taskdef>
>
> If you use a version control system, put the jarfile in your version
> control system, and users will check out the correct version when they
> checkout the project.
>
> On Sun, Oct 31, 2010 at 11:53 AM, Andreas Krey <a....@gmx.de> wrote:
>> Question: I need a user task; I do load it via explicit class path in
>> the taskdef. Unfortunately I need to use that version, but users may
>> have older ones in their .ant/lib. How can I keep ant (1.7) from
>> loading that version?
>>
>> Andreas
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>
>
>
> --
> David Weintraub
> qazwart@gmail.com
>
> ---------------------------------------------------------------------
> 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


Re: Getting task class *only* from specified path

Posted by David Weintraub <qa...@gmail.com>.
When you use a <taskdef>, you can specify the classpath to use to
point to the jarfile. ut the jarfile used by <taskdef> inside your
project, and then set classpath to load that jarfile. For example, Put
the jarfile in "${basedir}/antlib" and then define your taskdef like
this:

<taskdef resource="path/to/resource.xml">
    <classpath>
        <fileset dir="${basedir}/antlib"/>
    </classpath>
</taskdef>

If you use a version control system, put the jarfile in your version
control system, and users will check out the correct version when they
checkout the project.

On Sun, Oct 31, 2010 at 11:53 AM, Andreas Krey <a....@gmx.de> wrote:
> Question: I need a user task; I do load it via explicit class path in
> the taskdef. Unfortunately I need to use that version, but users may
> have older ones in their .ant/lib. How can I keep ant (1.7) from
> loading that version?
>
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
David Weintraub
qazwart@gmail.com

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