@@ -77493,20 +77493,21 @@ const gpg = __importStar(__nccwpck_require__(88343));
7749377493const util_1 = __nccwpck_require__(54527);
7749477494function configureAuthentication() {
7749577495 return __awaiter(this, void 0, void 0, function* () {
77496- const id = core.getInput(constants.INPUT_SERVER_ID);
77497- const username = core.getInput(constants.INPUT_SERVER_USERNAME);
77498- const password = core.getInput(constants.INPUT_SERVER_PASSWORD);
77496+ const numMvnRepos = core.getInput(constants.INPUT_NUM_MVN_REPOS);
77497+ const mvnSettings = [];
7749977498 const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) ||
7750077499 path.join(os.homedir(), constants.M2_DIR);
7750177500 const overwriteSettings = (0, util_1.getBooleanInput)(constants.INPUT_OVERWRITE_SETTINGS, true);
77502- const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) ||
77503- constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
77504- const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE) ||
77505- (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
77506- if (gpgPrivateKey) {
77507- core.setSecret(gpgPrivateKey);
77501+ let gpgPrivateKey;
77502+ if (numMvnRepos === '' || core.getInput(constants.INPUT_GPG_PRIVATE_KEY)) {
77503+ gpgPrivateKey = populateMvnSettings(mvnSettings);
7750877504 }
77509- yield createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase);
77505+ else {
77506+ for (let i = 0; i < parseInt(numMvnRepos); i++) {
77507+ populateMvnSettings(mvnSettings, i);
77508+ }
77509+ }
77510+ yield createAuthenticationSettings(mvnSettings, settingsDirectory, overwriteSettings);
7751077511 if (gpgPrivateKey) {
7751177512 core.info('Importing private gpg key');
7751277513 const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || '';
@@ -77515,41 +77516,67 @@ function configureAuthentication() {
7751577516 });
7751677517}
7751777518exports.configureAuthentication = configureAuthentication;
77518- function createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase = undefined) {
77519+ function populateMvnSettings(mvnSettings, idx = -1) {
77520+ const id = core.getInput(getIndexedInputName(constants.INPUT_SERVER_ID, idx));
77521+ const username = core.getInput(getIndexedInputName(constants.INPUT_SERVER_USERNAME, idx));
77522+ const password = core.getInput(getIndexedInputName(constants.INPUT_SERVER_PASSWORD, idx));
77523+ if (username !== '' && password !== '') {
77524+ mvnSettings.push({ id: id, username: username, password: password });
77525+ }
77526+ if (idx === -1) {
77527+ const gpgPrivateKey = core.getInput(getIndexedInputName(constants.INPUT_GPG_PRIVATE_KEY, idx)) || constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
77528+ const gpgPassphrase = core.getInput(getIndexedInputName(constants.INPUT_GPG_PASSPHRASE, idx)) ||
77529+ (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
77530+ if (gpgPrivateKey) {
77531+ core.setSecret(gpgPrivateKey);
77532+ }
77533+ if (gpgPassphrase) {
77534+ mvnSettings.push({ id: 'gpg.passphrase', gpgPassphrase: gpgPassphrase });
77535+ return gpgPrivateKey;
77536+ }
77537+ }
77538+ return undefined;
77539+ }
77540+ function getIndexedInputName(inputName, idx) {
77541+ return inputName + (idx >= 0 ? '-' + idx : '');
77542+ }
77543+ function createAuthenticationSettings(mvnSettings, settingsDirectory, overwriteSettings) {
7751977544 return __awaiter(this, void 0, void 0, function* () {
77520- core.info(`Creating ${constants.MVN_SETTINGS_FILE} with server-id: ${id} `);
77545+ core.info(`Creating ${constants.MVN_SETTINGS_FILE}`);
7752177546 // when an alternate m2 location is specified use only that location (no .m2 directory)
7752277547 // otherwise use the home/.m2/ path
7752377548 yield io.mkdirP(settingsDirectory);
77524- yield write(settingsDirectory, generate(id, username, password, gpgPassphrase ), overwriteSettings);
77549+ yield write(settingsDirectory, generate(mvnSettings ), overwriteSettings);
7752577550 });
7752677551}
7752777552exports.createAuthenticationSettings = createAuthenticationSettings;
7752877553// only exported for testing purposes
77529- function generate(id, username, password, gpgPassphrase ) {
77554+ function generate(mvnSettings ) {
7753077555 const xmlObj = {
7753177556 settings: {
7753277557 '@xmlns': 'http://maven.apache.org/SETTINGS/1.0.0',
7753377558 '@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
7753477559 '@xsi:schemaLocation': 'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd',
7753577560 servers: {
77536- server: [
77537- {
77538- id: id,
77539- username: `\${env.${username}}`,
77540- password: `\${env.${password}}`
77541- }
77542- ]
77561+ server: []
7754377562 }
7754477563 }
7754577564 };
77546- if (gpgPassphrase) {
77547- const gpgServer = {
77548- id: 'gpg.passphrase',
77549- passphrase: `\${env.${gpgPassphrase}}`
77550- };
77551- xmlObj.settings.servers.server.push(gpgServer);
77552- }
77565+ mvnSettings.forEach(mvnSetting => {
77566+ if (mvnSetting.username && mvnSetting.password) {
77567+ xmlObj.settings.servers.server.push({
77568+ id: mvnSetting.id,
77569+ username: `\${env.${mvnSetting.username}}`,
77570+ password: `\${env.${mvnSetting.password}}`
77571+ });
77572+ }
77573+ if (mvnSetting.gpgPassphrase) {
77574+ xmlObj.settings.servers.server.push({
77575+ id: mvnSetting.id,
77576+ passphrase: `\${env.${mvnSetting.gpgPassphrase}}`
77577+ });
77578+ }
77579+ });
7755377580 return (0, xmlbuilder2_1.create)(xmlObj).end({
7755477581 headless: true,
7755577582 prettyPrint: true,
@@ -77805,7 +77832,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) {
7780577832"use strict";
7780677833
7780777834Object.defineProperty(exports, "__esModule", ({ value: true }));
77808- 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;
77835+ 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_NUM_MVN_REPOS = 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;
7780977836exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
7781077837exports.INPUT_JAVA_VERSION = 'java-version';
7781177838exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
@@ -77814,6 +77841,7 @@ exports.INPUT_JAVA_PACKAGE = 'java-package';
7781477841exports.INPUT_DISTRIBUTION = 'distribution';
7781577842exports.INPUT_JDK_FILE = 'jdkFile';
7781677843exports.INPUT_CHECK_LATEST = 'check-latest';
77844+ exports.INPUT_NUM_MVN_REPOS = 'mvn-repositories-len';
7781777845exports.INPUT_SERVER_ID = 'server-id';
7781877846exports.INPUT_SERVER_USERNAME = 'server-username';
7781977847exports.INPUT_SERVER_PASSWORD = 'server-password';
0 commit comments