mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
feat(plugins): a granted plugin's Java agent joins Java run configurations (API 1.10) (#3830)
Plugins that instrument the user's application had no way to get a Java agent into the JVM the IDE starts. A [[contributes.javaAgents]] entry (one per plugin, a jar inside the package, optional single-line args, API ^1.10) derives the high-risk java.agent capability; granting it records the jar's blake3 hash, and every launch re-hashes the jar and leaves out a changed or missing one until approved again. For Application, Spring Boot and JAR Application run and debug, the host adds one -javaagent argument after the VM options (java-debug vmArgs, Kotlin vmArguments), never twice, and a shortened command line keeps it as its own argument. Remote projects and run targets get no agent, with one console line. Settings › Plugins shows the agent next to the permission. Closes #3566 Co-authored-by: bertyhell <1710840+bertyhell@users.noreply.github.com>
This commit is contained in:
co-authored by
bertyhell
parent
6c9556ef54
commit
2b69d64055
@@ -15,6 +15,7 @@ import {
|
||||
} from "@/platform/ipc";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useBuildPresentation } from "@/platform/projectPresentation";
|
||||
import { isRemoteWindow } from "@/platform/remote";
|
||||
|
||||
export const CLASSPATH = "${classpath}";
|
||||
export const TEST_CLASSPATH = "${testClasspath}";
|
||||
@@ -25,6 +26,25 @@ export function isJvmApplication(config: Pick<RunConfig, "kind">): boolean {
|
||||
return JVM_APPLICATION_KINDS.includes(config.kind);
|
||||
}
|
||||
|
||||
/** Run configuration kinds whose JVM gets the plugins' Java agents (`[[contributes.javaAgents]]`). */
|
||||
const JAVA_AGENT_KINDS = ["application", "spring-boot", "jar-application"];
|
||||
|
||||
/**
|
||||
* The console line of a Java launch in a remote project, when plugins with a granted
|
||||
* `java.agent` would have added their agent: the JVM runs on the server, and agents load
|
||||
* only into JVMs on this machine. `null` otherwise. Plugins are the desktop's own.
|
||||
*/
|
||||
export async function remoteJavaAgentNote(config: Pick<RunConfig, "kind">): Promise<string | null> {
|
||||
if (!JAVA_AGENT_KINDS.includes(config.kind) || !isRemoteWindow()) return null;
|
||||
const snapshot = await call(commands.pluginList()).catch(() => null);
|
||||
const names = (snapshot?.plugins ?? [])
|
||||
.filter((p) => p.enabled && p.capabilities.some((c) => c.id === "java.agent" && c.granted))
|
||||
.map((p) => p.name);
|
||||
if (!names.length) return null;
|
||||
const list = names.join(", ");
|
||||
return tx`Java agents of ${list} were not added: they load only in local projects.` + "\n";
|
||||
}
|
||||
|
||||
/** `java` options whose value is the next argument. */
|
||||
const WITH_VALUE = new Set([
|
||||
"-cp",
|
||||
|
||||
Reference in New Issue
Block a user