Gradle plugin dependencies not found

Hi, I’m having a weird issue regarding plugin dependencies. Let’s see if I can explain it tersely:

I’ve got a multi-project build. One of the projects (jnic) contains a source dependency, in which I inject a local plugin hyperscan-cmake:
[project jnic build.gradle]
dependencies {
implementation ‘org.intel:hyperscan:v5.4.0’
}
[root settings.gradle]
sourceControl {
gitRepository(“GitHub - intel/hyperscan: High-performance regular expression matching library”) {
producesModule(“org.intel:hyperscan”)
plugins {
id “hyperscan-cmake”
}
}
}

Now, the code to implement the hyperscan-cmake plugin lives in an included build “plugins”.
I’d like to make use of a 3rd party library to implement the plugin, so I’m writing:
[plugins build.gradle]
dependencies {
implementation “com.devo.foundations:devo-foundations-jnice:0.1.0-SNAPSHOT”
}

Now, when I run the build I get the following:

  • What went wrong:
    Could not resolve all artifacts for configuration ‘classpath’.

Could not find com.devo.foundations:devo-foundations-jnice:0.1.0-SNAPSHOT.
Searched in the following locations:
- https://plugins.gradle.org/m2/com/devo/foundations/devo-foundations-jnice/0.1.0-SNAPSHOT/maven-metadata.xml
- https://plugins.gradle.org/m2/com/devo/foundations/devo-foundations-jnice/0.1.0-SNAPSHOT/devo-foundations-jnice-0.1.0-SNAPSHOT.pom
Required by:
unspecified:unspecified:unspecified > project :plugins

This is, it seems gradle only looks in gradle plugin portal to resolve that dependency.
The weird thing is that I have my corporate repositories defined in an init.gradle file, and I have checked they are defined for the plugins project, but for some reason, they are ignored.
The same dependency loads fine in other subprojects of the same build, by the way. It’s within the injected plugin that doesn’t work.

Could anybody shed some light here, please? I’m utterly lost now.

Is this happening when trying to build that plugin or when trying to apply the plugin?
Because when the plugin is applied, iirc the repositories you defined to build it are irrelevant.
You have to define at usage side the repositories so that dependencies can be resolved.
So you probably have to add your corporate repository to pluginManagement { repositories { ... } } so that at usage time the dependencies can be resolved.

The error is happening at configuration phase.

In any case, my init.gradle defines corporate repos both in the normal repositories section, and in the pluginManagement section.
And I can check repos are there, as I have added this lines to the failing project build.gradle:

println “---- NORMAL REPOS ----” + project.repositories.collect {it.name}
println “---- PLUGIN MANAGEMENT REPOS ----” + gradle.settings.pluginManagement.repositories.collect {it.name}

And I get

---- NORMAL REPOS ----[maven, maven2]
---- PLUGIN MANAGEMENT REPOS ----[MavenLocal, maven, maven2, Gradle Central Plugin Repository]

where maven & maven2 are the names of my corporate repos.
So, they are there. But, for some reason, gradle seems to ignore those and only look in gradle plugin portal, as can be seen in the error message:

Could not find com.devo.foundations:devo-foundations-jnice:0.1.0-SNAPSHOT.
Searched in the following locations:
- https://plugins.gradle.org/m2/com/devo/foundations/devo-foundations-jnice/0.1.0-SNAPSHOT/maven-metadata.xml
- https://plugins.gradle.org/m2/com/devo/foundations/devo-foundations-jnice/0.1.0-SNAPSHOT/devo-foundations-jnice-0.1.0-SNAPSHOT.pom

Strangely, in fact, it also mentions jcenter repos just before giving the failure:
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/devo/foundations/devo-foundations-jnice/0.1.0-SNAPSHOT/maven-metadata.xml]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/devo/foundations/devo-foundations-jnice/0.1.0-SNAPSHOT/devo-foundations-jnice-0.1.0-SNAPSHOT.pom]

And I don’t have jcenter repo defined anywhere.

So, just to clarify:
Plugin code should be able to depend on a 3rd party library, residing in a repo declared in normal ‘repositories’ block, shouldn’t it?
May this have something to do with the fact of the failing plugin not being normal but being injected into a source dependency?

I’ve tried to get a build scan of this, so that it’s easier to inspect, but no luck. I get the following:

This build uses Gradle features that are incompatible with build scans (code: late-load-build-op).

Yeah, build scans unfortunately do not work with source dependencies yet: Supports build scan for build using source dependencies · Issue #13795 · gradle/gradle · GitHub.

Gradle Plugin Portal forwards to JCenter for resolving plugin dependencies that are not hosted on the plugin portal itself, so the JCenter lines might come from that.

You use the plugin for building the source dependency, so my guess would be, that there your corporate repos are not properly injected and thus the dependencies cannot be resolved.
But that’s just a wild guess.
While source dependencies are nice I didn’t really play much with them up to now.

I’ve setup a minimal project which reproduces the problem here:

README contains instructions to reproduce. Could you give it a try, please?

I have no idea.
It seems the plugin is not even built.
It first tries to resolve the dependencies on the source dependency build and fails to do so as there seems to be no way to inject a repository as far as I can see.

I’d recommend you open an issue about it and if you share the link here, I’ll also thumbs-up it.
For easier reproduction without misunderstanding I’d suggest you add some repository and dependency that is on some Maven repo but not on Maven Central or JCenter, because Gradle Plugin Portal forwards to JCenter which forwards to Maven Central, so for everything present there, you should not have a problem, besides maybe some company guidelines to just use internal repositories or similar.

I improved intructions a little bit, but didn’t include a predefined repo/dep because I couldn’t find a public repo containing a dep that is not in Gradle Plugin Central.

Here’s the link to the issue I created: Repository definitions ignored for plugins injected in source dependency · Issue #16752 · gradle/gradle · GitHub.

Thanks.

There are so many out there.
Just pick one from mvnrepository.com.
For example repo https://packages.atlassian.com/content/repositories/atlassian-public/
artifact com.atlassian.activeobjects:activeobjects-confluence-spi:3.3.1.
:slight_smile:

Ok, done. Now the problem is reproduced without editing anything.
Thanks very much.

1 Like

Gradle is unable to resolve dependencies that do not have associated pom after plugin upgrade from 4.10 to 6.1.1
I have tried below but no luck.

pluginManagement {
    repositories {
        gradlePluginPortal().tap {
            metadataSources {
                mavenPom()
                artifact()
            }
        }
    }
}

The exception is

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'.

And you are hijacking a foreign thread that has nothing to do with your problem because?
This thread is about a problem with dependencies of settings plugins that are injected into source dependencies.
Please create an own thread with your problem and maybe add some more information.
From what you provided I for example couldn’t at all figure out what you are talking about.

No worries. I have figured it out. Thanks.
I didn’t mean to hijack was kind of in a rush and my account was on hold for some reason. Thanks