diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c976747c..e649158f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -11,14 +11,14 @@ jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2.3.3
+ - uses: actions/checkout@v2.3.4
- run: |
npm ci
npm test
test_job:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2.3.3
+ - uses: actions/checkout@v2.3.4
- name: Create maven settings.xml
uses: ./
with:
@@ -27,6 +27,7 @@ jobs:
repositories: '[{"id": "foo", "url": "https://fu.bar"}]'
plugin_repositories: '[{"id": "foo-plugin", "url": "https://fu.bar.plugin"}]'
profiles: '[{ "id": "foo.profile", "name": "foo.profile", "url": "http://foo.bar.profile", "properties": { "foo": "property-1", "bar": "property-2"} }]'
+ plugin_groups: '[ "some.plugin.group.id", "some.other.plugin.group.id" ]'
- run: |
cat ~/.m2/settings.xml
diff --git a/README.md b/README.md
index 0ada4832..cfcf1d38 100644
--- a/README.md
+++ b/README.md
@@ -45,6 +45,11 @@ Reference: [Maven Settings > Plugin Repositories](http://maven.apache.org/settin
Reference: [Maven Settings > Repositories](http://maven.apache.org/settings.html#Plugin_Repositories)
+### `plugin_groups`
+**Optional** json array of plugin groups to add to settings.xml
+
+Reference: [Maven Settings > Plugin Groups](http://maven.apache.org/settings.html#Plugin_Groups)
+
### `profiles`
**Optional** json array of profiles to add to settings.xml
@@ -125,6 +130,7 @@ Reference: [Maven Settings > Profiles](http://maven.apache.org/settings.html#pro
servers: '[{ "id": "some-server", "username": "some.user", "password": "some.password" }]'
mirrors: '[{ "id": "nexus", "mirrorOf": "!my-org-snapshots,*", "url": "http://redacted/nexus/content/groups/public" }]'
profiles: '[{ "id": "foo.profile", "name": "foo.profile", "url": "http://foo.bar.profile", "properties": { "foo": "property-1", "bar": "property-2"} }]'
+ plugin_groups: '[ "some.plugin.group.id", "some.other.plugin.group.id" ]'
````
@@ -207,5 +213,10 @@ Reference: [Maven Settings > Profiles](http://maven.apache.org/settings.html#pro
+
+ some.plugin.group.id
+ some.other.plugin.group.id
+
+
````
diff --git a/action.yml b/action.yml
index 21e58c8e..be602caa 100644
--- a/action.yml
+++ b/action.yml
@@ -19,6 +19,9 @@ inputs:
profiles:
description: 'json array of profiles to add to settings.xml'
required: false
+ plugin_groups:
+ description: 'json array of plugin groups to add to settings.xml'
+ required: false
runs:
using: 'node12'
main: 'dist/index.js'
diff --git a/dist/index.js b/dist/index.js
index ec711f07..4b5b3e30 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -43,6 +43,32 @@ module.exports =
/************************************************************************/
/******/ ({
+/***/ 82:
+/***/ (function(__unusedmodule, exports) {
+
+"use strict";
+
+// We use any as a valid input type
+/* eslint-disable @typescript-eslint/no-explicit-any */
+Object.defineProperty(exports, "__esModule", { value: true });
+/**
+ * Sanitizes an input into a string so it can be passed into issueCommand safely
+ * @param input input to sanitize into a string
+ */
+function toCommandValue(input) {
+ if (input === null || input === undefined) {
+ return '';
+ }
+ else if (typeof input === 'string' || input instanceof String) {
+ return input;
+ }
+ return JSON.stringify(input);
+}
+exports.toCommandValue = toCommandValue;
+//# sourceMappingURL=utils.js.map
+
+/***/ }),
+
/***/ 87:
/***/ (function(module) {
@@ -50,6 +76,42 @@ module.exports = require("os");
/***/ }),
+/***/ 102:
+/***/ (function(__unusedmodule, exports, __webpack_require__) {
+
+"use strict";
+
+// For internal use, subject to change.
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+ result["default"] = mod;
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// We use any as a valid input type
+/* eslint-disable @typescript-eslint/no-explicit-any */
+const fs = __importStar(__webpack_require__(747));
+const os = __importStar(__webpack_require__(87));
+const utils_1 = __webpack_require__(82);
+function issueCommand(command, message) {
+ const filePath = process.env[`GITHUB_${command}`];
+ if (!filePath) {
+ throw new Error(`Unable to find environment variable for file command ${command}`);
+ }
+ if (!fs.existsSync(filePath)) {
+ throw new Error(`Missing file at path: ${filePath}`);
+ }
+ fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
+ encoding: 'utf8'
+ });
+}
+exports.issueCommand = issueCommand;
+//# sourceMappingURL=file-command.js.map
+
+/***/ }),
+
/***/ 431:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
@@ -64,6 +126,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87));
+const utils_1 = __webpack_require__(82);
/**
* Commands
*
@@ -117,28 +180,14 @@ class Command {
return cmdStr;
}
}
-/**
- * Sanitizes an input into a string so it can be passed into issueCommand safely
- * @param input input to sanitize into a string
- */
-function toCommandValue(input) {
- if (input === null || input === undefined) {
- return '';
- }
- else if (typeof input === 'string' || input instanceof String) {
- return input;
- }
- return JSON.stringify(input);
-}
-exports.toCommandValue = toCommandValue;
function escapeData(s) {
- return toCommandValue(s)
+ return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
}
function escapeProperty(s) {
- return toCommandValue(s)
+ return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
@@ -1435,6 +1484,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __webpack_require__(431);
+const file_command_1 = __webpack_require__(102);
+const utils_1 = __webpack_require__(82);
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
/**
@@ -1461,9 +1512,17 @@ var ExitCode;
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) {
- const convertedVal = command_1.toCommandValue(val);
+ const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal;
- command_1.issueCommand('set-env', { name }, convertedVal);
+ const filePath = process.env['GITHUB_ENV'] || '';
+ if (filePath) {
+ const delimiter = '_GitHubActionsFileCommandDelimeter_';
+ const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
+ file_command_1.issueCommand('ENV', commandValue);
+ }
+ else {
+ command_1.issueCommand('set-env', { name }, convertedVal);
+ }
}
exports.exportVariable = exportVariable;
/**
@@ -1479,7 +1538,13 @@ exports.setSecret = setSecret;
* @param inputPath
*/
function addPath(inputPath) {
- command_1.issueCommand('add-path', {}, inputPath);
+ const filePath = process.env['GITHUB_PATH'] || '';
+ if (filePath) {
+ file_command_1.issueCommand('PATH', inputPath);
+ }
+ else {
+ command_1.issueCommand('add-path', {}, inputPath);
+ }
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
}
exports.addPath = addPath;
@@ -2290,6 +2355,7 @@ function run() {
settings.updateRepositories(templateXml);
settings.updatePluginRepositories(templateXml);
settings.updateProfiles(templateXml)
+ settings.updatePluginGroups(templateXml)
// write template to filepath
var settingsPath = path.join(os.homedir(), '.m2', 'settings.xml');
@@ -3000,6 +3066,23 @@ function updateProfiles(templateXml) {
});
}
+function updatePluginGroups(templateXml) {
+ var pluginGroupsInput = core.getInput('plugin_groups');
+
+ if (!pluginGroupsInput) {
+ return;
+ }
+
+ var pluginGroupsXml = templateXml.getElementsByTagName('pluginGroups')[0];
+
+ JSON.parse(pluginGroupsInput).forEach((pluginGroupInput) => {
+ var pluginGroupXml = templateXml.createElement('pluginGroup');
+ pluginGroupXml.textContent = pluginGroupInput;
+ pluginGroupsXml.appendChild(pluginGroupXml);
+ });
+
+}
+
module.exports = {
getSettingsTemplate,
writeSettings,
@@ -3007,7 +3090,8 @@ module.exports = {
updateMirrors,
updateRepositories,
updatePluginRepositories,
- updateProfiles
+ updateProfiles,
+ updatePluginGroups
}
/***/ })
diff --git a/dist/settings.xml b/dist/settings.xml
index be9ef6ab..1f2c39e7 100644
--- a/dist/settings.xml
+++ b/dist/settings.xml
@@ -30,4 +30,6 @@
+
+
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index 0da6a3c4..766f6500 100644
--- a/src/index.js
+++ b/src/index.js
@@ -14,6 +14,7 @@ function run() {
settings.updateRepositories(templateXml);
settings.updatePluginRepositories(templateXml);
settings.updateProfiles(templateXml)
+ settings.updatePluginGroups(templateXml)
// write template to filepath
var settingsPath = path.join(os.homedir(), '.m2', 'settings.xml');
diff --git a/src/settings.js b/src/settings.js
index e9d039d7..c2d6b5e8 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -168,6 +168,23 @@ function updateProfiles(templateXml) {
});
}
+function updatePluginGroups(templateXml) {
+ var pluginGroupsInput = core.getInput('plugin_groups');
+
+ if (!pluginGroupsInput) {
+ return;
+ }
+
+ var pluginGroupsXml = templateXml.getElementsByTagName('pluginGroups')[0];
+
+ JSON.parse(pluginGroupsInput).forEach((pluginGroupInput) => {
+ var pluginGroupXml = templateXml.createElement('pluginGroup');
+ pluginGroupXml.textContent = pluginGroupInput;
+ pluginGroupsXml.appendChild(pluginGroupXml);
+ });
+
+}
+
module.exports = {
getSettingsTemplate,
writeSettings,
@@ -175,5 +192,6 @@ module.exports = {
updateMirrors,
updateRepositories,
updatePluginRepositories,
- updateProfiles
+ updateProfiles,
+ updatePluginGroups
}
\ No newline at end of file
diff --git a/template/settings.xml b/template/settings.xml
index be9ef6ab..1f2c39e7 100644
--- a/template/settings.xml
+++ b/template/settings.xml
@@ -30,4 +30,6 @@
+
+
\ No newline at end of file
diff --git a/test/settings.test.js b/test/settings.test.js
index d8e09b05..746324ea 100644
--- a/test/settings.test.js
+++ b/test/settings.test.js
@@ -161,5 +161,24 @@ describe('run settings.js', function () {
});
});
+ describe('#updatePluginGroups', function () {
+ it(' should be appended with when input.pluginGroups is present', function () {
+ // given input
+ process.env['INPUT_PLUGIN_GROUPS'] = '[ "some.plugin.group.id" ]';
+
+ // and default settings
+ var xml = new DOMParser().parseFromString("");
+
+ // when
+ settings.updatePluginGroups(xml);
+
+ // then
+ var expectedXml = 'some.plugin.group.id';
+ assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
+
+ process.env['INPUT_PLUGIN_GROUPS'] = '';
+ });
+ });
+
});