Search code examples
javagradlebuild.gradleartifactory

Gradle looking for POM instead of ZIP


Here's a part of my build.gradle:

apply plugin: 'java'

repositories {
    maven {
        url "https://artifactory.(...)/artifactory/jcenter/"
        credentials {
            username artifactoryUsername
            password artifactoryPassword
        }
    }
    maven {
        url "https://artifactory.(...)/artifactory/libs-release-local/"
        credentials {
            username artifactoryUsername
            password artifactoryPassword
        }
    }
}

configurations {
    [amq, amqBundles, amqExtensions]
}

dependencies {
    amq(group: 'com.redhat', name: 'amq-broker', version: '7.10.0', ext: 'zip')
    amqBundles(group: "org.postgresql", name: "postgresql", version: "42.2.14", ext: "jar")
    amqExtensions(group: "biz.paluch.logging", name: "logstash-gelf", version: "1.14.1", ext: "jar")
}

(...)

task extractAmq(type: Copy) {
    from configurations.amq.files
    into "$buildDir/software/amq"
}

And here's the error I get when I run "gradle help":

A problem occurred evaluating root project 'installer'.
> Could not resolve all files for configuration ':amq'.
   > Could not find com.redhat:amq-broker:7.10.0.
     Searched in the following locations:
       - https://artifactory.(...)/artifactory/jcenter/com/redhat/amq-broker/7.10.0/amq-broker-7.10.0.pom
       - https://artifactory.(...)/artifactory/libs-release-local/com/redhat/amq-broker/7.10.0/amq-broker-7.10.0.pom
     Required by:
         project :

It fails at the "from configurations.amq.files" line.

Why is it looking for a .pom instead of .zip and how can I fix that?


Solution

  • I added metadataSources to the repositories like so:

    repositories {
        maven {
            url "https://artifactory.(...)/artifactory/jcenter/"
            credentials {
                username artifactoryUsername
                password artifactoryPassword
            }
            metadataSources{
                artifact()
            }
        }
        maven {
            url "https://artifactory.(...)/artifactory/libs-release-local/"
            credentials {
                username artifactoryUsername
                password artifactoryPassword
            }
            metadataSources{
                artifact()
            }
        }
    }
    

    and it fixed the issue.