mirror of
https://github.com/actions/setup-java.git
synced 2026-08-10 17:42:58 +00:00
Optimize Maven configuration warm path (#1182)
* Optimize Maven configuration warm path Avoid eager Maven XML initialization on warm JDK runs by using deterministic serializers for new Maven settings/toolchains files, lazy-loading xmlbuilder2 for existing toolchains merges, and deferring Maven configuration modules until after Java setup. Add targeted tests for XML escaping, lazy xmlbuilder2 loading, concurrent Maven configuration, and a manual benchmark workflow for warm-path validation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b * Address Maven optimization PR feedback Make the toolchain XML generator consistently async, remove redundant Maven configuration await handling, and reuse the existing XML test helper. Configure CodeQL to skip generated dist output so newly split vendored chunks do not report duplicate generated-code alerts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b * Apply rubber duck review suggestions Document XML attribute escaping, simplify Maven configuration awaiting, and add a regression test that feeds fast-path toolchains output into the merge path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b * Delete .github/codeql/codeql-config.yml * Update codeql-analysis.yml * Replace xmlbuilder2 in Maven toolchain merge Use fast-xml-parser for existing toolchains.xml parsing and serialize merged Maven toolchains deterministically. This removes the bundled xmlbuilder2 DOM/XML builder chunk from dist while preserving merge behavior for custom attributes, custom toolchains, partial entries, duplicate filtering, and escaping. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b * Move Maven benchmark out of setup-java Remove the Maven warm-path benchmark workflow and helper script from setup-java. Benchmark coverage is being moved to actions/setup-java-benchmarks so this action repository only carries the runtime optimization, tests, and generated distribution artifacts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b --------- Copilot-Session: 4dc58426-5e20-44cb-af16-8da0965fac3b
This commit is contained in:
+34
-40
@@ -4,11 +4,10 @@ import * as io from '@actions/io';
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
|
||||
import {create as xmlCreate} from 'xmlbuilder2';
|
||||
import * as constants from './constants.js';
|
||||
import * as gpg from './gpg.js';
|
||||
import {getBooleanInput} from './util.js';
|
||||
import {escapeXmlText} from './xml.js';
|
||||
|
||||
export async function configureAuthentication() {
|
||||
const id = core.getInput(constants.INPUT_SERVER_ID);
|
||||
@@ -101,53 +100,48 @@ export function generate(
|
||||
passwordEnvVar: string,
|
||||
gpgPassphraseEnvVar?: string | undefined
|
||||
) {
|
||||
const xmlObj: {[key: string]: any} = {
|
||||
settings: {
|
||||
'@xmlns': 'http://maven.apache.org/SETTINGS/1.0.0',
|
||||
'@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
'@xsi:schemaLocation':
|
||||
'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd',
|
||||
interactiveMode: false,
|
||||
servers: {
|
||||
server: [
|
||||
{
|
||||
id: id,
|
||||
username: `\${env.${usernameEnvVar}}`,
|
||||
password: `\${env.${passwordEnvVar}}`
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// The maven-gpg-plugin reads the passphrase from the environment variable
|
||||
// named by the `gpg.passphraseEnvName` property (default MAVEN_GPG_PASSPHRASE).
|
||||
// Only configure it when the requested env var name differs from that default;
|
||||
// otherwise the plugin already reads the right variable and no extra settings
|
||||
// are needed. Writing `gpg.passphrase` to settings.xml is deprecated and fails
|
||||
// when the plugin's `bestPractices` mode is enabled.
|
||||
if (
|
||||
const includeGpgPassphraseProfile =
|
||||
gpgPassphraseEnvVar &&
|
||||
gpgPassphraseEnvVar !== constants.MAVEN_GPG_PASSPHRASE_DEFAULT_ENV
|
||||
) {
|
||||
xmlObj.settings.profiles = {
|
||||
profile: {
|
||||
id: constants.GPG_PASSPHRASE_PROFILE_ID,
|
||||
properties: {
|
||||
'gpg.passphraseEnvName': gpgPassphraseEnvVar
|
||||
}
|
||||
}
|
||||
};
|
||||
xmlObj.settings.activeProfiles = {
|
||||
activeProfile: constants.GPG_PASSPHRASE_PROFILE_ID
|
||||
};
|
||||
gpgPassphraseEnvVar !== constants.MAVEN_GPG_PASSPHRASE_DEFAULT_ENV;
|
||||
|
||||
const lines = [
|
||||
'<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"',
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
|
||||
' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">',
|
||||
' <interactiveMode>false</interactiveMode>',
|
||||
' <servers>',
|
||||
' <server>',
|
||||
` <id>${escapeXmlText(id)}</id>`,
|
||||
` <username>${escapeXmlText(`\${env.${usernameEnvVar}}`)}</username>`,
|
||||
` <password>${escapeXmlText(`\${env.${passwordEnvVar}}`)}</password>`,
|
||||
' </server>',
|
||||
' </servers>'
|
||||
];
|
||||
|
||||
if (includeGpgPassphraseProfile) {
|
||||
lines.push(
|
||||
' <profiles>',
|
||||
' <profile>',
|
||||
` <id>${constants.GPG_PASSPHRASE_PROFILE_ID}</id>`,
|
||||
' <properties>',
|
||||
` <gpg.passphraseEnvName>${escapeXmlText(gpgPassphraseEnvVar)}</gpg.passphraseEnvName>`,
|
||||
' </properties>',
|
||||
' </profile>',
|
||||
' </profiles>',
|
||||
' <activeProfiles>',
|
||||
` <activeProfile>${constants.GPG_PASSPHRASE_PROFILE_ID}</activeProfile>`,
|
||||
' </activeProfiles>'
|
||||
);
|
||||
}
|
||||
|
||||
return xmlCreate(xmlObj).end({
|
||||
headless: true,
|
||||
prettyPrint: true,
|
||||
width: 80
|
||||
});
|
||||
lines.push('</settings>');
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
async function write(
|
||||
|
||||
Reference in New Issue
Block a user