Gradle plugins in artifactory

I would like to setup my project so that everything gets downloaded via company’s internal artifactory repository (firewall blocks all other urls). Here is my settings.gradle :

pluginManagement{
  repositories {
    maven {
      url = uri("...")
      credentials(HttpHeaderCredentials::class) {
     .
     .

      }
      authentication {
        create<HttpHeaderAuthentication>("header")
      }
    }
  }
}

When I run gradle build it still looks in Gradle Central Plugin repository for plugins, what am I missing?

Error : 


* What went wrong:
Plugin [id: 'org.gradle.kotlin.kotlin-dsl', version: '4.0.7'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:4.0.7')
  Searched in the following repositories:
    Gradle Central Plugin Repository

You forgot to define the plugin repositories for the build that is building your convention plugins.

Sorry not sure I completely understand, could you please elaborate with an example?

You use some convention plugins, either in buildSrc or in an included build.
These are built by an own build where you need the repositories as normal production repositories to be able to build your plugin.
You only defined it for the later stage where your convention plugin is applied to your main build.

I am using following plugins in buildSrc/build.gradle.kts
plugins {
java-gradle-plugin
kotlin-dsl
idea
}

I have also defined similar custom repositories block like mentioned above for settings.gradle in this build.gradle as well but for some reason when I build its first trying to look for plugins in Gradle Central plugin repository, I want it to look directly in repository url I am providing (here I am using artifactory for example )

As I said, buildSrc is a complete own build, did you define the repository in pluginManagement of buildSrc/settings.gradle(.kts)? Otherwise the plugins used to build buildSrc are looked up in the default, which is the plugin central.

Thank you , that was the missing piece. I was not defining pluginManagement inside buildSrc/settings.gradle.

1 Like