You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by rob08 <ro...@yahoo.com> on 2009/05/21 04:30:19 UTC

sorting or ordering of resolved jars

Hi all,

I'm wondering if there's a way to specify that a certain dependency should
be higher or lower priority (order) in the resulting classpath.

My problems is that the vendor I'm working with delivers patches in separate
jars.  These jar contain classes that 'shadow' the standard class in the
standard jar.  I therefore need the patch jars to be earlier in the
classpath, or else the old, buggy class will be executed by my JUnit tests.  

Also, some patches make previously private methods protected or public, etc.
which if course is a problem purely on a resolve basis.

Any tips?

Thanks,


-- 
View this message in context: http://www.nabble.com/sorting-or-ordering-of-resolved-jars-tp23646892p23646892.html
Sent from the ivy-user mailing list archive at Nabble.com.


Re: sorting or ordering of resolved jars

Posted by Nicolas Lalevée <ni...@hibnet.org>.
On vendredi 22 mai 2009 08:41:07 Geoff Clitheroe wrote:
> Hi Rob,
>
> > I reviewed those links, but I don't think that's quite what I'm after...
> >
> > Here as sample fragment of my ivy.xml:
> >        <dependencies>
> >                <dependency org="vendor1" name="patches"
> > rev="latest.integration" conf="*->@"/>
> >                <dependency org="myco" name="myenhancements"
> > rev="latest.integration" conf="*->@"/>
> >                <dependency org="vendor1" name="core-app"
> > rev="latest.integration" conf="*->@"/>
> >        </dependencies>
> >
> > I find that for the classpath generated by the above, the order of jars
> > is random.  I have 3 configurations and the CLASSPATH generated by Ivy
> > for each configuration is different.
> >
> > I was hoping the CLASSPATH jars could be in the same order as the
> > dependencies, or perhaps a dependency attribute existed that allowed me
> > to specify some sort of classpath sort order or priority.
>
> When you say the 'classpath generated by Ivy' does this mean you are
> using Ivyde?  I've never used it but from the screen shots from the
> latest milestone for the classpath container it looks like you can
> tell it to order the classpath based on the order in the ivy.xml.  If
> your not using Ivyde and are building the classpath in an ant file
> then send some details of the file.

Actually Ivy itself is ordering the classpath relatively to the order declared 
in the ivy.xml. Then there is an option in IvyDE to reorder them in the 
lexical order.

But it seems there is a bug in IvyDE: 
https://issues.apache.org/jira/browse/IVYDE-170
Maybe Rob you are hitting this.

Nicolas


>
> > I realise that having an application depend on classpath order is a *bad
> > thing*, but surely it's not unheard of in the real world, is it?  Anyway,
> > in this case it's out of my hands - vendor app.
>
> Hmmm, it's probably only as bad as the lack of control you have over
> the classpath when you deploy, but yeah vendors do it all the time.  I
> would expect, at some time, this could cause unexpected behavior and
> hideous pain...
>
> Are the vendor jars encrypted or obfuscated in any way?  I would be
> very tempted to repackage the old jar and patch into a new jar.  If
> you go this way jarjar or proguard may be worth a look.
>
> Cheers,
> Geoff


Re: sorting or ordering of resolved jars

Posted by Geoff Clitheroe <g....@gmail.com>.
Hi Rob,

>
> I reviewed those links, but I don't think that's quite what I'm after...
>
> Here as sample fragment of my ivy.xml:
>        <dependencies>
>                <dependency org="vendor1" name="patches" rev="latest.integration"
> conf="*->@"/>
>                <dependency org="myco" name="myenhancements" rev="latest.integration"
> conf="*->@"/>
>                <dependency org="vendor1" name="core-app" rev="latest.integration"
> conf="*->@"/>
>        </dependencies>
>
> I find that for the classpath generated by the above, the order of jars is
> random.  I have 3 configurations and the CLASSPATH generated by Ivy for each
> configuration is different.
>
> I was hoping the CLASSPATH jars could be in the same order as the
> dependencies, or perhaps a dependency attribute existed that allowed me to
> specify some sort of classpath sort order or priority.

When you say the 'classpath generated by Ivy' does this mean you are
using Ivyde?  I've never used it but from the screen shots from the
latest milestone for the classpath container it looks like you can
tell it to order the classpath based on the order in the ivy.xml.  If
your not using Ivyde and are building the classpath in an ant file
then send some details of the file.

>
> I realise that having an application depend on classpath order is a *bad
> thing*, but surely it's not unheard of in the real world, is it?  Anyway, in
> this case it's out of my hands - vendor app.
>

Hmmm, it's probably only as bad as the lack of control you have over
the classpath when you deploy, but yeah vendors do it all the time.  I
would expect, at some time, this could cause unexpected behavior and
hideous pain...

Are the vendor jars encrypted or obfuscated in any way?  I would be
very tempted to repackage the old jar and patch into a new jar.  If
you go this way jarjar or proguard may be worth a look.

Cheers,
Geoff

Re: Re: sorting or ordering of resolved jars

Posted by Thomas Laun <th...@launweb.de>.
Hello Rob,

you could try to use different configurations for that purpose. The 
patches are downloaded in one configuration, and your enhancements are 
downloaded in another configuration. Retrieve each configuration to a 
separate directory and build the classpath by scanning the directories 
in the correct order.

Your ivy.xml would look something like this:

<configurations>
   <configuration name="patches" description="contains vendor patches"/>
   <configuration name="enhancements" description="contains own 
enhancements"/>
   [...]
</configurations>
<dependencies>
   <dependency org="vendor1" name="patches" conf="patches->@" />
   <dependency org="myco" name="myenhancements" conf="enhancements->@" />
   <dependency org="vendor1" name="core-app" 
