mirror of
https://github.com/actions/setup-java.git
synced 2026-09-01 05:23:17 +01:00
Merge branch 'main' into brunoborges-fix-maven-wrapper-caching
This commit is contained in:
27
dist/setup/index.js
vendored
27
dist/setup/index.js
vendored
@@ -127351,13 +127351,11 @@ async function write(directory, settings, overwriteSettings) {
|
||||
|
||||
|
||||
|
||||
|
||||
async function configureToolchains(version, distributionName, jdkHome, toolchainId) {
|
||||
const vendor = getInput(INPUT_MVN_TOOLCHAIN_VENDOR) || distributionName;
|
||||
const id = toolchainId || `${vendor}_${version}`;
|
||||
const settingsDirectory = getInput(INPUT_SETTINGS_PATH) ||
|
||||
external_path_.join(external_os_.homedir(), M2_DIR);
|
||||
const overwriteSettings = util_getBooleanInput(INPUT_OVERWRITE_SETTINGS, true);
|
||||
await createToolchainsSettings({
|
||||
jdkInfo: {
|
||||
version,
|
||||
@@ -127365,18 +127363,17 @@ async function configureToolchains(version, distributionName, jdkHome, toolchain
|
||||
id,
|
||||
jdkHome
|
||||
},
|
||||
settingsDirectory,
|
||||
overwriteSettings
|
||||
settingsDirectory
|
||||
});
|
||||
}
|
||||
async function createToolchainsSettings({ jdkInfo, settingsDirectory, overwriteSettings }) {
|
||||
async function createToolchainsSettings({ jdkInfo, settingsDirectory }) {
|
||||
info(`Creating ${MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`);
|
||||
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
||||
// otherwise use the home/.m2/ path
|
||||
await mkdirP(settingsDirectory);
|
||||
const originalToolchains = await readExistingToolchainsFile(settingsDirectory);
|
||||
const updatedToolchains = generateToolchainDefinition(originalToolchains, jdkInfo.version, jdkInfo.vendor, jdkInfo.id, jdkInfo.jdkHome);
|
||||
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains, overwriteSettings);
|
||||
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains);
|
||||
}
|
||||
// only exported for testing purposes
|
||||
function generateToolchainDefinition(original, version, vendor, id, jdkHome) {
|
||||
@@ -127458,18 +127455,20 @@ async function readExistingToolchainsFile(directory) {
|
||||
}
|
||||
return '';
|
||||
}
|
||||
async function writeToolchainsFileToDisk(directory, settings, overwriteSettings) {
|
||||
async function writeToolchainsFileToDisk(directory, settings) {
|
||||
const location = external_path_.join(directory, MVN_TOOLCHAINS_FILE);
|
||||
const settingsExists = external_fs_namespaceObject.existsSync(location);
|
||||
if (settingsExists && overwriteSettings) {
|
||||
info(`Overwriting existing file ${location}`);
|
||||
}
|
||||
else if (!settingsExists) {
|
||||
info(`Writing to ${location}`);
|
||||
// The toolchains file is produced by a non-destructive merge (existing JDK,
|
||||
// custom, and non-jdk toolchains are preserved – see generateToolchainDefinition),
|
||||
// so it is always safe to write it. Unlike settings.xml, it is therefore not
|
||||
// gated behind the `overwrite-settings` input; that would prevent subsequent
|
||||
// setup-java runs from registering additional JDKs and silently drop the
|
||||
// toolchain entries created by earlier runs.
|
||||
if (settingsExists) {
|
||||
info(`Updating existing file ${location}`);
|
||||
}
|
||||
else {
|
||||
info(`Skipping generation of ${location} because file already exists and overwriting is not enabled`);
|
||||
return;
|
||||
info(`Writing to ${location}`);
|
||||
}
|
||||
return external_fs_namespaceObject.writeFileSync(location, settings, {
|
||||
encoding: 'utf-8',
|
||||
|
||||
Reference in New Issue
Block a user