This message was deleted.
# community-support
s
This message was deleted.
e
you can create a
Plugin<Settings>
but AFAIK it must come from a repository as a binary, not from a included build
although testing it out now, actually included builds seem to work fine
Copy code
// settings.gradle.kts
pluginManagement {
  includeBuild("plugin")
}
plugins {
  id("com.example.plugin")
}
Copy code
// plugin/build.gradle.kts
plugins {
  `java-gradle-plugin`
}

gradlePlugin {
  plugins {
    create("plugin") {
      id = "com.example.plugin"
      implementationClass = "com.example.SettingsPlugin"
    }
  }
}
Copy code
// plugin/src/main/java/com/example/SettingsPlugin.java
package com.example;

import org.gradle.api.Plugin;
import org.gradle.api.initialization.Settings;

public class SettingsPlugin implements Plugin<Settings> {
  @Override
  public void apply(Settings target) {
  }
}
❤️ 1
z
oh interesting, thank you! I wonder if the
kotlin-dsl
plugin can be leveraged for a
*.gradle.kts
format
so this plugin would contain all the shared logic, and each other
settings.gradle.kts
would import it then add its own custom logic if needed
e
if you want a precompiled script plugin, https://github.com/gradle/gradle/blob/master/subprojects/kotlin-dsl-provider-plugins/src/main/kotlin/org/gradle/kotlin/dsl/provider/plugins/precompiled/DefaultPrecompiledScriptPluginsSupport.kt
The target of a given script plugin is defined via its file name suffix in the following manner:
- the
.init.gradle.kts
file name suffix defines a [Gradle] script plugin
- the
.settings.gradle.kts
file name suffix defines a [Settings] script plugin
- and finally, the simpler
.gradle.kts
file name suffix defines a [Project] script plugin
👍 1
but unlike for build scripts, I think it's quite a lot less likely that you need to work with accessors generated from other settings plugins
z
oh, you can leverage
xyz.settings.gradle.kts
- interesting
interesting: if I add:
Copy code
// in my shared settings gradle precompiled plugin
plugins {
    id("com.gradle.enterprise") version ("3.11.1")
    id("com.gradle.common-custom-user-data-gradle-plugin") version ("1.8")
}
Plugin [id: 'com.gradle.enterprise'] was not found in any of the following sources:
Those IDs and versions need to be specified in the root
settings.gradle.kts
too, and that is something I’m trying to share lol
specifically the version part
e
same as other precompiled plugins, you can't do it like that
👍 1
z
any way to share that version via a gradle property or something?
e
Copy code
// plugin/build.gradle.kts
dependencies {
    implementation("com.gradle:gradle-enterprise-gradle-plugin:3.11.1")
}
Copy code
// plugin/src/main/kotlin/xyz.settings.gradle.kts
plugins {
    id("com.gradle.enterprise")
}
👍 1
z
haven’t tried it, but something like the following may work
Copy code
// File: settings.gradle.kts
pluginManagement {
    val springBootPluginVersion: String by settings // use project property with version
    plugins {
        id("org.springframework.boot") version "${springBootPluginVersion}"
    }
}
from https://blog.jdriven.com/2021/02/gradle-goodness-setting-plugin-version-from-property-in-plugins-section/
e
gradle properties aren't shared with included builds
z
Correct, but they are if you alias the root file!