kotlin-allopen doesn't work in IntelliJ

Answered

Start a brand new Spring-Boot project with start.spring.io:

  • Gradle
  • Kotlin
  • Spring-Boot 1.5.10

Import into IntellJ:

Enable Annotation Processing:

It still want's me to mark all my classes with open.

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'DemoApplication' may not be final. Remove the final modifier to continue.
Offending resource: com.example.demo.DemoApplication

Gradle command line works no problem:

$ gradle bootRun: 
...
2018-02-01 14:53:28.394 INFO 13497 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-02-01 14:53:28.403 INFO 13497 --- [ main] com.example.demo.DemoApplicationKt : Started DemoApplicationKt in 2.601 seconds (JVM running for 3.156)

Here is the Gradle File:

buildscript {
ext {
kotlinVersion = '1.2.20'
springBootVersion = '1.5.10.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
}
}

apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

repositories {
mavenCentral()
}


dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
testCompile('org.springframework.boot:spring-boot-starter-test')
}

Versions:

IntelliJ IDEA 2017.3.4 (Ultimate Edition)
Build #IU-173.4548.28, built on January 29, 2018

JRE: 1.8.0_152-release-1024-b11-amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Gradle: 4.5

0
2 comments
Avatar
Permanently deleted user

Link to the same issue in the Kotlin issue tracker: https://youtrack.jetbrains.com/issue/KT-22644

0

Please sign in to leave a comment.