This message was deleted.
# community-support
s
This message was deleted.
j
The specific problem is that the artifactregistry protocol is unsupported; I have the
buildscript
block set to use the gradlePluginPortal and adds the artifactregistry to the classpath, then I
apply
the plugin, but in
dependencyResolutionManagement
, I get an exception saying the protocol is invalid.
c
could you show how this is applied & configured, and the error output pls?
j
Sure.
settings.gradle.kts
, slightly munged:
Copy code
pluginManagement {
    repositories {
        mavenLocal()
        mavenCentral()
        gradlePluginPortal()
        maven {
            setUrl("<https://place.jfrog.io/artifactory/libs-release-local>")
            credentials {
                username = System.getenv("ARTIFACTORY_USER")
                password = System.getenv("ARTIFACTORY_PASSWORD")
            }
        }
    }
}

buildscript {
    repositories {
        gradlePluginPortal()
    }
    dependencies {
        classpath("gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1")
    }
}
apply {
    plugin("com.google.cloud.artifactregistry.gradle-plugin")
}

dependencyResolutionManagement {
    repositories {
        mavenCentral()
        maven {
            url = uri("<artifactregistry://us-east4-maven.pkg.dev/shared-place/mvn-repo-shared>")
            if (System.getenv("GCP_KEY") != null) {
                credentials {
                    username = "_json_key"
                    password = System.getenv("GCP_KEY")
                }
            }
        }
        maven {
            setUrl("<https://place.jfrog.io/artifactory/libs-release-local>")
            credentials {
                username = System.getenv("ARTIFACTORY_USER")
                password = System.getenv("ARTIFACTORY_PASSWORD")
            }
        }
        maven("<https://packages.confluent.io/maven>")
        mavenLocal()
    }
    versionCatalogs {
        create("libs") {
            from("com.place:place-bom:0.0.1")
        }
    }
}

rootProject.name = "thing-service"

include("thing-streams-app")
include("thing-service-api")
error:
Copy code
Could not resolve all dependencies for configuration 'incomingCatalogForLibs0'.
> Not a supported repository protocol 'artifactregistry': valid protocols are [http, https, file, gcs, s3, sftp]
We have working code where the repository is declared in the
build.gradle.kts
but we're building a version catalog as well, so ... settings
c
why does it have to be in settings? you can build/publish version catalogs w/o applying plugins in settings.
j
this isn't what builds the catalog, but what consumes it. Can you declare a version catalog's usage in build.gradle.kts and get the completion, etc?
c
not seeing where settings.gradle.kts is consuming the version catalog? Typically you’d define the version catalog in settings.gradle.kts and consume that in build.gradle.kts.
j
Copy code
versionCatalogs {
        create("libs") {
            from("com.place:place-bom:0.0.1")
        }
    }
^^^ consumption
c
ah ok. and that is from this custom repo?
j
it will be, and many of the things it refers to will be in this custom repo as well
I guess I'm mostly not clear on how I provide that protocol resolution properly for the settings, because I'm following the docs as I understand them
c
yea. that plugin does support being applied in settings (looking at the code), but something isn’t quite right.
hmmm. it tweaks the pluginManagement repositories when applied as a settings plugin, which isn’t where you have the repo.
It rewrites that custom protocol; wondering if you can do that directly.
Copy code
if (u != null && u.getScheme() != null && u.getScheme().equals("artifactregistry")) {
      try {
        arRepo.setUrl(new URI("https", u.getHost(), u.getPath(), u.getFragment()));
      } catch (URISyntaxException e) {
        throw new ProjectConfigurationException(
            String.format("Invalid repository URL %s", u.toString()), e);
      }

      if (crd != null && shouldStoreCredentials(arRepo)) {
        arRepo.setConfiguredCredentials(crd);
        arRepo.authentication(authenticationContainer -> authenticationContainer
            .add(new DefaultBasicAuthentication("basic")));
      }
    }
a
c
from that the url
Copy code
<https://us-east4-maven.pkg.dev/shared-place/mvn-repo-shared>
should be equivalent.
kinda odd that they jump through all those hoops to configure the repo - which is really just a url and basic auth. just document the setup for the custom repo. Too much magic == 💥
j
I would tell you how wrong you are, except I don't think you're wrong at all
🤣 1
c
when applied in settings it only modifies repos in pluginManagement, not dependencyManagement. Could try moving the repo to pluginManagement, though that won’t likely work for resolving version catalog artifacts. Alternately, look at what the logic does to rewrite the repository (change the url / set the auth) and just to that on your custom repository in dependencyManagement.
v
Trick 17:
Copy code
pluginManagement {
    repositories {
        maven {
            name = "supercalifragilisticexpialidocious"
            url = uri("<artifactregistry://us-east4-maven.pkg.dev/shared-place/mvn-repo-shared>")
            if (System.getenv("GCP_KEY") != null) {
                credentials {
                    username = "_json_key"
                    password = System.getenv("GCP_KEY")
                }
            }
        }
    }
}

buildscript {
    repositories {
        gradlePluginPortal()
    }
    dependencies {
        classpath("gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1")
    }
}
apply(plugin = "com.google.cloud.artifactregistry.gradle-plugin")

dependencyResolutionManagement {
    repositories {
        gradle.settingsEvaluated {
            pluginManagement
                .repositories
                .matching { it.name == "supercalifragilisticexpialidocious" }
                .forEach {
                    add(it)
                    pluginManagement.repositories.remove(it)
                }
        }
    }
}