Hello
I have create a small settings plugin that configures the build cache.
How can I apply it to my settings.gradle.kts?
Here is the code of my plugin:
class JvmSettingsPlugin : Plugin<Settings> {
override fun apply(settings: Settings) {
configureBuildCache(settings)
}
private fun configureBuildCache(settings: Settings) {
val isCI = settings.getExtra("CI")!!.toBoolean()
settings.buildCache { config ->
config.local { directoryBuildCache ->
directoryBuildCache.isEnabled = !isCI
directoryBuildCache.isPush = true
directoryBuildCache.removeUnusedEntriesAfterDays = 2
}
config.remote(HttpBuildCache::class.java, Action<HttpBuildCache> { buildCache ->
buildCache.isEnabled = true
buildCache.isPush = isCI
buildCache.url = URI(
"${settings.getExtra("ARTIFACTORY_URL")}/gradle-build-caches/${settings.rootProject.name}/"
)
buildCache.credentials { credentials ->
credentials.username = settings.getExtra("ARTIFACTORY_USERNAME")
credentials.password = settings.getExtra("ARTIFACTORY_PASSWORD")
}
})
}
}
private fun Settings.getExtra(key: String) =
this.extensions.extraProperties.get(key)?.toString()
}
I package it like this:
gradlePlugin {
plugins {
....
val settingsPlugin by plugins.creating {
id = "de.tech.gradle.plugins.settings"
implementationClass = "de.tech.gradle.plugins.JvmSettingsPlugin"
}
}
}
When I try to apply it from my settings script it says not found, even if I add it in pluginManagement > plugins block.