Search code examples
gradleversionartifact

Gradle: excluding revision number from custom artifact name


I have the following custom artifact dependency in my build.gradle:

compile('foo:bar:1.1') {
    artifact {
        name="baz"
        extension="xsd"
        type="xsd"
    }
    force = true
}

When I run gradlew, I get an error saying that there is no such file as nexus.dir/foo/bar/1.1/baz-1.1.xsd

Since my file is nexus.dir/foo/bar/1.1/baz.xsd I'd like to get the version number string off from the baz.xsd so that it may be located. Is this even possible? Or should I ask the baz.xsd to be renamed?


Solution

  • We tried to add the version number to the artifacts but it turned out that our nexus server wanted to rename the files like foo/bar/1.1/bar-1.1-baz.xsd instead. But anyway that solved my problem, since I could specify the dependency simply like this:

    compile 'foo:bar:1.1:baz@xsd'
    

    And it even transforms nicely to pom when publishing my jar, so fetching the resource as a transitive dependency on another project works fine too.