Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle can't resolve my dependencies if not provided in a certain format

I can't pull any dependencies from my Artifactory repository, if they're in a certain format. However maven manages to pull all those dependencies without any problems regardless of the format.

> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find eu.****:cloudnet-bridge:1.0.0.
     Searched in the following locations:
       - https://repo.****.dev:443/artifactory/****-repo/eu/****/cloudnet-bridge/1.0.0/cloudnet-bridge-1.0.0.pom
       - https://repo.****.dev:443/artifactory/****-repo/eu.****/cloudnet-bridge/ivy-1.0.0.xml
     Required by:
         project :

This is the error I am getting in IntelliJ (2020.1.2 Community Edition) using gradle (6.5).

This is the folder structure for a non-working dependency (the jar is directly placed in the folder)

This is the folder structure for a working dependency (the jar is inside a version folder along with a valid POM; the artifactory auto-generated one does NOT work here! There also is a xml file in the dependency's root folder containing some information about the version etc.)

Now my question is whether or not I can fix this issue.

like image 304
Samuel E. Avatar asked Oct 31 '25 05:10

Samuel E.


1 Answers

It looks like the lack of a .pom is the problem.

By default, Gradle 6 can't find dependencies unless they have metadata. This is a change from Gradle 5 behaviour. You can customise it by adding a metadataSources block to your repository declaration, like this:

repositories {
    maven {
        url = uri("https://repo.****.dev:443/artifactory/****-repo")
        metadataSources {
            mavenPom()
            artifact()
        }
    }
}

This means, "Look for the .pom first, but if there is no .pom, look for the .jar."

You might also want to add gradleMetadata() if the repo contains any.

like image 110
Selcaby Avatar answered Nov 02 '25 19:11

Selcaby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!