0

I'm running a gradle project with Kotlin and Java source code. I need to configure the testing environment in GitHub codespaces with VS code, I cannot use JetBrains Gateway. Even though the Gradle tasks are running successfully, the project is being built, etc. Whenever I try to run a test or work in the IDE, I receive errors.

import something.from.kotlin.KotlinCode;
import something.from.java.JavaCodeTwo;

class JavaCode {

    public void method() {
        KotlinCode kc = new KotlinCode(); // this line does not work
    }

}

On the first line vs code shows the red error: The import something.from.kotlin.KotlinCode cannot be resolved*

Any ideas on how can I make it up and running? Right now I can only run tests using ./gradlew test I would like to be able to run and debug them using vs co

I have the following extensions installed:

None of those solved my issue.

In order to at least run some test with the debugger I've prepared a script:

#!/bin/bash
export GRADLE_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"
echo 'here'
 ../gradlew -p .. clean test --tests '*SomeTest*'

enter image description here

Test runs in the debug mode on 5005, later I'm attaching a debugger using vs code and this launch.json config:

{
            "type": "java",
            "name": "Attach to Remote Program",
            "request": "attach",
            "projectName": "projectName", // the name is correct
            "hostName": "localhost",
            "port": "5005"        
        },

and even though I can stop the program from the debug panel, none of my breakpoints work:
enter image description here

any idea how could I fix the kotlin + java interoperability in the github codespace running vs code, or at least configure the debugger so I could set up the breakpoints ?

  • I'm afraid it's not something you can fix; it's more of an issue in the mixed Java-Kotlin projects in VSCode (and codespaces). You should report it in their issue tracker. – asm0dey Jul 24 '23 at 12:03

1 Answers1

0

Make sure the correct JDK path is set, you can clean and rebuild the project with the following commands.

./gradlew clean
./gradlew build

Also try Ctrl+Shift+P --> Java: Clean Java Language Server Workspace and restart vscode.

JialeDu
  • 6,021
  • 2
  • 5
  • 24