Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Gradle Kotlin DSL #33

Open
jul1u5 opened this issue Apr 20, 2020 · 6 comments
Open

Issues with Gradle Kotlin DSL #33

jul1u5 opened this issue Apr 20, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@jul1u5
Copy link

jul1u5 commented Apr 20, 2020

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:
Kotlin errors

Extension version
0.2.11

@jul1u5 jul1u5 added the bug Something isn't working label Apr 20, 2020
@fwcd
Copy link
Owner

fwcd commented Jun 30, 2020

Please try adding the option "kotlin.compiler.jvm.target": "1.8" to your VSCode settings.

@jul1u5
Copy link
Author

jul1u5 commented Jun 30, 2020

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:

image

NOTE: The code has changed a little bit since I posted it here

@cmitchell
Copy link

cmitchell commented Jun 7, 2021

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.

@Baneeishaque
Copy link

Same issue...

@ptrckdev
Copy link

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.

image

Could developing in WSL be part of the problem? The Extension is installed inside WSL

image

@megabyte6
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants