title: Getting rid of warning in a Spring Boot project being migrated to the Gradle Kotlin DSL
body: <p>I am migrating certain Gradle project from the Groovy to the Kotlin DSL.</p>
  
  <p>I am using the <a href="https://docs.gradle.org/current/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin" rel="nofollow noreferrer">kotlin-dsl</a> plugin and configuring Spring Boot as follows:</p>
  
  <pre><code>plugins {
      java
      id("org.springframework.boot").version(Versions.springBootVersion)
      `kotlin-dsl`
  }
  </code></pre>
  
  <p>The documentation of the <code>kotlin-dsl</code> plugin asks to <strong>not</strong> specify any specific Kotlin version, as quoted below:</p>
  
  <blockquote>
    <p>Avoid specifying a version for the kotlin-dsl plugin:</p>
    
    <p>Each Gradle release is meant to be used with a specific version of the
    kotlin-dsl plugin and compatibility between arbitrary Gradle releases
    and kotlin-dsl plugin versions is not guaranteed. Using an unexpected
    version of the kotlin-dsl plugin in a build will emit a warning and
    can cause hard to diagnose problems.</p>
  </blockquote>
  
  <p>And this is my application class:</p>
  
  <pre><code>@SpringBootApplication
  class App {
      fun main(args: Array&lt;String&gt;) {
          runApplication&lt;App&gt;(*args)
      }
  }
  </code></pre>
  
  <p>Under the line starting with <code>class App</code> I see a warning in IntelliJ that tells me:</p>
  
  <pre><code>Classes annotated with '@Configuration' could be implicitly subclassed and must not be final 
  </code></pre>
  
  <p>I know this is because the <code>App</code> class should be declared as <code>open</code>. 
  To the best of my knowledge the Gradle Spring Boot plugin for Kotlin should be in charge of making an <code>@SpringBootApplication</code> annotated class <code>open</code> for me behind the curtains. So I tried adding the following plugin: </p>
  
  <p><code>kotlin("plugin.spring") version "1.3.72"</code></p>
  
  <p>(where <code>version "1.3.72"</code> corresponds to the Kotlin version)</p>
  
  <p>And the exception is gone, as expected.
  However, this approach is against the recommended guideline of not hard-coding the Kotlin version in the Gradle configuration.</p>
  
  <p>What are the best practices for configuring Spring Boot using the Kotlin DSL so I do not have to hard-code the Kotlin version in my build script ? 
  Maybe there is a way to get rid of the warning in IntelliJ without having to add the <code>kotlin("plugin.spring") version "1.3.72"</code> plugin ?
  I think this may be an IntelliJ specific issue since I do not see any similar warning when building or executing the project with gradle from a terminal even if the <code>kotlin("plugin.spring")</code> is not present.</p>