@@ -123151,15 +123151,13 @@ const os = __importStar(__nccwpck_require__(22037));
123151
123151
const xmlbuilder2_1 = __nccwpck_require__(70151);
123152
123152
const constants = __importStar(__nccwpck_require__(69042));
123153
123153
const gpg = __importStar(__nccwpck_require__(23759));
123154
- const util_1 = __nccwpck_require__(92629);
123155
- function configureAuthentication() {
123154
+ function configureAuthentication(overwriteSettings) {
123156
123155
return __awaiter(this, void 0, void 0, function* () {
123157
123156
const id = core.getInput(constants.INPUT_SERVER_ID);
123158
123157
const username = core.getInput(constants.INPUT_SERVER_USERNAME);
123159
123158
const password = core.getInput(constants.INPUT_SERVER_PASSWORD);
123160
123159
const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) ||
123161
123160
path.join(os.homedir(), constants.M2_DIR);
123162
- const overwriteSettings = (0, util_1.getBooleanInput)(constants.INPUT_OVERWRITE_SETTINGS, true);
123163
123161
const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) ||
123164
123162
constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
123165
123163
const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE) ||
@@ -123455,7 +123453,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) {
123455
123453
"use strict";
123456
123454
123457
123455
Object.defineProperty(exports, "__esModule", ({ value: true }));
123458
- exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
123456
+ exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_ADD_TO_PATH = exports.INPUT_UPDATE_JAVA_HOME = exports.INPUT_UPDATE_TOOLCHAINS_ONLY = exports. INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
123459
123457
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
123460
123458
exports.INPUT_JAVA_VERSION = 'java-version';
123461
123459
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
@@ -123469,6 +123467,9 @@ exports.INPUT_SERVER_USERNAME = 'server-username';
123469
123467
exports.INPUT_SERVER_PASSWORD = 'server-password';
123470
123468
exports.INPUT_SETTINGS_PATH = 'settings-path';
123471
123469
exports.INPUT_OVERWRITE_SETTINGS = 'overwrite-settings';
123470
+ exports.INPUT_UPDATE_TOOLCHAINS_ONLY = 'update-toolchains-only';
123471
+ exports.INPUT_UPDATE_JAVA_HOME = 'update-env-javahome';
123472
+ exports.INPUT_ADD_TO_PATH = 'add-to-env-path';
123472
123473
exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key';
123473
123474
exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
123474
123475
exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
@@ -123730,6 +123731,8 @@ class JavaBase {
123730
123731
this.architecture = installerOptions.architecture || os_1.default.arch();
123731
123732
this.packageType = installerOptions.packageType;
123732
123733
this.checkLatest = installerOptions.checkLatest;
123734
+ this.updateEnvJavaHome = installerOptions.updateEnvJavaHome;
123735
+ this.addToEnvPath = installerOptions.addToEnvPath;
123733
123736
}
123734
123737
setupJava() {
123735
123738
return __awaiter(this, void 0, void 0, function* () {
@@ -123831,8 +123834,18 @@ class JavaBase {
123831
123834
}
123832
123835
setJavaDefault(version, toolPath) {
123833
123836
const majorVersion = version.split('.')[0];
123834
- core.exportVariable('JAVA_HOME', toolPath);
123835
- core.addPath(path_1.default.join(toolPath, 'bin'));
123837
+ if (this.updateEnvJavaHome) {
123838
+ core.exportVariable('JAVA_HOME', toolPath);
123839
+ }
123840
+ else {
123841
+ core.info(`Skip updating env.JAVA_HOME according to ${constants_1.INPUT_UPDATE_JAVA_HOME}`);
123842
+ }
123843
+ if (this.addToEnvPath) {
123844
+ core.addPath(path_1.default.join(toolPath, 'bin'));
123845
+ }
123846
+ else {
123847
+ core.info(`Skip adding to env.PATH according to ${constants_1.INPUT_ADD_TO_PATH}`);
123848
+ }
123836
123849
core.setOutput('distribution', this.distribution);
123837
123850
core.setOutput('path', toolPath);
123838
123851
core.setOutput('version', version);
@@ -126199,6 +126212,10 @@ function run() {
126199
126212
const cache = core.getInput(constants.INPUT_CACHE);
126200
126213
const cacheDependencyPath = core.getInput(constants.INPUT_CACHE_DEPENDENCY_PATH);
126201
126214
const checkLatest = (0, util_1.getBooleanInput)(constants.INPUT_CHECK_LATEST, false);
126215
+ const updateToolchainsOnly = (0, util_1.getBooleanInput)(constants.INPUT_UPDATE_TOOLCHAINS_ONLY, false);
126216
+ const overwriteSettings = (0, util_1.getBooleanInput)(constants.INPUT_OVERWRITE_SETTINGS, !updateToolchainsOnly);
126217
+ const updateEnvJavaHome = (0, util_1.getBooleanInput)(constants.INPUT_UPDATE_JAVA_HOME, !updateToolchainsOnly);
126218
+ const addToEnvPath = (0, util_1.getBooleanInput)(constants.INPUT_ADD_TO_PATH, !updateToolchainsOnly);
126202
126219
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
126203
126220
core.startGroup('Installed distributions');
126204
126221
if (versions.length !== toolchainIds.length) {
@@ -126213,7 +126230,11 @@ function run() {
126213
126230
checkLatest,
126214
126231
distributionName,
126215
126232
jdkFile,
126216
- toolchainIds
126233
+ toolchainIds,
126234
+ updateToolchainsOnly,
126235
+ overwriteSettings,
126236
+ updateEnvJavaHome,
126237
+ addToEnvPath
126217
126238
};
126218
126239
if (!versions.length) {
126219
126240
core.debug('java-version input is empty, looking for java-version-file input');
@@ -126231,7 +126252,7 @@ function run() {
126231
126252
core.endGroup();
126232
126253
const matchersPath = path.join(__dirname, '..', '..', '.github');
126233
126254
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
126234
- yield auth.configureAuthentication();
126255
+ yield auth.configureAuthentication(overwriteSettings );
126235
126256
if (cache && (0, util_1.isCacheFeatureAvailable)()) {
126236
126257
yield (0, cache_1.restore)(cache, cacheDependencyPath);
126237
126258
}
@@ -126244,19 +126265,21 @@ function run() {
126244
126265
run();
126245
126266
function installVersion(version, options, toolchainId = 0) {
126246
126267
return __awaiter(this, void 0, void 0, function* () {
126247
- const { distributionName, jdkFile, architecture, packageType, checkLatest, toolchainIds } = options;
126268
+ const { distributionName, jdkFile, architecture, packageType, checkLatest, toolchainIds, updateToolchainsOnly, overwriteSettings, updateEnvJavaHome, addToEnvPath } = options;
126248
126269
const installerOptions = {
126270
+ version,
126249
126271
architecture,
126250
126272
packageType,
126251
126273
checkLatest,
126252
- version
126274
+ updateEnvJavaHome,
126275
+ addToEnvPath
126253
126276
};
126254
126277
const distribution = (0, distribution_factory_1.getJavaDistribution)(distributionName, installerOptions, jdkFile);
126255
126278
if (!distribution) {
126256
126279
throw new Error(`No supported distribution was found for input ${distributionName}`);
126257
126280
}
126258
126281
const result = yield distribution.setupJava();
126259
- yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[toolchainId]);
126282
+ yield toolchains.configureToolchains(version, distributionName, result.path, overwriteSettings || updateToolchainsOnly, toolchainIds[toolchainId]);
126260
126283
core.info('');
126261
126284
core.info('Java configuration:');
126262
126285
core.info(` Distribution: ${distributionName}`);
@@ -126314,15 +126337,13 @@ const path = __importStar(__nccwpck_require__(71017));
126314
126337
const core = __importStar(__nccwpck_require__(42186));
126315
126338
const io = __importStar(__nccwpck_require__(47351));
126316
126339
const constants = __importStar(__nccwpck_require__(69042));
126317
- const util_1 = __nccwpck_require__(92629);
126318
126340
const xmlbuilder2_1 = __nccwpck_require__(70151);
126319
- function configureToolchains(version, distributionName, jdkHome, toolchainId) {
126341
+ function configureToolchains(version, distributionName, jdkHome, updateToolchains, toolchainId) {
126320
126342
return __awaiter(this, void 0, void 0, function* () {
126321
126343
const vendor = core.getInput(constants.INPUT_MVN_TOOLCHAIN_VENDOR) || distributionName;
126322
126344
const id = toolchainId || `${vendor}_${version}`;
126323
126345
const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) ||
126324
126346
path.join(os.homedir(), constants.M2_DIR);
126325
- const overwriteSettings = (0, util_1.getBooleanInput)(constants.INPUT_OVERWRITE_SETTINGS, true);
126326
126347
yield createToolchainsSettings({
126327
126348
jdkInfo: {
126328
126349
version,
@@ -126331,20 +126352,20 @@ function configureToolchains(version, distributionName, jdkHome, toolchainId) {
126331
126352
jdkHome
126332
126353
},
126333
126354
settingsDirectory,
126334
- overwriteSettings
126355
+ updateToolchains
126335
126356
});
126336
126357
});
126337
126358
}
126338
126359
exports.configureToolchains = configureToolchains;
126339
- function createToolchainsSettings({ jdkInfo, settingsDirectory, overwriteSettings }) {
126360
+ function createToolchainsSettings({ jdkInfo, settingsDirectory, updateToolchains }) {
126340
126361
return __awaiter(this, void 0, void 0, function* () {
126341
- core.info(`Creating ${constants.MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`);
126362
+ core.info(`Adding a toolchain entry in ${constants.MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`);
126342
126363
// when an alternate m2 location is specified use only that location (no .m2 directory)
126343
126364
// otherwise use the home/.m2/ path
126344
126365
yield io.mkdirP(settingsDirectory);
126345
126366
const originalToolchains = yield readExistingToolchainsFile(settingsDirectory);
126346
126367
const updatedToolchains = generateToolchainDefinition(originalToolchains, jdkInfo.version, jdkInfo.vendor, jdkInfo.id, jdkInfo.jdkHome);
126347
- yield writeToolchainsFileToDisk(settingsDirectory, updatedToolchains, overwriteSettings );
126368
+ yield writeToolchainsFileToDisk(settingsDirectory, updatedToolchains, updateToolchains );
126348
126369
});
126349
126370
}
126350
126371
exports.createToolchainsSettings = createToolchainsSettings;
@@ -126410,18 +126431,18 @@ function readExistingToolchainsFile(directory) {
126410
126431
return '';
126411
126432
});
126412
126433
}
126413
- function writeToolchainsFileToDisk(directory, settings, overwriteSettings ) {
126434
+ function writeToolchainsFileToDisk(directory, settings, updateToolchains ) {
126414
126435
return __awaiter(this, void 0, void 0, function* () {
126415
126436
const location = path.join(directory, constants.MVN_TOOLCHAINS_FILE);
126416
- const settingsExists = fs.existsSync(location);
126417
- if (settingsExists && overwriteSettings ) {
126418
- core.info(`Overwriting existing file ${location}`);
126437
+ const toolchainsExists = fs.existsSync(location);
126438
+ if (toolchainsExists && updateToolchains ) {
126439
+ core.info(`Updating existing file ${location}`);
126419
126440
}
126420
- else if (!settingsExists ) {
126421
- core.info(`Writing to ${location}`);
126441
+ else if (!toolchainsExists ) {
126442
+ core.info(`Creating file ${location}`);
126422
126443
}
126423
126444
else {
126424
- core.info(`Skipping generation of ${location} because file already exists and overwriting is not enabled`);
126445
+ core.info(`Skipping update of ${location} since file already exists and updating is not enabled`);
126425
126446
return;
126426
126447
}
126427
126448
return fs.writeFileSync(location, settings, {
0 commit comments