дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
fix(java): resolve application classpaths independently of working directory (#493)
Run and Debug passed the configuration working directory to java_resolve_launch as the module, so changing the working directory also changed which jdtls project supplied the classpath and failed with "references non-existing project". Java application configurations now store their module at detection and creation, keep it when the working directory changes, and clear it when the main class changes. Older saved configurations resolve it from the main class source file. The Kotlin debugger check also uses the module directory. Fixes #435
Цей коміт міститься в:
1 джерело
2754cf327f
коміт
0660f3c020
17 files changed
+265
-30
No files matched your search
@@ -11,6 +11,14 @@ vi.mock("@/platform/ipc", async (orig) => {
|
||||
...real,
|
||||
commands: {
|
||||
...real.commands,
|
||||
findFiles: (name: string) =>
|
||||
ok(
|
||||
name === "Main.java"
|
||||
? [{ path: "/p/api/src/main/java/a/Main.java", relPath: "api/src/main/java/a/Main.java" }]
|
||||
: [],
|
||||
),
|
||||
fsReadText: () => ok("package a;\npublic class Main {}"),
|
||||
runConfigs: () => ok([]),
|
||||
fsReadDir: (path: string) =>
|
||||
ok(
|
||||
kotlinFiles && path.endsWith("/src")
|
||||
@@ -49,6 +57,7 @@ const app: RunConfig = {
|
||||
command: "java",
|
||||
args: ["-Xmx1g", "-cp", "${classpath}", "a.Main", "--port", "8081 x"],
|
||||
cwd: "api",
|
||||
module: "api",
|
||||
env: { A: "1" },
|
||||
detected: true,
|
||||
isTest: false,
|
||||
@@ -144,3 +153,14 @@ describe("Java debugging (java-debug through jdtls)", () => {
|
||||
expect(JSON.parse(l.extraJson!)).toMatchObject({ debugServer: 41234, hostName: "127.0.0.1", port: 5005 });
|
||||
});
|
||||
});
|
||||
|
||||
it.each(["sibling", "/outside/modules"])("debugs from %s with the main class module", async (cwd) => {
|
||||
kotlinFiles = false;
|
||||
for (const module of ["api", undefined]) {
|
||||
invoked.length = 0;
|
||||
const launch = await javaLaunchConfig({ ...app, module, cwd }, "/p");
|
||||
expect(invoked).toContainEqual(["javaResolveLaunch", ["api", false, true, expect.any(Number)]]);
|
||||
expect(invoked).toContainEqual(["javaDebugServer", ["api"]]);
|
||||
expect(launch.cwd).toBe(cwd.startsWith("/") ? cwd : `/p/${cwd}`);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Заблокувати користувача