From 083ec8734f45210d78e2767fceeba8ae97d2cb80 Mon Sep 17 00:00:00 2001 From: AsifNawaz-cnic Date: Wed, 13 Nov 2024 14:45:24 +0000 Subject: [PATCH] feat(additional options): added support for additional parameters --- README.md | 1 + src/maven.js | 18 ++++++++++++------ src/plugin-config.js | 4 +++- src/prepare.js | 5 +++-- src/success.js | 5 +++-- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5ccc330..2a55f78 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,5 @@ Was inspired by https://github.com/conveyal/maven-semantic-release. It differs i | snapshotCommitMessage | string | "'chore:" | setting next snapshot version [skip ci]' The commit message used if a new snapshot version should be created. | | debug | boolean | false | Sets the `-X` option for all maven calls. | | mvnw | boolean | false | Use the mvnw script instead of mvn | +| [options] | string | | Sets the additional options e.g. `-Pdev` | diff --git a/src/maven.js b/src/maven.js index 147d3a9..90f1904 100644 --- a/src/maven.js +++ b/src/maven.js @@ -29,10 +29,11 @@ function settingsOption(settingsPath) { * @param {string|undefined} settingsPath * @param {boolean} processAllModules * @param {boolean} debug + * @param {string} options * @returns {Promise} * @private */ -async function updateVersion(logger, mvnw, versionStr, settingsPath, processAllModules, debug) { +async function updateVersion(logger, mvnw, versionStr, settingsPath, processAllModules, debug, options) { logger.log(`Updating pom.xml to version ${versionStr}`); const command = mvnw ? './mvnw' : 'mvn'; @@ -50,7 +51,8 @@ async function updateVersion(logger, mvnw, versionStr, settingsPath, processAllM '--no-transfer-progress', '-DgenerateBackupPoms=false', `-DnewVersion=${versionStr}`, - ...processAllModulesOption + ...processAllModulesOption, + ...options ] ); } catch (e) { @@ -66,10 +68,11 @@ async function updateVersion(logger, mvnw, versionStr, settingsPath, processAllM * @param {string|undefined} settingsPath * @param {boolean} processAllModules * @param {boolean} debug + * @param {string} options * @returns {Promise} * @private */ -async function updateSnapshotVersion(logger, mvnw, settingsPath, processAllModules, debug) { +async function updateSnapshotVersion(logger, mvnw, settingsPath, processAllModules, debug, options) { logger.log('Update pom.xml to next snapshot version'); const command = mvnw ? './mvnw' : 'mvn'; @@ -87,7 +90,8 @@ async function updateSnapshotVersion(logger, mvnw, settingsPath, processAllModul '--no-transfer-progress', '-DnextSnapshot=true', '-DgenerateBackupPoms=false', - ...processAllModulesOption + ...processAllModulesOption, + ...options ] ); } catch (e) { @@ -105,10 +109,11 @@ async function updateSnapshotVersion(logger, mvnw, settingsPath, processAllModul * @param {string|undefined} settingsPath * @param {boolean} clean * @param {boolean} debug + * @param {string} options * @returns {Promise} * @private */ -async function deploy(logger, mvnw, nextVersion, mavenTarget, settingsPath, clean, debug) { +async function deploy(logger, mvnw, nextVersion, mavenTarget, settingsPath, clean, debug, options) { logger.log(`Deploying version ${nextVersion} with maven`); const command = mvnw ? './mvnw' : 'mvn'; @@ -125,7 +130,8 @@ async function deploy(logger, mvnw, nextVersion, mavenTarget, settingsPath, clea ...debugOption, '--batch-mode', '--no-transfer-progress', - '-DskipTests' + '-DskipTests', + ...options ] ); } catch (e) { diff --git a/src/plugin-config.js b/src/plugin-config.js index 4193a88..1696861 100644 --- a/src/plugin-config.js +++ b/src/plugin-config.js @@ -12,6 +12,7 @@ * @property {string} snapshotCommitMessage='chore: setting next snapshot version [skip ci]' The commit message used if a new snapshot version should be created. * @property {boolean} debug=false Sets the `-X` option for all maven calls. * @property {boolean} mvnw=false Use the mvnw script instead of mvn + * @property {string} opts=assign additional set of options */ const SemanticReleaseError = require("@semantic-release/error"); @@ -29,7 +30,8 @@ function evaluateConfig(config) { updateSnapshotVersion: false, snapshotCommitMessage: 'chore: setting next snapshot version [skip ci]', debug: false, - mvnw: false + mvnw: false, + opts: '' }, config); if (withDefaults.settingsPath && !/^[\w~./-]*$/.test(withDefaults.settingsPath)) { diff --git a/src/prepare.js b/src/prepare.js index 7c32ea5..c6cb441 100644 --- a/src/prepare.js +++ b/src/prepare.js @@ -27,8 +27,9 @@ module.exports = async function prepare(pluginConfig, { settingsPath, processAllModules, debug, - mvnw + mvnw, + opts } = evaluateConfig(pluginConfig); - await updateVersion(logger, mvnw, nextRelease.version, settingsPath, processAllModules, debug); + await updateVersion(logger, mvnw, nextRelease.version, settingsPath, processAllModules, debug, opts); }; diff --git a/src/success.js b/src/success.js index fb9dad3..7b553fb 100644 --- a/src/success.js +++ b/src/success.js @@ -32,14 +32,15 @@ module.exports = async function success(pluginConfig, { processAllModules, debug, settingsPath, - mvnw + mvnw, + opts } = evaluateConfig(pluginConfig) if (!updateSnapshotVersionOpt) { return; } - await updateSnapshotVersion(logger, mvnw, settingsPath, processAllModules, debug); + await updateSnapshotVersion(logger, mvnw, settingsPath, processAllModules, debug, opts); if (!options?.repositoryUrl) { logger.error('No git repository url configured. No files are commited.'); return;