conf="*,!patches,!enhancements->@" />
<dependencies>

The easiest setupt would be to retrieve each configuration into a 
separate directory. Then you can build your classpath by simply using 
all files in the folders:

<path id="myClasspath">
  <fileset dir="lib/patches" includes="*"/>
  <fileset dir="lib/enhancements" include="*"/>
  <fileset dir="lib/default" include="*"/>
</path>

As an alternative, you could use the ivy:cachpath task. It allows you to 
build a path of all artifacts in a configuration.

Thomas


rob08 wrote:
> Geoff Clitheroe-2 wrote:
>   
>> Hi Rob,
>>
>> I'm not sure that the shadowing is easy to deal with in pure Ivy
>> (unless the vendor is providing Ivy files with nice configs or you
>> write your own).  You could look at latest strategies and conflict
>> resolution
>>
>> http://ant.apache.org/ivy/history/2.1.0-rc1/settings/latest-strategies.html
>> http://ant.apache.org/ivy/history/2.1.0-rc1/settings/conflict-managers.html
>>
>> But if there are no configs available for you to work from then it may
>> be simplest to deal with how you set up the classpath in ant with
>> different pathelements?
>>
>> Cheers,
>> Geoff
>>     
> Thanks Geoff,
>
> I reviewed those links, but I don't think that's quite what I'm after...
>
> Here as sample fragment of my ivy.xml:
> 	<dependencies>
> 		<dependency org="vendor1" name="patches" rev="latest.integration"
> conf="*->@"/>
> 		<dependency org="myco" name="myenhancements" rev="latest.integration"
> conf="*->@"/>
> 		<dependency org="vendor1" name="core-app" rev="latest.integration"
> conf="*->@"/>
> 	</dependencies>
>
> I find that for the classpath generated by the above, the order of jars is
> random.  I have 3 configurations and the CLASSPATH generated by Ivy for each
> configuration is different.
>
> I was hoping the CLASSPATH jars could be in the same order as the
> dependencies, or perhaps a dependency attribute existed that allowed me to
> specify some sort of classpath sort order or priority.
>
> I realise that having an application depend on classpath order is a *bad
> thing*, but surely it's not unheard of in the real world, is it?  Anyway, in
> this case it's out of my hands - vendor app.
>
> Thanks,
>
>   

Re: sorting or ordering of resolved jars

Posted by rob08 <ro...@yahoo.com>.

Geoff Clitheroe-2 wrote:
> 
> Hi Rob,
> 
> I'm not sure that the shadowing is easy to deal with in pure Ivy
> (unless the vendor is providing Ivy files with nice configs or you
> write your own).  You could look at latest strategies and conflict
> resolution
> 
> http://ant.apache.org/ivy/history/2.1.0-rc1/settings/latest-strategies.html
> http://ant.apache.org/ivy/history/2.1.0-rc1/settings/conflict-managers.html
> 
> But if there are no configs available for you to work from then it may
> be simplest to deal with how you set up the classpath in ant with
> different pathelements?
> 
> Cheers,
> Geoff
> 
> 


Thanks Geoff,

I reviewed those links, but I don't think that's quite what I'm after...

Here as sample fragment of my ivy.xml:
	<dependencies>
		<dependency org="vendor1" name="patches" rev="latest.integration"
conf="*->@"/>
		<dependency org="myco" name="myenhancements" rev="latest.integration"
conf="*->@"/>
		<dependency org="vendor1" name="core-app" rev="latest.integration"
conf="*->@"/>
	</dependencies>

I find that for the classpath generated by the above, the order of jars is
random.  I have 3 configurations and the CLASSPATH generated by Ivy for each
configuration is different.

I was hoping the CLASSPATH jars could be in the same order as the
dependencies, or perhaps a dependency attribute existed that allowed me to
specify some sort of classpath sort order or priority.

I realise that having an application depend on classpath order is a *bad
thing*, but surely it's not unheard of in the real world, is it?  Anyway, in
this case it's out of my hands - vendor app.

Thanks,

-- 
View this message in context: http://www.nabble.com/sorting-or-ordering-of-resolved-jars-tp23646892p23664408.html
Sent from the ivy-user mailing list archive at Nabble.com.


Re: sorting or ordering of resolved jars

Posted by Geoff Clitheroe <g....@gmail.com>.
Hi Rob,

I'm not sure that the shadowing is easy to deal with in pure Ivy
(unless the vendor is providing Ivy files with nice configs or you
write your own).  You could look at latest strategies and conflict
resolution

http://ant.apache.org/ivy/history/2.1.0-rc1/settings/latest-strategies.html
http://ant.apache.org/ivy/history/2.1.0-rc1/settings/conflict-managers.html

But if there are no configs available for you to work from then it may
be simplest to deal with how you set up the classpath in ant with
different pathelements?

Cheers,
Geoff


On Thu, May 21, 2009 at 2:30 PM, rob08 <ro...@yahoo.com> wrote:
>
> Hi all,
>
> I'm wondering if there's a way to specify that a certain dependency should
> be higher or lower priority (order) in the resulting classpath.
>
> My problems is that the vendor I'm working with delivers patches in separate
> jars.  These jar contain classes that 'shadow' the standard class in the
> standard jar.  I therefore need the patch jars to be earlier in the
> classpath, or else the old, buggy class will be executed by my JUnit tests.
>
> Also, some patches make previously private methods protected or public, etc.
> which if course is a problem purely on a resolve basis.
>
> Any tips?
>
> Thanks,
>
>
> --
> View this message in context: http://www.nabble.com/sorting-or-ordering-of-resolved-jars-tp23646892p23646892.html
> Sent from the ivy-user mailing list archive at Nabble.com.
>
>