Skip to content

Commit

Permalink
feat(additional options): added support for additional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
AsifNawaz-cnic committed Nov 13, 2024
1 parent 45b8903 commit 083ec87
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ Was inspired by https://github.com/conveyal/maven-semantic-release. It differs i
| snapshotCommitMessage | <code>string</code> | <code>&quot;&#x27;chore:&quot;</code> | setting next snapshot version [skip ci]' The commit message used if a new snapshot version should be created. |
| debug | <code>boolean</code> | <code>false</code> | Sets the `-X` option for all maven calls. |
| mvnw | <code>boolean</code> | <code>false</code> | Use the mvnw script instead of mvn |
| [options] | <code>string</code> | | Sets the additional options e.g. `-Pdev` |
<!-- AUTO_GENERATED_OPTIONS -->
18 changes: 12 additions & 6 deletions src/maven.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ function settingsOption(settingsPath) {
* @param {string|undefined} settingsPath
* @param {boolean} processAllModules
* @param {boolean} debug
* @param {string} options
* @returns {Promise<void>}
* @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';
Expand All @@ -50,7 +51,8 @@ async function updateVersion(logger, mvnw, versionStr, settingsPath, processAllM
'--no-transfer-progress',
'-DgenerateBackupPoms=false',
`-DnewVersion=${versionStr}`,
...processAllModulesOption
...processAllModulesOption,
...options
]
);
} catch (e) {
Expand All @@ -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<void>}
* @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';
Expand All @@ -87,7 +90,8 @@ async function updateSnapshotVersion(logger, mvnw, settingsPath, processAllModul
'--no-transfer-progress',
'-DnextSnapshot=true',
'-DgenerateBackupPoms=false',
...processAllModulesOption
...processAllModulesOption,
...options
]
);
} catch (e) {
Expand All @@ -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<void>}
* @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';
Expand All @@ -125,7 +130,8 @@ async function deploy(logger, mvnw, nextVersion, mavenTarget, settingsPath, clea
...debugOption,
'--batch-mode',
'--no-transfer-progress',
'-DskipTests'
'-DskipTests',
...options
]
);
} catch (e) {
Expand Down
4 changes: 3 additions & 1 deletion src/plugin-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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)) {
Expand Down
5 changes: 3 additions & 2 deletions src/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
5 changes: 3 additions & 2 deletions src/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 083ec87

Please sign in to comment.