This message was deleted.
# community-support
s
This message was deleted.
e
Thinking about it more, would I actually need a plugin, or could I have a library that I depend on in the
settings.gradle.kts
buildscript, that provides function I can call that will add a repository?
v
Both should work fine I think. Actually, there was a bug that when you add a repo from a settings plugin to
pluginManagement.repositories
the implicit Gradle Plugin Portal repo was not suppressed, but that should be fixed with 7.5 iirc.
👍 1
e
I'm trying to add a repository to
pluginManagement
with a settings plugin, but I'm having trouble setting up an extension for it. I keep getting an error saying that
ejsonSecretsFile must be set
, even though I'm setting the
password
property in the extension in
settings.gradle.kts
v
You create the extension and then immediately check password and ejsonSecretsFile, what else do you expect, than then being unset?
e
How do I wait until it gets populated?
v
Same as always. Best is you don't. Add a function / functions to your extension instead.
e
A function on the extension that will add the repository?
Also, do I have to do something special to configure the extension by name, e.g.
Copy code
addGitHubPackagesRepoToPluginManagement {
  owner = ...
}
I keep getting an error saying that it doesn't exist. But if I do:
Copy code
configure<GitHubPackagesPluginManagementRepoPlugin.Extension> {
  owner = ...
}
Then it works
v
A function on the extension that will add the repository?
Exactly
Also, do I have to do something special to configure the extension by name
How do you apply it?
e
In the plugins block
g
Also, do I have to do something special to configure the extension by name
For settings plugin, yes. Add an extension function with signature
fun Settings.addGitHubPackagesRepoToPluginManagement(configure: Action<in GitHubPackagesPluginManagementRepoPlugin.Extension>)
in the default package
e
Oh interesting so it's not made for you like Project plugins? Is that documented somewhere?
g
Not sure if it is. But there were some issues on the github like https://github.com/gradle/gradle/issues/11210
v
Or 21381 for a remake of the issue 🙂
g
I wonder if java only plugin can provide such an extension
v
I wonder like the new reporter how it works for the Gradle enterprise plugin, where navigation in the IDE brings you to a
Project
extension function which seems wrong. Both, it being generated and also being taken there. 😕
g
Plugin itself contains
org.gradle.kotlin.dsl.GradleEnterpriseKt
with
public fun Settings.gradleEnterprise(GradleEnterpriseExtension.() -> Unit): Unit
and
public val Settings.gradleEnterprise: GradleEnterpriseExtension
so I guess that the ones with
Project
are generated the same way as for the project plugins and IDE finds them but not from settings buildscripts classpath. I had to add
com.gradle.enterprise
manually to the dependencies for IDEA to show
com.gradle:gradle-enterprise-gradle-plugin
in the
External Libraries
.
v
Yeah, I've seen those manual extensions in
org.gradle.kotlin.dsl.GradleEnterpriseKt
by navigating to the extension from the settings script and using the breadcrumb toolbar in IntelliJ to navigate around the jar. But still, afaik for settings script there should be no accessor generation at all, and even if I do
settings.gradleEnterprise { ... }
navigation takes me to the project accessor which does not make much sense.
1
g
Thought the same but they are generated and
kotlinDslAccessorsReport
task prints them. And it seems same code collects all
ExtensionAware
objects visible from project perspective.
Copy code
plugins {
  id("com.gradle.enterprise")  version "3.9"
}

gradle.rootProject {
  val schema = serviceOf<ProjectSchemaProvider>().schemaFor(this)
  schema.extensions.forEach { logger.lifecycle("ext: $it") }
}
produces
Copy code
ext: ProjectSchemaEntry(target=org.gradle.api.Project, name=ext, type=org.gradle.api.plugins.ExtraPropertiesExtension)
ext: ProjectSchemaEntry(target=org.gradle.api.Project, name=buildScan, type=com.gradle.scan.plugin.BuildScanExtension)
ext: ProjectSchemaEntry(target=org.gradle.api.Project, name=gradleEnterprise, type=com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension)
ext: ProjectSchemaEntry(target=org.gradle.api.artifacts.dsl.DependencyHandler, name=ext, type=org.gradle.api.plugins.ExtraPropertiesExtension)
ext: ProjectSchemaEntry(target=org.gradle.api.artifacts.dsl.RepositoryHandler, name=ext, type=org.gradle.api.plugins.ExtraPropertiesExtension)
Though even in
afterEvaluate
I don't see my extension from settings plugin there, only genuine project-related ones (like version catalogs, extra properties for every
ExtensionAware
, and project plugin extensions). So I would guess that it hails from some special handling for blessed `buildScan`/`gradleEnterprise` extensions.