Get XML parsing error on Ivy file after upgrading from gradle 1.7


(Don Henry) #1

I’m reposting this as a problem because this issue does seem like versions later than 1.7 broke backward compatibility.

When using the following repository configuration with version 1.7, I could successfully retrieve the dependent JAR’s from our corporate Ivy repository:

repositories {
        ivy {
            name 'Old BPS Ivy Repository'
            url 'http://bps-artifacts.turner.com/ivy'
            layout 'pattern', {
                artifact '[organisation]/[module]/prod/[type]s/[artifact]-[revision].[type]'
                ivy '[organisation]/[module]/prod/ivys/ivy-[revision].xml'
    }
            }
    }

For all versions after version 1.7 that I have tested with, I get the following error:

> Could not resolve xstream:xstream:1.3.1.1.
  Required by:
      :mscore:unspecified
   > Could not parse Ivy file http://bps-artifacts.turner.com/ivy/xstream/xstream/prod/ivys/ivy-1.3.1.1.xml
      > xml parsing: ivy-1.3.1.1.xml:4:127: cvc-complex-type.3.2.2: Attribute 'env' is not allowed to appear in element 'info'. in http://bps-artifacts.turner.com/ivy/xstream/xstream/prod/ivys/ivy-1.3.1.1.xml
        xml parsing: ivy-1.3.1.1.xml:14:96: cvc-complex-type.3.2.2: Attribute 'env' is not allowed to appear in element 'dependency'. in http://bps-artifacts.turner.com/ivy/xstream/xstream/prod/ivys/ivy-1.3.1.1.xml
        xml parsing: ivy-1.3.1.1.xml:15:98: cvc-complex-type.3.2.2: Attribute 'env' is not allowed to appear in element 'dependency'. in http://bps-artifacts.turner.com/ivy/xstream/xstream/prod/ivys/ivy-1.3.1.1.xml
        xml parsing: ivy-1.3.1.1.xml:16:88: cvc-complex-type.3.2.2: Attribute 'env' is not allowed to appear in element 'dependency'. in http://bps-artifacts.turner.com/ivy/xstream/xstream/prod/ivys/ivy-1.3.1.1.xml

The only way I’ve found to fix this is to change the repository configuration as follows:

repositories {
        add(new org.apache.ivy.plugins.resolver.URLResolver()) {
            name = 'Old BPS Ivy Repository'
            validate = false
            addIvyPattern 'http://bps-artifacts.turner.com/ivy/[organisation]/[module]/prod/ivys/ivy-[revision].xml'
            addArtifactPattern 'http://bps-artifacts.turner.com/ivy/[organisation]/[module]/prod/[type]s/[artifact]-[revision].[type]'
        }
    }

This allows me to add the validate flag which eliminates the parsing error, but forces me to use a feature which will be deprecated in version 2.0.

Initialization script '/home/dohenry/gradle_init.d/bpsrepos.gradle': line 24
The ArtifactRepositoryContainer.add(DependencyResolver, Closure) method has been deprecated and is scheduled to be removed in Gradle 2.0.

I’ve tried to introduce the validate flag into the desired repository configuration but it doesn’t seem to support it.

Any suggestions around this issue? Could this be a bug that will get addressed in a later version?


Custom/invalid ivy.xml parsing