10

I have successfully published to Artifact Registry, and I can use artifacts from there in "normal" use: dependencies { implementation("mygroup:myartifact:myversion") }.

My issue is plugins. I have created a plugin. I can successfully publish it to Artifact Registry and also to Maven local. I can use it from Maven local, but I can't get my build script to take it from Artifact Registry.

buildscript {
    repositories {
        maven(url = uri("artifactregistry://us-west1-maven.pkg.dev/glitchy-maven/repo"))
    }
}

plugins {
    id("com.google.cloud.artifactregistry.gradle-plugin") version "2.1.1"
    id("com.glitchybyte.gradle.plugin.buildinfo") version "1.0.0"
    `java-library`
}

And I get:

* What went wrong:
Plugin [id: 'com.glitchybyte.gradle.plugin.buildinfo', version: '1.0.0'] 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 'com.glitchybyte.gradle.plugin.buildinfo:com.glitchybyte.gradle.plugin.buildinfo.gradle.plugin:1.0.0')
  Searched in the following repositories:
    Gradle Central Plugin Repository

So, it's not looking into Artifact Registry for plugins. I know I'm missing something, but I don't know what.

...Update...

I removed buildscript from build.gradle.kts, and instead I added this to settings.gradle.kts:

pluginManagement {
    plugins {
        id("com.google.cloud.artifactregistry.gradle-plugin") version "2.1.1"
    }
    repositories {
        maven(url = uri("artifactregistry://us-west1-maven.pkg.dev/glitchy-maven/repo"))
    }

And I get:

* What went wrong:
Error resolving plugin [id: 'com.glitchybyte.gradle.plugin.buildinfo', version: '1.0.0']
> Could not resolve all dependencies for configuration 'detachedConfiguration1'.
   > Not a supported repository protocol 'artifactregistry': valid protocols are [http, https, file, gcs, s3, sftp]
Luis
  • 171
  • 1
  • 8
  • Have you seen [how to configure Gradle](https://cloud.google.com/artifact-registry/docs/java/quickstart#config-gradle) documentation ? Try going throgh it and maybe it will help you. – Wojtek_B Dec 14 '20 at 15:52
  • 1
    Yes. As I explained at the very top, publishing an artifact and pulling it in the "normal" way (with the Google plugin and the repository definition) works fine. The problem is using the artifact as a plugin. The documentation doesn't talk about it at all, I assume, as this is mostly a Gradle problem; having to use a plugin to use another plugin. – Luis Dec 15 '20 at 03:00
  • 1
    Hello, I'm facing the same issue – Maryo Feb 03 '21 at 00:00
  • 1
    Me too, and no solution yet – bart van deenen Feb 08 '21 at 09:50

1 Answers1

0

Hello Sorry for the late answer. I think you are missing this part of the configuration to be added to your settings.gradle.kts

buildscript {
    repositories {
        maven {
            url = uri("https://plugins.gradle.org/m2/")          }
    }
    dependencies {
        classpath("gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.0")
    }
}
apply(plugin =  "com.google.cloud.artifactregistry.gradle-plugin")

More details are provided on this link.

Youssef NAIT
  • 1,362
  • 11
  • 27