Project A can't fetch artifact A with classifier and extension


(Sergey Sheypak) #1

I have project A. It published artifact

group: "com.me", name: "a", version: "0.0.1", classifier: "distribution",  ext: "tar.gz"

to artifactory.

I try to include “a” dependency to project A

dependencies{
// other deps
compile "com.me", name: "a", version: "0.0.1", classifier: "distribution",  ext: "tar.gz"
}

Gradle can’t resolve this dependency:

Could not find a.distribution.tar.gz (com.me:a:0.0.1).

  1. Why Could not find a.distribution.tar.gz
    where is the version in file name?

  2. Works fine if I remove classifier and extension. Gradle is able to fetch published jar and dependencies

dependencies{
// other deps
compile "com.me", name: "a", version: "0.0.1" 
}
  1. I have project B
    I include there
compile "com.me", name: "a", version: "0.0.1", classifier: "distribution",  ext: "tar.gz"

Works fine.


Gradle 2.13

Build time: 2016-04-25 04:10:10 UTC
Build number: none
Revision: 3b427b1481e46232107303c90be7b05079b05b1c

Groovy: 2.4.4
Ant: Apache Ant™ version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_66 (Oracle Corporation 25.66-b17)
OS: Mac OS X 10.11.6 x86_64


(Sergey Sheypak) #2

OK, my friend helped me to find solution.
I had to create artificial project in my build.gradle file and fetch that dependency there.

Seems like a real gradle bug.


(Benjamin Muschko) #3

Works fine for me with Gradle 3.1. Please see the following code for reference. publish is project name in this case.

producer.gradle:

apply plugin: 'maven-publish'

group = 'com.me'
version = '0.0.1'

task distZip(type: Zip) {
    from 'test.txt'
    extension = 'tar.gz'
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact distZip {
                classifier "distribution"
            }
        }
    }
    
    repositories {
        maven {
            url "$buildDir/repo"
        }
    }
}

consumer.gradle:

configurations {
    myConf
}

repositories {
    maven {
        url "$buildDir/repo"
    }
}

dependencies {
    myConf group: "com.me", name: "publish", version: "0.0.1", classifier: "distribution",  ext: "tar.gz"
}

task copyLib(type: Copy) {
    from configurations.myConf
    into "$buildDir/libs"
}