Add feature flag to roll out JAR minimization in the Java extractor

This commit is contained in:
Nick Rolfe
2025-09-10 17:26:55 +01:00
parent df1fe23118
commit 0abf548bb3
15 changed files with 163 additions and 23 deletions

View File

@@ -78,6 +78,7 @@ import {
wrapError,
checkActionVersion,
getErrorMessage,
BuildMode,
} from "./util";
import { validateWorkflow } from "./workflow";
@@ -546,8 +547,16 @@ async function run() {
}
// Restore dependency cache(s), if they exist.
const minimizeJavaJars = await features.getValue(
Feature.JavaMinimizeDependencyJars,
codeql,
);
if (shouldRestoreCache(config.dependencyCachingEnabled)) {
await downloadDependencyCaches(config.languages, logger);
await downloadDependencyCaches(
config.languages,
logger,
minimizeJavaJars,
);
}
// Suppress warnings about disabled Python library extraction.
@@ -597,6 +606,24 @@ 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.
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.buildMode === BuildMode.None &&
config.languages.includes(KnownLanguage.java)
) {
core.exportVariable(
EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS,
"true",
);
}
const { registriesAuthTokens, qlconfigFile } =
await configUtils.generateRegistries(
getOptionalInput("registries"),