0

I have a question.

There is a question about spring-boot-gradle-plugin. I written about spring boot example that allows the specified version (ex. 2.2.1.RELEASE).

By the way, springBoot scope is not available when applying spring-boot-gradle-plugin written in legacy plugin application style. But the plugin DSL style is not a problem.

I know that there is no dynamic version assignment in the plugins scope in Kotlin build scripts, so I have to write in the legacy plugin application style.

The code is as follows:

Using legacy plugin application:

buildscript {
  repositories {
    gradlePluginPortal()
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.1.RELEASE")
  }
}

apply(plugin = "org.springframework.boot")

springBoot {
  mainClassName = "blabla~~"
}

e: .../build.gradle.kts:25:1: Unresolved reference: springBoot

Using the plugins DSL:

plugins {
  id("org.springframework.boot") version "2.2.1.RELEASE"
}

springBoot {
  mainClassName = "blabla~~"
}

no problem

Thanks!

WonChul Heo
  • 242
  • 1
  • 12
  • That's perfectly normal and expected. The Kotlin DSL will only provide plugin extensions if the plugin is applied using the plugins block. – JB Nizet Jan 01 '20 at 12:42
  • @JBNizet Thank for the reply. By the way, I don't understand why it's different from when I wrote it in `Groovy`. If I write in `Groovy`, I can use `springBoot`. Is this a problem with the `spring-boot-gradle-plugin`? I did not see that manifestation in the documentation. Can you tell me where it is stated? And can you suggest me a way to solve it? – WonChul Heo Jan 02 '20 at 02:06
  • 1
    It's different because Groovy is a dynamic language, but Kotlin is not. So springBoot is availailable in Groovy because it's dynamically added as an extension to the Project object in Groovy, but it can only be added as a Kotlin extension function when the .kts file is compiled if the plugin is applied statically, using the plugins block. See the information note in https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/#applying_plugins. – JB Nizet Jan 02 '20 at 07:09
  • @JBNizet thanks for detail reply :) – WonChul Heo Jan 02 '20 at 10:52

0 Answers0