14

I need a dependency which has an inconsistent version number in it's pom.

Apache XmlSchema-Pom has as version SNAPSHOT which is obviously not correct as it should be 1.1.

According to this gradle discussion it should be possible if the maven repository specified as an ivy repo, adding @jar or transitive = false to the dependency, all that didn't work for me

Here my build.gradle with my attempts:

group 'de.company'
version '1.0-SNAPSHOT'

apply plugin: 'maven'
apply plugin: 'java'

repositories {
    // specified as ivy repo
    // ivy {
    //     url = mavenCentral().url
    // }
    mavenCentral()
}

dependencies {
    // with @jar and transitive
    // compile (group: 'org.apache.ws.commons', name: 'XmlSchema', version: '1.1', ext: 'jar') {
    //     transitive = false
    // }
    compile group: 'org.apache.ws.commons', name: 'XmlSchema', version: '1.1'
}

Here is the error message which gradle outputs:

Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not resolve org.apache.ws.commons:XmlSchema:1.1.
  Required by:
      de.company:gradle-test:1.0-SNAPSHOT
   > Could not resolve org.apache.ws.commons:XmlSchema:1.1.
      > inconsistent module metadata found. Descriptor: org.apache.ws.commons:XmlSchema:SNAPSHOT Errors: bad version: expected='1.1' found='SNAPSHOT'
jmattheis
  • 10,494
  • 11
  • 46
  • 58

2 Answers2

17

The way i solved this is different, I don't want to touch artifactory pom as i don't have access to artifactory. here is the code you need in gradle.build

repositories {
    maven {
        url 'http://xxxxx/xx'
        metadataSources {
             artifact() //Look directly for artifact
        }
    }
}
Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76
Md Ayub Ali Sarker
  • 10,795
  • 4
  • 24
  • 19
2

As to the current date, there is no actual way of ignoring the validating of the poms from gradle.

Still there are some ways to workaround that.

  1. Try use an other version of that dependency, where the pom is valid
  2. Check other repositories, maybe they have an valid pom for the depedency you want.

    that would be in my example for XmlSchema the jcenter repository (XmlSchema from jcenter)

  3. Download the sources by yourself and deploy it into your local/company repository and use this version instead

jmattheis
  • 10,494
  • 11
  • 46
  • 58