if I'd like to apply the `foojay-resolver-conventi...
# gradle
e
if I'd like to apply the
foojay-resolver-convention
plugin from a init scritp, am I right doing this?
Copy code
beforeSettings {
    pluginManagement {
        repositories { gradlePluginPortal() }
        resolutionStrategy {
            eachPlugin {
                if (requested.id.id == "org.gradle.toolchains.foojay-resolver-convention")
                    useVersion("1.0.0")
            }
        }
    }
}
settingsEvaluated {
    pluginManager.apply("org.gradle.toolchains.foojay-resolver-convention")
}
not kotlin but kotlin colored 3
because I dont see any other way to infer the version
v
You should strongly consider whether you really want to do that. This makes builds not executable if that init script is not applied. If you have such an init script in a custom Gradle distribution, it might be fine as the build will then always have it. But if you do that in a local init script, then other people not having that init script in place will not be able to execute that build. Also, if you have that in place locally, you are also modifying the plugin repositories of all builds you execute which might also then make builds behave differently, if you for example have a build that should not use the Gradle plugin portal. Having said that, you can for example do
Copy code
iniscript {
    repositories {
        gradlePluginPortal()
    }
    dependencies {
        classpath('org.gradle.toolchains.foojay-resolver-convention:org.gradle.toolchains.foojay-resolver-convention.gradle.plugin:1.0.0')
    }
}

settingsEvaluated {
    apply(plugin: org.gradle.toolchains.foojay.FoojayToolchainsConventionPlugin)
}
Besides that, this question does not really have anything to do with Kotlin, so is off-topic on this server.
e
ok, thanks for the feedback, I'll think about it, then