[
https://issues.apache.org/jira/browse/IVY-1028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12710577#action_12710577
]
David Schlosnagle commented on IVY-1028:
----------------------------------------
I am also encountering the {{IndexOutOfBoundsException}} triggered by
{{org.apache.ivy.plugins.resolver.IBiblioResolver.findSnapshotVersion(IBiblioResolver.java:165)}}
using Apache Ivy 2.1.0-rc1. The problem appears to only occur when using the
Ibiblio resolver when no ivy patterns have been defined for that resolver. It
is therefore possible to workaround the bug by adding the following element
within the Ibiblio resolver(s) that use snapshot versions.
{code:xml}
<ivy
pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
{code}
The root of the problem is the following line of code:
{code:java}
String pattern = (String) getIvyPatterns().get(0);
{code}
I'd naively suggest the following as a fix to default the M2_PATTERN if none is
defined for the resolver as this will cause
org.apache.ivy.plugins.resolver.IBiblioResolver.shouldUseMavenMetadata(String)
to return true if the resolver is configured to use maven metadata and is M2
compatible since the default pattern would always end with the M2_PATTERN:
{code:java}
String pattern = (String) (getIvyPatterns().isEmpty() ? M2_PATTERN :
getIvyPatterns().get(0));
{code}
Unified diff:
{code:java}
--- before/IBiblioResolver.java 2009-05-18 20:58:40.000000000 -0400
+++ after/IBiblioResolver.java 2009-05-18 20:59:32.000000000 -0400
@@ -162,7 +162,7 @@
return null;
}
- String pattern = (String) getIvyPatterns().get(0);
+ String pattern = (String) (getIvyPatterns().isEmpty() ? M2_PATTERN :
getIvyPatterns().get(0));
if (shouldUseMavenMetadata(pattern)) {
InputStream metadataStream = null;
try {
{code}
I don't know enough about when it would make sense to define an ivy pattern for
an Ibiblio resolver, but if the ivy pattern is not needed it would be simple
enough to just pass M2_PATTERN to the shouldUseMavenMetadata method:
{code:java}
--- before/IBiblioResolver.java 2009-05-18 20:58:40.000000000 -0400
+++ after/IBiblioResolver.java 2009-05-18 21:01:25.000000000 -0400
@@ -162,8 +162,7 @@
return null;
}
- String pattern = (String) getIvyPatterns().get(0);
- if (shouldUseMavenMetadata(pattern)) {
+ if (shouldUseMavenMetadata(M2_PATTERN)) {
InputStream metadataStream = null;
try {
String metadataLocation = IvyPatternHelper.substitute(
{code}
Example workaround ivysettings:
{code:xml}
<ivysettings>
<property name="M2_PATTERN"
value="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
override="false"/>
<resolvers>
<chain name="chained" returnFirst="true">
<ibiblio name="java-twitter"
root="http://java-twitter.googlecode.com/svn/repository/"
pattern="[organisation]/[module]/[revision]/[module]-[revision].[ext]"
m2compatible="true"
usepoms="false">
<ivy pattern="${M2_PATTERN}"/>
</ibiblio>
</chain>
</resolvers>
</ivysettings>
{code}
in ivy.xml:
{code:xml}
<dependency org="net.unto.twitter" name="java-twitter" rev="0.9-SNAPSHOT"
conf="runtime->default" />
{code}
> Snapshot issues when using ibiblio resolver when m2compatible is false
> ----------------------------------------------------------------------
>
> Key: IVY-1028
> URL: https://issues.apache.org/jira/browse/IVY-1028
> Project: Ivy
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0
> Reporter: Daniel Nielsen
> Assignee: Maarten Coene
> Fix For: 2.1.0-RC1
>
>
> I changed the java.net resolver to use the maven2 of download.java.net and
> added m2compatible and usepoms=true. Now it does not fail with NPE.
> --------------------
> I think you've found a bug in Ivy.
> It seems to be caused by your "java.net" resolver. Could you try what happens
> if you add m2compatible="true" and usepoms="true" to this resolver?
> <ibiblio name="java.net" root="${java.net.repo}" m2compatible="true"
> usepoms="true"
> pattern="[organization]/jars/[module]-[revision].[ext]"/>
> If that helps, could you please open a JIRA ticket?
> Maarten
> ----- Original Message ----
> From: Daniel Nielsen <[email protected]>
> To: "[email protected]" <[email protected]>
> Sent: Tuesday, February 3, 2009 2:41:03 PM
> Subject: Snapshot issue?!
> Hi.
> I'm currently evaluating Ivy 2.0.0 for our dependency management. I like what
> I've seen so far, but now I've run into trouble.
> We use JSFUnit for our testcases and we use the snapshot versions.
> To make Ivy fetch these dependencies I have the following ivy settings: (the
> properties file contains only version numbers and repository locations)
> <?xml version="1.0" encoding="UTF-8"?>
> <ivysettings>
> <settings defaultResolver="default"/>
> <properties file="${ivy.settings.dir}/ivysettings.properties"/>
> <caches
> artifactPattern="[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"
> checkUpToDate="true"/>
> <resolvers>
> <filesystem name="project">
> <ivy
> pattern="${basedir}/lib/ivy-repo/[organisation]/[module]/ivy-[revision].xml"/>
> <artifact
> pattern="${basedir}/lib/ivy-repo/[organisation]/[module]/[artifact]-[revision](-[classifier]).[ext]"/>
> </filesystem>
> <ibiblio name="central" m2compatible="true" usepoms="true"
> root="${central.repo}" />
> <ibiblio name="jboss" m2compatible="true" usepoms="true"
> root="${jboss.repo}" />
> <ibiblio name="jboss-snapshot" m2compatible="true" usepoms="true"
> root="${jboss.snapshotrepo}" />
> <ibiblio name="java.net" root="${java.net.repo}"
> pattern="[organization]/jars/[module]-[revision].[ext]"/>
> <chain name="default" returnFirst="true">
> <resolver ref="project" />
> <resolver ref="central"/>
> <resolver ref="jboss-snapshot"/>
> <resolver ref="jboss"/>
> <resolver ref="java.net"/>
> </chain>
> </resolvers>
> </ivysettings>
> And try to fetch jsfunit snapshot with an ivy.xml file:
> <ivy-module version="2.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:m="http://ant.apache.org/ivy/maven"
>
> xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
> <info organisation="com.blipsystems.analyzer" module="test-jsf"/>
> <configurations>
> <conf name="default" transitive="false"/>
> <conf name="jsfunit" transitive="true"/>
> </configurations>
> <dependencies defaultconf="default">
> <dependency org="org.jboss.jsfunit" name="jboss-jsfunit"
> rev="1.0.0.GA-SNAPSHOT" conf="jsfunit->default" />
> <!--<dependency org="org.jboss.jsfunit" name="jboss-jsfunit-core"
> rev="1.0.0.GA-SNAPSHOT" changing="true" conf="jsfunit->default" />-->
> <!--<dependency org="org.jboss.jsfunit" name="jboss-jsfunit-ant"
> rev="1.0.0.GA-SNAPSHOT" changing="true" conf="jsfunit->default" />-->
> <!--<dependency org="org.jboss.jsfunit"
> name="jboss-jsfunit-richfaces" rev="1.0.0.GA-SNAPSHOT" changing="true"
> conf="jsfunit->default" />-->
> <!--<dependency org="org.jboss.jsfunit" name="jboss-jsfunit-analysis"
> rev="1.0.0.GA-SNAPSHOT" changing="true" conf="jsfunit->default" />-->
> <!-- snip other dependencies for default configuration -->
> </dependencies>
> </ivy-module>
> The following is the output of a <ivy:resolve> run from ant with verbose
> output:
> [ivy:resolve] == resolving dependencies
> com.blipsystems.analyzer#test-jsf;work...@danipc1->org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT
> [jsfunit->default] [ivy:resolve] default: Checking cache for: dependency:
> org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT {jsfunit=[default]}
> [ivy:resolve] tried
> c:\Users\dani.BSH\work\analyzer-trunk/lib/ivy-repo/org.jboss.jsfunit/jboss-jsfunit/ivy-1.0.0.GA-SNAPSHOT.xml
> [ivy:resolve] tried
> c:\Users\dani.BSH\work\analyzer-trunk/lib/ivy-repo/org.jboss.jsfunit/jboss-jsfunit/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] project: no ivy file nor artifact found for
> org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT
> [ivy:resolve] don't use cache for
> org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT: changing=true
> [ivy:resolve] CLIENT ERROR: Not Found
> url=http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/maven-metadata.xml
> [ivy:resolve] maven-metadata not available:
> http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/maven-metadata.xml
> [ivy:resolve] tried
> http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.pom
> [ivy:resolve] CLIENT ERROR: Not Found
> url=http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.pom
> [ivy:resolve] maven-metadata not available:
> http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/maven-metadata.xml
> [ivy:resolve] tried
> http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] CLIENT ERROR: Not Found
> url=http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] central: no ivy file nor artifact found for
> org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT
> [ivy:resolve] don't use cache for
> org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT: changing=true
> [ivy:resolve] [1.0.0.GA-20090129.125050-9]
> org/jboss/jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT
> [ivy:resolve] tried
> http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-20090129.125050-9.pom
> [ivy:resolve] jboss-snapshot: found md file for
> org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT
> [ivy:resolve] =>
> http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-20090129.125050-9.pom
> (1.0.0.GA-SNAPSHOT)
> [ivy:resolve] downloading
> http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-20090129.125050-9.pom
> ...
> [ivy:resolve] jboss-snapshot: downloading
> http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-20090129.125050-9.pom
> [ivy:resolve] jboss-snapshot: downloading
> http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-20090129.125050-9.pom.sha1
> [ivy:resolve] sha1 OK for
> http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-20090129.125050-9.pom
> [ivy:resolve] [SUCCESSFUL ]
> org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT!jboss-jsfunit.pom(pom.original)
> (869ms)
> [ivy:resolve] default: Checking cache for: dependency:
> org.jboss#jboss-parent;3 {} [ivy:resolve] default: module revision found in
> cache: org.jboss#jboss-parent;3
> [ivy:resolve] tried
> c:\Users\dani.BSH\work\analyzer-trunk/lib/ivy-repo/org.jboss.jsfunit/jboss-jsfunit/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] maven-metadata not available:
> http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/maven-metadata.xml
> [ivy:resolve] tried
> http://repo1.maven.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] tried
> http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-20090129.125050-9.jar
> [ivy:resolve] CLIENT ERROR: Not Found
> url=http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-20090129.125050-9.jar
> [ivy:resolve] tried
> http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] CLIENT ERROR: Not Found
> url=http://snapshots.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] CLIENT ERROR: Not Found
> url=http://repository.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/maven-metadata.xml
> [ivy:resolve] maven-metadata not available:
> http://repository.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/maven-metadata.xml
> [ivy:resolve] tried
> http://repository.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] CLIENT ERROR: Not Found
> url=http://repository.jboss.org/maven2/org/jboss/jsfunit/jboss-jsfunit/1.0.0.GA-SNAPSHOT/jboss-jsfunit-1.0.0.GA-SNAPSHOT.jar
> [ivy:resolve] problem occured while resolving dependency:
> org.jboss.jsfunit#jboss-jsfunit;1.0.0.GA-SNAPSHOT {jsfunit=[default]} with
> jboss-snapshot: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
> [ivy:resolve] at java.util.ArrayList.RangeCheck(ArrayList.java:547)
> [ivy:resolve] at java.util.ArrayList.get(ArrayList.java:322)
> [ivy:resolve] at
> java.util.Collections$UnmodifiableList.get(Collections.java:1154)
> [ivy:resolve] at
> org.apache.ivy.plugins.resolver.IBiblioResolver.findSnapshotVersion(IBiblioResolver.java:161)
> The jboss-jsfunit is a pom declaring only dependencies with no jars, but Ivy
> apparently expects an jar to download? Ivy identifies the correct snapshot
> version, but I don't get why it tries to download the jboss-jsfunit jar.
> I've tried listing the stuff I need from jsfunit (jboss-jsfunit-core etc) but
> these poms have a <parent> attribute naming jboss-jsfunit and ivy resolves
> this parent regardless of transitive settings.
> Am I doing something wrong or is this a bug in Ivy?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.