vscode-kotlin
vscode-kotlin copied to clipboard
Issues with Gradle Kotlin DSL
Thanks for creating this extension!
Describe the bug I want to use Kotlin DSL to configure Gradle build for a project which uses Java. However, the extension produces a lot of errors.
To Reproduce
Here is my build.gradle.kts
file:
plugins {
java
application
}
repositories {
jcenter()
}
dependencies {
implementation("junit:junit:4.13")
testImplementation("junit:junit:4.13")
}
configurations {
implementation {
resolutionStrategy.failOnVersionConflict()
}
}
sourceSets {
main {
java.setSrcDirs(listOf("src"))
}
test {
java.setSrcDirs(listOf("src"))
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
application {
mainClassName = "app.App"
}
val test by tasks.getting(Test::class) {
useJUnitPlatform()
}
Here are the errors:
Extension version 0.2.11
Please try adding the option "kotlin.compiler.jvm.target": "1.8"
to your VSCode settings.
Thanks for the response. I added the option and restarted the language server. JVM errors have disappeared, but the extension still seems to not understand some of the Gradle functions:
NOTE: The code has changed a little bit since I posted it here
Same issue here. Didn't run into it until I enabled this extension, and changing Kotlin › Compiler › Jvm: Target from "default" to 1.8 for both User and Workspace as mentioned above still gives red error lines in the gradle.build.kts file.
Same issue...
Same Issue aswell in settings.gradle.kts
as in build.gradle.kts
for a gradle init
project with Kotlin and Kotlin DSL without any changes made.
Could developing in WSL be part of the problem? The Extension is installed inside WSL
@ptrckdev No, it's not just WSL. I have the same issue. I'm on Fedora 38 but Linux shouldn't be the issue. I think it's just that the plugin isn't designed to work with Kotlin DSL files. I was really hoping it would work but at the moment, that doesn't seem possible. In my opinion, Kotlin DSL support is even more useful than Kotlin project support since Gradle now prefers Kotlin DSL over Groovy DSL. For the time being, I think I'll just use IntelliJ IDEA for my Java/Kotlin work and use VSCode for the other stuff.