You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by "Juliano DeCarvalho (JIRA)" <ji...@apache.org> on 2008/11/06 20:52:52 UTC

[jira] Commented: (IVY-966) Problem resolving latest jar from multiple repositories containing same jar with different versions

    [ https://issues.apache.org/jira/browse/IVY-966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12645558#action_12645558 ] 

Juliano DeCarvalho commented on IVY-966:
----------------------------------------

I apologize.  I've attached the files since it seems my code has wiki markup in it.

> Problem resolving latest jar from multiple repositories containing same jar with different versions
> ---------------------------------------------------------------------------------------------------
>
>                 Key: IVY-966
>                 URL: https://issues.apache.org/jira/browse/IVY-966
>             Project: Ivy
>          Issue Type: Bug
>    Affects Versions: 2.0-RC2
>         Environment: Windows XP SP2, JDK 1.6.0.05
>            Reporter: Juliano DeCarvalho
>
> This problem may be related to my configuration, but if it is, I'm not sure how to fix it.
> My project has a dependency on a jar that I build with another project.  This jar can be found in two different maven repositories, one local and one shared.  The jars have different modification dates but the same revision (SNAPSHOT) in either repository.  I need Ivy to find the latest of the two jars.  Both repositories are located on my local filesystem, for testing purposes.
> Ivy does not seem to return the latest of the two jars.  It seems to randomly select one, from what I can see.  I have debugged into the code and I think I found the problem, but not the cause or a solution.
> My configuration:
> *Ant:*
> {quote}
> 		<property name="ivy.shared.default.root" value="c:/repos/shared" />
> 		<property name="ivy.local.default.root" value="c:/repos/local" />
> 		<property name="ivy.local.default.ivy.pattern" value="[organisation]/[module]/[revision]/ivy.xml" />
> 		<property name="ivy.local.default.artifact.pattern" value="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
> 		<ivy:settings file="ivysettings.xml" />
> 		<ivy:resolve file="ivy.xml" />
> 		<ivy:retrieve pattern="./[artifact]-[revision].[ext]" />
> {quote}
> *ivy.xml:*
> {quote}
> <ivy-module version="2.0">
>     <info organisation="com.test" module="testapp" />
>     <dependencies>
>         <dependency org="com.test" name="components-codegenUtils" rev="4.1.0-SNAPSHOT" changing="true">
>         	<include type="jar" />
>         </dependency>
>     </dependencies>
> </ivy-module>
> {quote}
> *ivysettings.xml:*
> {quote}
> <ivysettings>
> 	<settings defaultResolver="default" />
> 	<property name="ivy.shared.default.root" value="${ivy.default.ivy.user.dir}/shared" override="false" />
> 	<property name="ivy.shared.default.ivy.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false" />
> 	<property name="ivy.shared.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false" />
> 	<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local" override="false" />
> 	<property name="ivy.local.default.ivy.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false" />
> 	<property name="ivy.local.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" override="false" />
> 	<resolvers>
> 		<filesystem name="local" m2compatible="true">
> 			<ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}" />
> 			<artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}" />
> 		</filesystem>
> 		<filesystem name="shared" m2compatible="true">
> 			<ivy pattern="${ivy.shared.default.root}/${ivy.local.default.ivy.pattern}" />
> 			<artifact pattern="${ivy.shared.default.root}/${ivy.local.default.artifact.pattern}" />
> 		</filesystem>
> 		<chain name="main" dual="true">
> 			<resolver ref="shared" />
> 		</chain>
> 		<chain name="default" returnFirst="false">
> 			<resolver ref="local" />
> 			<resolver ref="main" />
> 		</chain>
> 	</resolvers>
> </ivysettings>
> {quote}
> Here are the sequence of events which occur to cause this problem:
> - Code enters AbstractResolver.checkLatest(ResolvedModuleRevision, ResolveData), passing in the local artifact
> - Code returns artifact as latest since its the first one found
> - Code enters the checkLatest method again with the second (and newer by modification date) artifact
> - Code calls isAfter(newModuleFound, previousModuleFound, data.getDate())
>     - newModuleFound is the second artifact, newer by date
>     - previousModuleFound is the first artifact, which is older
>     - data.getDate() is null
> - isAfter() creates an array [ newModuleFound, previousModuleFound ] and passes that to LatestRevisionStrategy.findLatest()
> - findLatest() iterates over the array backwards
>     - findLatest() states that it iterates backwards because, and I quote:   "the latest revision comes last, use a ListIterator to iterate the sorted list in the reverse direction.".  Now, this is incorrect in my case since the array passed in clearly has the newer module found (the jar with the newer modification date) in slot 0
> - findLatest() returns the older revision artifact because the assumptions it makes about the array are wrong
> I hope that makes sense.  If there's anything else that you need to replicate this problem, please let me know.
> Thank you,
> - Juliano DeCarvalho

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.