Looking at the nebula-kotlin project, I can see th...
# gradle
s
Looking at the nebula-kotlin project, I can see they do some magic in order to allow you to specify any kotlin version and have it apply that kotlin dependency. what is not obvious to me is if that same logic applies to the
apply
of the kotlin plugin. I can't parse whether the apply works because they increment the nebula-kotlin version whenever a new kotlin version is released, or if it works because of the
configurations
block that changes the resolution strategy. https://github.com/nebula-plugins/nebula-kotlin-plugin/blob/master/src/main/kotlin/netflix/nebula/NebulaKotlinPlugin.kt
g
Isn't this plugin is depreciated because standard Kotlin plugin does the same. Or you interested how this implemented in general?
s
I'm interested in how to make a plugin that accepts a version that allows me to then apply that version to other plugins. the use case is I want to create a custom plugin (internally for my company) that would be something like this
id("company.spring") version "any version of spring here"
and then be able to not only apply that version of the actual spring plugin (from within my plugin) but also apply custom configurations to that plugin. I'm wondering if the only way to actually handle this is to release a new version of the custom plugin for every version of the spring plugin, or if there is a better way.
g
Plugin verision is not something dynamic, so you have to publish plugin for each version if you just want to map it directly to spring version, this is exactly what nebula.kotlin does (see old version): https://plugins.gradle.org/plugin/nebula.kotlin
another way to handle it, expose some extension and set required spring versionm there:
Copy code
plugins {
   id("company.spring") version "your_plugin_version"
}

companySpring {
   springVersion = "spring_version"
}
s
Ok, that is what I wondered. I thought since you declare a dependency on the plugin (in the custom plugin) that I'd be able to modify that dependency at runtime and then apply a specific version
hmm. that's an idea.
g
I’d be able to modify that dependency at runtime
Modify plugin dependency on runtime? what do you mean?
s
hard to explain... currently my plugin has dependencies block like
Copy code
dependencies {
    implementation("com.netflix.nebula:nebula-kotlin-plugin:2.0.2")
    implementation("com.netflix.nebula:nebula-publishing-plugin:10.0.0")
    implementation("nu.studer:gradle-credentials-plugin:1.0.7")
    implementation("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
    implementation("org.jetbrains.kotlin:kotlin-noarg:$kotlinVersion")
    implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
    implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
    implementation("net.researchgate:gradle-release:3.0.0-RC3")
    implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7")
    implementation("org.ajoberstar.grgit:grgit-core:3.1.1")
    implementation("gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:1.1.2")
    //    id("org.springframework.boot") version ("2.1.2.RELEASE")
    implementation("org.springframework.boot:spring-boot-gradle-plugin:2.1.4.RELEASE")
}
I then apply plugin like
Copy code
class PromontechDockerPlugin : Plugin<Project> {
    override fun apply(project: Project): Unit = project.run {
        apply<PromontechBasePlugin>()
        apply<com.google.cloud.tools.jib.gradle.JibPlugin>()
I thought maybe I could do something like
Copy code
class PromontechDockerPlugin : Plugin<Project> {
    override fun apply(project: Project): Unit = project.run {
        apply<PromontechBasePlugin>()
        
        project.dependencies.add("...:spring:different version here")
        
        apply<DifferentVersionOfSpringPluginHere>()