From 4014b75309464286709699a0e40236d3512de355 Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Mon, 15 Sep 2025 14:56:45 +0100 Subject: [PATCH] Only enable JAVA dependency minimisation when caching is enabled --- lib/init-action.js | 2 +- src/init-action.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/init-action.js b/lib/init-action.js index 2f2fc6a350..d98384d27c 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -90679,7 +90679,7 @@ exec ${goBinaryPath} "$@"` logger.debug( `${"CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */} is already set to '${process.env["CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */]}', so the Action will not override it.` ); - } else if (minimizeJavaJars && config.buildMode === "none" /* None */ && config.languages.includes("java" /* java */)) { + } else if (minimizeJavaJars && config.dependencyCachingEnabled && config.buildMode === "none" /* None */ && config.languages.includes("java" /* java */)) { core13.exportVariable( "CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */, "true" diff --git a/src/init-action.ts b/src/init-action.ts index c28b1e72c9..508d17333b 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -608,13 +608,17 @@ async function run() { // If the feature flag to minimize Java dependency jars is enabled, and we are doing a Java // `build-mode: none` analysis (i.e. the flag is relevant), then set the environment variable - // that enables the corresponding option in the Java extractor. + // that enables the corresponding option in the Java extractor. We also only do this if + // dependency caching is enabled, since the option is intended to reduce the size of + // dependency caches, but the jar-rewriting does have a performance cost that we'd like to avoid + // when caching is not being used. if (process.env[EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS]) { logger.debug( `${EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS} is already set to '${process.env[EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS]}', so the Action will not override it.`, ); } else if ( minimizeJavaJars && + config.dependencyCachingEnabled && config.buildMode === BuildMode.None && config.languages.includes(KnownLanguage.java) ) {