diff --git a/README.md b/README.md
index e8c92da3..d0cb3aaa 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,26 @@ Reference: [Maven Settings > Mirrors](http://maven.apache.org/settings.html#mirr
* **releases.enabled** - Enable release policy.
* **snapshots.enabled** - Enable snapshot policy.
-Reference: [Maven Settings > Plugin Repositories](http://maven.apache.org/settings.html#repositories)
+When not `repostories` is empty or null, the Maven Central repository is applied by default:
+
+```yaml
+repositories: |
+ [
+ {
+ "id": "central",
+ "name": "Maven Central",
+ "url": "https://repo1.maven.org/maven2",
+ "releases": {
+ "enabled": "true"
+ },
+ "snapshots": {
+ "enabled": "false"
+ }
+ }
+ ]
+```
+
+Reference: [Maven Settings > Repositories](http://maven.apache.org/settings.html#repositories)
### `plugin_repositories`
**Optional** json array of repositories to add to settings.xml
@@ -45,7 +64,7 @@ Reference: [Maven Settings > Plugin Repositories](http://maven.apache.org/settin
* **releases.enabled** - Enable release policy.
* **snapshots.enabled** - Enable snapshot policy.
-Reference: [Maven Settings > Repositories](http://maven.apache.org/settings.html#Plugin_Repositories)
+Reference: [Maven Settings > Plugin Repositories](http://maven.apache.org/settings.html#Plugin_Repositories)
### `plugin_groups`
**Optional** json array of plugin groups to add to settings.xml
@@ -59,18 +78,28 @@ The `profile` element in the `settings.xml` is a truncated version of the `pom.x
Reference: [Maven Settings > Profiles](http://maven.apache.org/settings.html#profiles)
-## Simple Usage
+
+### `activeProfiles`
+**Optional** json array of active profiles to add to settings.xml
+
+Set of `activeProfile` elements, which each have a value of a `profile` `id`. Any `profile` `id` defined as an `activeProfile` will be active, regardless of any environment settings. If no matching profile is found nothing will happen. For example, if `env-test` is an `activeProfile`, a profile in a `pom.xml` (or `profile.xml`) with a corresponding `id` will be active. If no such profile is found then execution will continue as normal.
+
+Reference: [Maven Settings > Active Profiles](https://maven.apache.org/settings.html#Active_Profiles)
+
+---
+
+## Basic Usage
````yaml
- name: maven-settings-xml-action
- uses: whelk-io/maven-settings-xml-action@v16
+ uses: whelk-io/maven-settings-xml-action@v17
with:
repositories: '[{ "id": "some-repository", "url": "http://some.repository.url" }]'
plugin_repositories: '[{ "id": "some-plugin-repository", "url": "http://some.plugin.repository.url" }]'
servers: '[{ "id": "some-server", "username": "some.user", "password": "some.password" }]'
````
-## Simple settings.xml
+**Output**
````xml
Profiles](http://maven.apache.org/settings.html#pro
github
-
- central
- https://repo1.maven.org/maven2
-
- true
-
-
- false
-
-
some-repository
http://some.repository.url
@@ -121,11 +140,13 @@ Reference: [Maven Settings > Profiles](http://maven.apache.org/settings.html#pro
````
+----
+
## Full Usage
````yaml
- name: maven-settings-xml-action
- uses: whelk-io/maven-settings-xml-action@v16
+ uses: whelk-io/maven-settings-xml-action@v17
with:
repositories: |
[
@@ -195,10 +216,13 @@ Reference: [Maven Settings > Profiles](http://maven.apache.org/settings.html#pro
"some.plugin.group.id",
"some.other.plugin.group.id"
]
-
+ active_profiles: |
+ [
+ "some-profile"
+ ]
````
-## Full settings.xml
+**Output**
````xml
Profiles](http://maven.apache.org/settings.html#pro
http://maven.apache.org/xsd/settings-1.0.0.xsd">
- github
+ some-profile
github
-
- central
- https://repo1.maven.org/maven2
-
- true
-
-
- false
-
-
some-repository
some-repository-name
@@ -295,3 +309,25 @@ Reference: [Maven Settings > Profiles](http://maven.apache.org/settings.html#pro
````
+
+----
+
+## Local Setup
+
+See [CONTRIBUTING.md](Contributing) for guidelines for forking and contributing to this project.
+
+**Install Dependencies**
+
+`npm ci`
+
+**Run Linter**
+
+`npm run lint`
+
+**Run Unit-Tests**
+
+`npm test`
+
+**Create Distribution**
+
+`npm run build`
diff --git a/action.yml b/action.yml
index be602caa..15a72389 100644
--- a/action.yml
+++ b/action.yml
@@ -22,6 +22,8 @@ inputs:
plugin_groups:
description: 'json array of plugin groups to add to settings.xml'
required: false
+ active_profiles:
+ description: 'json array of profile ids to add to settings.xml'
runs:
using: 'node12'
main: 'dist/index.js'
diff --git a/dist/index.js b/dist/index.js
index 6c8e7821..e540fbba 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -51,6 +51,7 @@ module.exports =
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
+exports.toCommandValue = void 0;
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
@@ -82,14 +83,27 @@ module.exports = require("os");
"use strict";
// For internal use, subject to change.
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
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;
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
+exports.issueCommand = void 0;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747));
@@ -117,14 +131,27 @@ exports.issueCommand = issueCommand;
"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
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;
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
+exports.issue = exports.issueCommand = void 0;
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
/**
@@ -1483,6 +1510,25 @@ try{
"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
@@ -1492,14 +1538,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
-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 });
+exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
const command_1 = __webpack_require__(431);
const file_command_1 = __webpack_require__(102);
const utils_1 = __webpack_require__(82);
@@ -1566,7 +1606,9 @@ function addPath(inputPath) {
}
exports.addPath = addPath;
/**
- * Gets the value of an input. The value is also trimmed.
+ * Gets the value of an input.
+ * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
+ * Returns an empty string if the value is not defined.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
@@ -1577,9 +1619,34 @@ function getInput(name, options) {
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
+ if (options && options.trimWhitespace === false) {
+ return val;
+ }
return val.trim();
}
exports.getInput = getInput;
+/**
+ * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
+ * Support boolean input list: `true | True | TRUE | false | False | FALSE` .
+ * The return value is also in boolean type.
+ * ref: https://yaml.org/spec/1.2/spec.html#id2804923
+ *
+ * @param name name of the input to get
+ * @param options optional. See InputOptions.
+ * @returns boolean
+ */
+function getBooleanInput(name, options) {
+ const trueValue = ['true', 'True', 'TRUE'];
+ const falseValue = ['false', 'False', 'FALSE'];
+ const val = getInput(name, options);
+ if (trueValue.includes(val))
+ return true;
+ if (falseValue.includes(val))
+ return false;
+ throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
+ `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
+}
+exports.getBooleanInput = getBooleanInput;
/**
* Sets the value of an output.
*
@@ -2375,6 +2442,256 @@ exports.XMLReader = XMLReader;
exports.ParseError = ParseError;
+/***/ }),
+
+/***/ 506:
+/***/ (function(module) {
+
+/**
+ * @typedef {Object} ParsingOptions
+ * @property {function(node)} filter Returns false to exclude a node. Default is true.
+ */
+
+/**
+ * Parse the given XML string into an object.
+ *
+ * @param {String} xml
+ * @param {ParsingOptions} [options]
+ * @return {Object}
+ * @api public
+ */
+function parse(xml, options = {}) {
+
+ options.filter = options.filter || (() => true);
+
+ function nextChild() {
+ return tag() || content() || comment() || cdata();
+ }
+
+ function nextRootChild() {
+ match(/\s*/);
+ return tag(true) || comment() || doctype() || processingInstruction(false);
+ }
+
+ function document() {
+ const decl = declaration();
+ const children = [];
+ let documentRootNode;
+ let child = nextRootChild();
+
+ while (child) {
+ if (child.node.type === 'Element') {
+ if (documentRootNode) {
+ throw new Error('Found multiple root nodes');
+ }
+ documentRootNode = child.node;
+ }
+
+ if (!child.excluded) {
+ children.push(child.node);
+ }
+
+ child = nextRootChild();
+ }
+
+ if (!documentRootNode) {
+ throw new Error('Failed to parse XML');
+ }
+
+ return {
+ declaration: decl ? decl.node : null,
+ root: documentRootNode,
+ children
+ };
+ }
+
+ function declaration() {
+ return processingInstruction(true);
+ }
+
+ function processingInstruction(matchDeclaration) {
+ const m = matchDeclaration ? match(/^<\?(xml)\s*/) : match(/^<\?([\w-:.]+)\s*/);
+ if (!m) return;
+
+ // tag
+ const node = {
+ name: m[1],
+ type: 'ProcessingInstruction',
+ attributes: {}
+ };
+
+ // attributes
+ while (!(eos() || is('?>'))) {
+ const attr = attribute();
+ if (!attr) return node;
+ node.attributes[attr.name] = attr.value;
+ }
+
+ match(/\?>/);
+
+ return {
+ excluded: matchDeclaration ? false : options.filter(node) === false,
+ node
+ };
+ }
+
+ function tag(matchRoot) {
+ const m = match(/^<([\w-:.]+)\s*/);
+ if (!m) return;
+
+ // name
+ const node = {
+ type: 'Element',
+ name: m[1],
+ attributes: {},
+ children: []
+ };
+
+ // attributes
+ while (!(eos() || is('>') || is('?>') || is('/>'))) {
+ const attr = attribute();
+ if (!attr) return node;
+ node.attributes[attr.name] = attr.value;
+ }
+
+ const excluded = matchRoot ? false : options.filter(node) === false;
+
+ // self closing tag
+ if (match(/^\s*\/>/)) {
+ node.children = null;
+ return {
+ excluded,
+ node
+ };
+ }
+
+ match(/\??>/);
+
+ if (!excluded) {
+ // children
+ let child = nextChild();
+ while (child) {
+ if (!child.excluded) {
+ node.children.push(child.node);
+ }
+ child = nextChild();
+ }
+ }
+
+ // closing
+ match(/^<\/[\w-:.]+>/);
+
+ return {
+ excluded,
+ node
+ };
+ }
+
+ function doctype() {
+ const m = match(/^]*>/);
+ if (m) {
+ const node = {
+ type: 'DocumentType',
+ content: m[0]
+ };
+ return {
+ excluded: options.filter(node) === false,
+ node
+ };
+ }
+ }
+
+ function cdata() {
+ if (xml.startsWith('');
+ if (endPositionStart > -1) {
+ const endPositionFinish = endPositionStart + 3;
+ const node = {
+ type: 'CDATA',
+ content: xml.substring(0, endPositionFinish)
+ };
+ xml = xml.slice(endPositionFinish);
+ return {
+ excluded: options.filter(node) === false,
+ node
+ };
+ }
+ }
+ }
+
+ function comment() {
+ const m = match(/^/);
+ if (m) {
+ const node = {
+ type: 'Comment',
+ content: m[0]
+ };
+ return {
+ excluded: options.filter(node) === false,
+ node
+ };
+ }
+ }
+
+ function content() {
+ const m = match(/^([^<]+)/);
+ if (m) {
+ const node = {
+ type: 'Text',
+ content: m[1]
+ };
+ return {
+ excluded: options.filter(node) === false,
+ node
+ };
+ }
+ }
+
+ function attribute() {
+ const m = match(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);
+ if (!m) return;
+ return {name: m[1], value: strip(m[2])}
+ }
+
+ /**
+ * Strip quotes from `val`.
+ */
+ function strip(val) {
+ return val.replace(/^['"]|['"]$/g, '');
+ }
+
+ /**
+ * Match `re` and advance the string.
+ */
+ function match(re) {
+ const m = xml.match(re);
+ if (!m) return;
+ xml = xml.slice(m[0].length);
+ return m;
+ }
+
+ /**
+ * End-of-source.
+ */
+ function eos() {
+ return 0 === xml.length;
+ }
+
+ /**
+ * Check for `prefix`.
+ */
+ function is(prefix) {
+ return 0 === xml.indexOf(prefix);
+ }
+
+ xml = xml.trim();
+
+ return document();
+}
+
+module.exports = parse;
+
+
/***/ }),
/***/ 622:
@@ -2398,12 +2715,7 @@ function run() {
var templateXml = settings.getSettingsTemplate();
// update from action input
- settings.updateServers(templateXml);
- settings.updateMirrors(templateXml);
- settings.updateRepositories(templateXml);
- settings.updatePluginRepositories(templateXml);
- settings.updateProfiles(templateXml)
- settings.updatePluginGroups(templateXml)
+ settings.update(templateXml);
// write template to filepath
var settingsPath = path.join(os.homedir(), '.m2', 'settings.xml');
@@ -2420,6 +2732,197 @@ module.exports = {
run
}
+/***/ }),
+
+/***/ 701:
+/***/ (function(module, __unusedexports, __webpack_require__) {
+
+/**
+ * @typedef {Object} XMLFormatterOptions
+ * @property {String} [indentation=' '] The value used for indentation
+ * @property {function(node): boolean} [filter] Return false to exclude the node.
+ * @property {Boolean} [collapseContent=false] True to keep content in the same line as the element. Only works if element contains at least one text node
+ * @property {String} [lineSeparator='\r\n'] The line separator to use
+ * @property {String} [whiteSpaceAtEndOfSelfclosingTag=false] to either end ad self closing tag with `` or ``
+ */
+
+/**
+ * @typedef {Object} XMLFormatterState
+ * @param {String} content
+ * @param {Number} level
+ * @param {XMLFormatterOptions} options
+ */
+
+/**
+ * @param {XMLFormatterState} state
+ * @return {void}
+ */
+function newLine(state) {
+ if (!state.options.indentation && !state.options.lineSeparator) return;
+ state.content += state.options.lineSeparator;
+ let i;
+ for (i = 0; i < state.level; i++) {
+ state.content += state.options.indentation;
+ }
+}
+
+/**
+ * @param {XMLFormatterState} state
+ * @param {String} content
+ * @return {void}
+ */
+function appendContent(state, content) {
+ state.content += content;
+}
+
+/**
+ * @param {Object} node
+ * @param {XMLFormatterState} state
+ * @param {Boolean} preserveSpace
+ * @return {void}
+ */
+function processNode(node, state, preserveSpace) {
+ if (typeof node.content === 'string') {
+ processContentNode(node, state, preserveSpace);
+ } else if (node.type === 'Element') {
+ processElementNode(node, state, preserveSpace);
+ } else if (node.type === 'ProcessingInstruction') {
+ processProcessingIntruction(node, state, preserveSpace);
+ } else {
+ throw new Error('Unknown node type: ' + node.type);
+ }
+}
+
+/**
+ * @param {Object} node
+ * @param {XMLFormatterState} state
+ * @param {Boolean} preserveSpace
+ * @return {void}
+ */
+function processContentNode(node, state, preserveSpace) {
+ if (!preserveSpace) {
+ node.content = node.content.trim();
+ }
+ if (node.content.length > 0) {
+ if (!preserveSpace && state.content.length > 0) {
+ newLine(state);
+ }
+ appendContent(state, node.content);
+ }
+}
+
+/**
+ * @param {Object} node
+ * @param {XMLFormatterState} state
+ * @param {Boolean} preserveSpace
+ * @return {void}
+ */
+function processElementNode(node, state, preserveSpace) {
+ if (!preserveSpace && state.content.length > 0) {
+ newLine(state);
+ }
+
+ appendContent(state, '<' + node.name);
+ processAttributes(state, node.attributes);
+
+ if (node.children === null) {
+ const selfClosingNodeClosingTag = state.options.whiteSpaceAtEndOfSelfclosingTag ? ' />' : '/>'
+ // self-closing node
+ appendContent(state, selfClosingNodeClosingTag);
+ } else if (node.children.length === 0) {
+ // empty node
+ appendContent(state, '>' + node.name + '>');
+ } else {
+
+ appendContent(state, '>');
+
+ state.level++;
+
+ let nodePreserveSpace = node.attributes['xml:space'] === 'preserve';
+
+ if (!nodePreserveSpace && state.options.collapseContent) {
+
+ const containsTextNodes = node.children.some(function(child) {
+ return child.type === 'Text' && child.content.trim() !== '';
+ });
+
+ if (containsTextNodes) {
+ nodePreserveSpace = true;
+ }
+ }
+
+ node.children.forEach(function(child) {
+ processNode(child, state, preserveSpace || nodePreserveSpace, state.options);
+ });
+
+ state.level--;
+
+ if (!preserveSpace && !nodePreserveSpace) {
+ newLine(state);
+ }
+ appendContent(state, '' + node.name + '>');
+ }
+}
+
+/**
+ * @param {XMLFormatterState} state
+ * @param {Record} attributes
+ * @return {void}
+ */
+function processAttributes(state, attributes) {
+ Object.keys(attributes).forEach(function(attr) {
+ const escaped = attributes[attr].replace(/"/g, '"');
+ appendContent(state, ' ' + attr + '="' + escaped + '"');
+ });
+}
+
+/**
+ * @param {Object} node
+ * @param {XMLFormatterState} state
+ * @return {void}
+ */
+function processProcessingIntruction(node, state) {
+ if (state.content.length > 0) {
+ newLine(state);
+ }
+ appendContent(state, '' + node.name);
+ processAttributes(state, node.attributes);
+ appendContent(state, '?>');
+}
+
+
+/**
+ * Converts the given XML into human readable format.
+ *
+ * @param {String} xml
+ * @param {XMLFormatterOptions} options
+ * @returns {string}
+ */
+function format(xml, options = {}) {
+ options.indentation = 'indentation' in options ? options.indentation : ' ';
+ options.collapseContent = options.collapseContent === true;
+ options.lineSeparator = 'lineSeparator' in options ? options.lineSeparator : '\r\n';
+ options.whiteSpaceAtEndOfSelfclosingTag = !!options.whiteSpaceAtEndOfSelfclosingTag;
+
+ const parser = __webpack_require__(506);
+ const parsedXml = parser(xml, {filter: options.filter});
+ const state = {content: '', level: 0, options: options};
+
+ if (parsedXml.declaration) {
+ processProcessingIntruction(parsedXml.declaration, state);
+ }
+
+ parsedXml.children.forEach(function(child) {
+ processNode(child, state, false);
+ });
+
+ return state.content;
+}
+
+
+module.exports = format;
+
+
/***/ }),
/***/ 721:
@@ -2947,23 +3450,92 @@ var path = __webpack_require__(622);
var fs = __webpack_require__(747);
var DOMParser = __webpack_require__(721).DOMParser;
var XMLSerializer = __webpack_require__(721).XMLSerializer;
+var format = __webpack_require__(701);
function getSettingsTemplate() {
- core.info("opening settings template");
- var templatePath = __webpack_require__.ab + "settings.xml";
- var template = fs.readFileSync(__webpack_require__.ab + "settings.xml").toString();
+ return getTemplate('../template', 'settings.xml');
+}
+
+function getDefaultRepositoryTemplate() {
+ return getTemplate('../template', 'default-repository.xml');
+}
+
+function getDefaultActiveProfileTemplate() {
+ return getTemplate('../template', 'default-active-profile.xml');
+}
+
+function getTemplate(filepath, filename) {
+ var templatePath = path.join(__dirname, filepath, filename);
+ var template = fs.readFileSync(templatePath).toString();
return new DOMParser().parseFromString(template, 'text/xml');
}
+function formatSettings(templateXml) {
+ var settingStr = new XMLSerializer().serializeToString(templateXml);
+
+ // format xml to standard format
+ return format(settingStr, {
+ indentation: ' ',
+ collapsetent: true,
+ lineSeparator: '\n'
+ });
+}
+
function writeSettings(settingsPath, templateXml) {
if (!fs.existsSync(path.dirname(settingsPath))) {
core.info("creating ~/.m2 directory");
fs.mkdirSync(path.dirname(settingsPath));
}
+ var formattedXml = formatSettings(templateXml);
+
core.info("writing settings.xml to path: " + settingsPath)
- var settingStr = new XMLSerializer().serializeToString(templateXml);
- fs.writeFileSync(settingsPath, settingStr);
+ fs.writeFileSync(settingsPath, formattedXml);
+}
+
+function update(templateXml) {
+ this.updateActiveProfiles(templateXml);
+ this.updateServers(templateXml);
+ this.updateMirrors(templateXml);
+ this.updateRepositories(templateXml);
+ this.updatePluginRepositories(templateXml);
+ this.updateProfiles(templateXml)
+ this.updatePluginGroups(templateXml)
+}
+
+function updateActiveProfiles(templateXml) {
+
+ var activeProfilesInput = core.getInput('active_profiles');
+
+ if (!activeProfilesInput) {
+ applyDefaultActiveProfile(templateXml);
+ return;
+ }
+
+ var activeProfiles = JSON.parse(activeProfilesInput);
+
+ if (activeProfiles.length == 0) {
+ applyDefaultActiveProfile(templateXml);
+ return;
+ }
+
+ // apply custom repostories
+ activeProfiles.forEach((activeProfileInput) => {
+ activeProfileXml = templateXml.createElement("activeProfile");
+ activeProfileXml.textContent = activeProfileInput;
+ templateXml
+ .getElementsByTagName('activeProfiles')[0]
+ .appendChild(activeProfileXml);
+ });
+
+}
+
+function applyDefaultActiveProfile(templateXml) {
+ var defaultActiveProfile = getDefaultActiveProfileTemplate();
+
+ templateXml
+ .getElementsByTagName('activeProfiles')[0]
+ .appendChild(defaultActiveProfile);
}
function updateServers(templateXml) {
@@ -3018,14 +3590,19 @@ function updateRepositories(templateXml) {
var repositoriesInput = core.getInput('repositories');
if (!repositoriesInput) {
+ applyDefaultRepository(templateXml);
return;
}
- var repositoriesXml =
- templateXml.getElementsByTagName('profiles')[0]
- .getElementsByTagName('repositories')[0];
+ var repositories = JSON.parse(repositoriesInput);
- JSON.parse(repositoriesInput).forEach((repositoryInput) => {
+ if (repositories.length == 0) {
+ applyDefaultRepository(templateXml);
+ return;
+ }
+
+ // apply custom repostories
+ repositories.forEach((repositoryInput) => {
var repositoryXml = templateXml.createElement('repository');
for (var key in repositoryInput) {
var keyXml = templateXml.createElement(key);
@@ -3045,10 +3622,22 @@ function updateRepositories(templateXml) {
repositoryXml.appendChild(keyXml);
}
}
- repositoriesXml.appendChild(repositoryXml);
+ templateXml
+ .getElementsByTagName('profiles')[0]
+ .getElementsByTagName('repositories')[0]
+ .appendChild(repositoryXml);
});
}
+function applyDefaultRepository(templateXml) {
+ var defaultRepositoryTemplate = getDefaultRepositoryTemplate();
+
+ templateXml
+ .getElementsByTagName('profiles')[0]
+ .getElementsByTagName('repositories')[0]
+ .appendChild(defaultRepositoryTemplate);
+}
+
function updatePluginRepositories(templateXml) {
var pluginRepositoriesInput = core.getInput('plugin_repositories');
@@ -3152,22 +3741,26 @@ function objectToXml(obj) {
}
xml += obj[prop] instanceof Array ? '' : "" + prop + ">";
}
- var xml = xml.replace(/<\/?[0-9]{1,}>/g, '');
+ xml = xml.replace(/<\/?[0-9]{1,}>/g, '');
return xml
}
module.exports = {
getSettingsTemplate,
+ getTemplate,
+ formatSettings,
writeSettings,
+ update,
+ updateActiveProfiles,
updateServers,
updateMirrors,
updateRepositories,
updatePluginRepositories,
updateProfiles,
- updatePluginGroups,
- objectToXml
+ updatePluginGroups
}
+
/***/ })
/******/ });
\ No newline at end of file
diff --git a/dist/template/default-active-profile.xml b/dist/template/default-active-profile.xml
new file mode 100644
index 00000000..7dbb7b16
--- /dev/null
+++ b/dist/template/default-active-profile.xml
@@ -0,0 +1 @@
+github
\ No newline at end of file
diff --git a/dist/template/default-repository.xml b/dist/template/default-repository.xml
new file mode 100644
index 00000000..f527a0ee
--- /dev/null
+++ b/dist/template/default-repository.xml
@@ -0,0 +1,11 @@
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
\ No newline at end of file
diff --git a/dist/template/settings.xml b/dist/template/settings.xml
new file mode 100644
index 00000000..e670248f
--- /dev/null
+++ b/dist/template/settings.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ github
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 7646254e..f4c86630 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,17 +1,18 @@
{
"name": "maven-settings-xml-action",
- "version": "0.0.8",
+ "version": "0.0.17",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "version": "0.0.8",
+ "version": "0.0.17",
"license": "Apache-2.0",
"dependencies": {
- "@actions/core": "^1.2.6",
+ "@actions/core": "^1.3.0",
"fs": "0.0.1-security",
"os": "^0.1.1",
"path": "^0.12.7",
+ "xml-formatter": "^2.4.0",
"xmldom": "^0.5.0"
},
"devDependencies": {
@@ -23,9 +24,9 @@
}
},
"node_modules/@actions/core": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.7.tgz",
- "integrity": "sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig=="
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.3.0.tgz",
+ "integrity": "sha512-xxtX0Cwdhb8LcgatfJkokqT8KzPvcIbwL9xpLU09nOwBzaStbfm0dNncsP0M4us+EpoPdWy7vbzU5vSOH7K6pg=="
},
"node_modules/@babel/code-frame": {
"version": "7.10.3",
@@ -513,7 +514,7 @@
"js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
- "lodash": "^4.17.21",
+ "lodash": "^4.17.14",
"minimatch": "^3.0.4",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
@@ -1194,7 +1195,7 @@
"cli-width": "^2.0.0",
"external-editor": "^3.0.3",
"figures": "^3.0.0",
- "lodash": "^4.17.21",
+ "lodash": "^4.17.15",
"mute-stream": "0.0.8",
"run-async": "^2.4.0",
"rxjs": "^6.5.3",
@@ -1647,7 +1648,7 @@
"js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.3.0",
- "lodash": "^4.17.21",
+ "lodash": "^4.17.14",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"natural-compare": "^1.4.0",
@@ -2403,7 +2404,7 @@
"dev": true,
"dependencies": {
"ajv": "^6.10.2",
- "lodash": "^4.17.21",
+ "lodash": "^4.17.14",
"slice-ansi": "^2.1.0",
"string-width": "^3.0.0"
},
@@ -2644,6 +2645,26 @@
"node": ">=4"
}
},
+ "node_modules/xml-formatter": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/xml-formatter/-/xml-formatter-2.4.0.tgz",
+ "integrity": "sha512-xTQ2IfbkCQKn0DGN5SD5KUgTgVohWiolyOXTLUHKJczIuSeGonN0BPduB9VQR5HOEuT1KOHQsOHSmTpU76zpUA==",
+ "license": "MIT",
+ "dependencies": {
+ "xml-parser-xo": "^3.1.1"
+ },
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "node_modules/xml-parser-xo": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/xml-parser-xo/-/xml-parser-xo-3.1.1.tgz",
+ "integrity": "sha512-gq1nDlJxjKQpPPZUhLbJ52pghtlB4Rz6LAQULm3SF6xzOYVnUloBglNhJR9vtZB3vIxMN/R3nZTf3qmun+6GCg==",
+ "engines": {
+ "node": ">= 10"
+ }
+ },
"node_modules/xmldom": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz",
@@ -2812,9 +2833,9 @@
},
"dependencies": {
"@actions/core": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.7.tgz",
- "integrity": "sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig=="
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.3.0.tgz",
+ "integrity": "sha512-xxtX0Cwdhb8LcgatfJkokqT8KzPvcIbwL9xpLU09nOwBzaStbfm0dNncsP0M4us+EpoPdWy7vbzU5vSOH7K6pg=="
},
"@babel/code-frame": {
"version": "7.10.3",
@@ -3221,7 +3242,7 @@
"js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
- "lodash": "^4.17.21",
+ "lodash": "^4.17.14",
"minimatch": "^3.0.4",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
@@ -3756,7 +3777,7 @@
"cli-width": "^2.0.0",
"external-editor": "^3.0.3",
"figures": "^3.0.0",
- "lodash": "^4.17.21",
+ "lodash": "^4.17.15",
"mute-stream": "0.0.8",
"run-async": "^2.4.0",
"rxjs": "^6.5.3",
@@ -4203,7 +4224,7 @@
"js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.3.0",
- "lodash": "^4.17.21",
+ "lodash": "^4.17.14",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"natural-compare": "^1.4.0",
@@ -4706,7 +4727,7 @@
"dev": true,
"requires": {
"ajv": "^6.10.2",
- "lodash": "^4.17.21",
+ "lodash": "^4.17.14",
"slice-ansi": "^2.1.0",
"string-width": "^3.0.0"
},
@@ -4903,6 +4924,19 @@
"mkdirp": "^0.5.1"
}
},
+ "xml-formatter": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/xml-formatter/-/xml-formatter-2.4.0.tgz",
+ "integrity": "sha512-xTQ2IfbkCQKn0DGN5SD5KUgTgVohWiolyOXTLUHKJczIuSeGonN0BPduB9VQR5HOEuT1KOHQsOHSmTpU76zpUA==",
+ "requires": {
+ "xml-parser-xo": "^3.1.1"
+ }
+ },
+ "xml-parser-xo": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/xml-parser-xo/-/xml-parser-xo-3.1.1.tgz",
+ "integrity": "sha512-gq1nDlJxjKQpPPZUhLbJ52pghtlB4Rz6LAQULm3SF6xzOYVnUloBglNhJR9vtZB3vIxMN/R3nZTf3qmun+6GCg=="
+ },
"xmldom": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.5.0.tgz",
diff --git a/package.json b/package.json
index 7370b539..33bdc8f6 100644
--- a/package.json
+++ b/package.json
@@ -1,16 +1,17 @@
{
"name": "maven-settings-xml-action",
- "version": "0.0.8",
+ "version": "0.0.17",
"description": "Update maven ~/.m2/settings.xml",
"main": "src/index.js",
"directories": {
"test": "test"
},
"dependencies": {
- "@actions/core": "^1.2.6",
+ "@actions/core": "^1.3.0",
"fs": "0.0.1-security",
"os": "^0.1.1",
"path": "^0.12.7",
+ "xml-formatter": "^2.4.0",
"xmldom": "^0.5.0"
},
"devDependencies": {
@@ -22,8 +23,10 @@
},
"scripts": {
"lint": "eslint ./src/*.js",
- "prepare": "ncc build src/index.js -o dist",
- "test": "mocha"
+ "test": "mocha",
+ "build_index": "ncc build src/index.js -o dist ",
+ "copy_templates": "rm -rf dist/template && mkdir dist/template && cp -a template/. dist/template/",
+ "build": "npm run build_index && npm run copy_templates"
},
"repository": {
"type": "git",
diff --git a/src/index.js b/src/index.js
index 766f6500..4e4234be 100644
--- a/src/index.js
+++ b/src/index.js
@@ -9,12 +9,7 @@ function run() {
var templateXml = settings.getSettingsTemplate();
// update from action input
- settings.updateServers(templateXml);
- settings.updateMirrors(templateXml);
- settings.updateRepositories(templateXml);
- settings.updatePluginRepositories(templateXml);
- settings.updateProfiles(templateXml)
- settings.updatePluginGroups(templateXml)
+ settings.update(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 5d30ca26..a4a89836 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -3,23 +3,92 @@ var path = require('path');
var fs = require('fs');
var DOMParser = require('xmldom').DOMParser;
var XMLSerializer = require('xmldom').XMLSerializer;
+var format = require('xml-formatter');
function getSettingsTemplate() {
- core.info("opening settings template");
- var templatePath = path.join(__dirname, '../template', 'settings.xml');
+ return getTemplate('../template', 'settings.xml');
+}
+
+function getDefaultRepositoryTemplate() {
+ return getTemplate('../template', 'default-repository.xml');
+}
+
+function getDefaultActiveProfileTemplate() {
+ return getTemplate('../template', 'default-active-profile.xml');
+}
+
+function getTemplate(filepath, filename) {
+ var templatePath = path.join(__dirname, filepath, filename);
var template = fs.readFileSync(templatePath).toString();
return new DOMParser().parseFromString(template, 'text/xml');
}
+function formatSettings(templateXml) {
+ var settingStr = new XMLSerializer().serializeToString(templateXml);
+
+ // format xml to standard format
+ return format(settingStr, {
+ indentation: ' ',
+ collapsetent: true,
+ lineSeparator: '\n'
+ });
+}
+
function writeSettings(settingsPath, templateXml) {
if (!fs.existsSync(path.dirname(settingsPath))) {
core.info("creating ~/.m2 directory");
fs.mkdirSync(path.dirname(settingsPath));
}
+ var formattedXml = formatSettings(templateXml);
+
core.info("writing settings.xml to path: " + settingsPath)
- var settingStr = new XMLSerializer().serializeToString(templateXml);
- fs.writeFileSync(settingsPath, settingStr);
+ fs.writeFileSync(settingsPath, formattedXml);
+}
+
+function update(templateXml) {
+ this.updateActiveProfiles(templateXml);
+ this.updateServers(templateXml);
+ this.updateMirrors(templateXml);
+ this.updateRepositories(templateXml);
+ this.updatePluginRepositories(templateXml);
+ this.updateProfiles(templateXml)
+ this.updatePluginGroups(templateXml)
+}
+
+function updateActiveProfiles(templateXml) {
+
+ var activeProfilesInput = core.getInput('active_profiles');
+
+ if (!activeProfilesInput) {
+ applyDefaultActiveProfile(templateXml);
+ return;
+ }
+
+ var activeProfiles = JSON.parse(activeProfilesInput);
+
+ if (activeProfiles.length == 0) {
+ applyDefaultActiveProfile(templateXml);
+ return;
+ }
+
+ // apply custom repostories
+ activeProfiles.forEach((activeProfileInput) => {
+ activeProfileXml = templateXml.createElement("activeProfile");
+ activeProfileXml.textContent = activeProfileInput;
+ templateXml
+ .getElementsByTagName('activeProfiles')[0]
+ .appendChild(activeProfileXml);
+ });
+
+}
+
+function applyDefaultActiveProfile(templateXml) {
+ var defaultActiveProfile = getDefaultActiveProfileTemplate();
+
+ templateXml
+ .getElementsByTagName('activeProfiles')[0]
+ .appendChild(defaultActiveProfile);
}
function updateServers(templateXml) {
@@ -74,14 +143,19 @@ function updateRepositories(templateXml) {
var repositoriesInput = core.getInput('repositories');
if (!repositoriesInput) {
+ applyDefaultRepository(templateXml);
return;
}
- var repositoriesXml =
- templateXml.getElementsByTagName('profiles')[0]
- .getElementsByTagName('repositories')[0];
+ var repositories = JSON.parse(repositoriesInput);
- JSON.parse(repositoriesInput).forEach((repositoryInput) => {
+ if (repositories.length == 0) {
+ applyDefaultRepository(templateXml);
+ return;
+ }
+
+ // apply custom repostories
+ repositories.forEach((repositoryInput) => {
var repositoryXml = templateXml.createElement('repository');
for (var key in repositoryInput) {
var keyXml = templateXml.createElement(key);
@@ -101,10 +175,22 @@ function updateRepositories(templateXml) {
repositoryXml.appendChild(keyXml);
}
}
- repositoriesXml.appendChild(repositoryXml);
+ templateXml
+ .getElementsByTagName('profiles')[0]
+ .getElementsByTagName('repositories')[0]
+ .appendChild(repositoryXml);
});
}
+function applyDefaultRepository(templateXml) {
+ var defaultRepositoryTemplate = getDefaultRepositoryTemplate();
+
+ templateXml
+ .getElementsByTagName('profiles')[0]
+ .getElementsByTagName('repositories')[0]
+ .appendChild(defaultRepositoryTemplate);
+}
+
function updatePluginRepositories(templateXml) {
var pluginRepositoriesInput = core.getInput('plugin_repositories');
@@ -214,12 +300,15 @@ function objectToXml(obj) {
module.exports = {
getSettingsTemplate,
+ getTemplate,
+ formatSettings,
writeSettings,
+ update,
+ updateActiveProfiles,
updateServers,
updateMirrors,
updateRepositories,
updatePluginRepositories,
updateProfiles,
- updatePluginGroups,
- objectToXml
-}
\ No newline at end of file
+ updatePluginGroups
+}
diff --git a/template/default-active-profile.xml b/template/default-active-profile.xml
new file mode 100644
index 00000000..7dbb7b16
--- /dev/null
+++ b/template/default-active-profile.xml
@@ -0,0 +1 @@
+github
\ No newline at end of file
diff --git a/template/default-repository.xml b/template/default-repository.xml
new file mode 100644
index 00000000..f527a0ee
--- /dev/null
+++ b/template/default-repository.xml
@@ -0,0 +1,11 @@
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
\ No newline at end of file
diff --git a/template/settings.xml b/template/settings.xml
index 1f2c39e7..e670248f 100644
--- a/template/settings.xml
+++ b/template/settings.xml
@@ -3,25 +3,12 @@
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
-
- github
-
+
github
-
-
- central
- https://repo1.maven.org/maven2
-
- true
-
-
- false
-
-
-
+
diff --git a/test/resources/when-active-profiles-empty.xml b/test/resources/when-active-profiles-empty.xml
new file mode 100644
index 00000000..5b1c573f
--- /dev/null
+++ b/test/resources/when-active-profiles-empty.xml
@@ -0,0 +1,35 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-active-profiles-missing.xml b/test/resources/when-active-profiles-missing.xml
new file mode 100644
index 00000000..5b1c573f
--- /dev/null
+++ b/test/resources/when-active-profiles-missing.xml
@@ -0,0 +1,35 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-active-profiles-present.xml b/test/resources/when-active-profiles-present.xml
new file mode 100644
index 00000000..d7156b6d
--- /dev/null
+++ b/test/resources/when-active-profiles-present.xml
@@ -0,0 +1,35 @@
+
+
+
+ foo-bar
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-mirrors-present.xml b/test/resources/when-mirrors-present.xml
new file mode 100644
index 00000000..c1ed8051
--- /dev/null
+++ b/test/resources/when-mirrors-present.xml
@@ -0,0 +1,41 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+ nexus
+ !my-org-snapshots,*
+ http://redacted/nexus/content/groups/public
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-plugin-groups-present.xml b/test/resources/when-plugin-groups-present.xml
new file mode 100644
index 00000000..49f856e2
--- /dev/null
+++ b/test/resources/when-plugin-groups-present.xml
@@ -0,0 +1,37 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ some.plugin.group.id
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-plugin-repositories-empty.xml b/test/resources/when-plugin-repositories-empty.xml
new file mode 100644
index 00000000..5b1c573f
--- /dev/null
+++ b/test/resources/when-plugin-repositories-empty.xml
@@ -0,0 +1,35 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-plugin-repositories-missing.xml b/test/resources/when-plugin-repositories-missing.xml
new file mode 100644
index 00000000..5b1c573f
--- /dev/null
+++ b/test/resources/when-plugin-repositories-missing.xml
@@ -0,0 +1,35 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-plugin-repositories-present.xml b/test/resources/when-plugin-repositories-present.xml
new file mode 100644
index 00000000..aea1c7d4
--- /dev/null
+++ b/test/resources/when-plugin-repositories-present.xml
@@ -0,0 +1,47 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+ foo.plugin
+ foo.plugin
+ http://foo.bar.plugin
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-profiles-present.xml b/test/resources/when-profiles-present.xml
new file mode 100644
index 00000000..0b284f50
--- /dev/null
+++ b/test/resources/when-profiles-present.xml
@@ -0,0 +1,43 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+ foo.profile
+ foo.profile
+
+ property-1
+ property-2
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dist/settings.xml b/test/resources/when-repositories-empty.xml
similarity index 75%
rename from dist/settings.xml
rename to test/resources/when-repositories-empty.xml
index 1f2c39e7..f8af8c6b 100644
--- a/dist/settings.xml
+++ b/test/resources/when-repositories-empty.xml
@@ -1,6 +1,5 @@
-
@@ -13,6 +12,7 @@
central
+ Maven Central
https://repo1.maven.org/maven2
true
diff --git a/test/resources/when-repositories-missing.xml b/test/resources/when-repositories-missing.xml
new file mode 100644
index 00000000..f8af8c6b
--- /dev/null
+++ b/test/resources/when-repositories-missing.xml
@@ -0,0 +1,35 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-repositories-present.xml b/test/resources/when-repositories-present.xml
new file mode 100644
index 00000000..271d8a53
--- /dev/null
+++ b/test/resources/when-repositories-present.xml
@@ -0,0 +1,35 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ foo
+ foo
+ http://foo.bar
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-servers-missing.xml b/test/resources/when-servers-missing.xml
new file mode 100644
index 00000000..5b1c573f
--- /dev/null
+++ b/test/resources/when-servers-missing.xml
@@ -0,0 +1,35 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-servers-present.xml b/test/resources/when-servers-present.xml
new file mode 100644
index 00000000..5e2edb3b
--- /dev/null
+++ b/test/resources/when-servers-present.xml
@@ -0,0 +1,41 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+ foo
+ fu
+ bar
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-servers-with-extended-configuration.xml b/test/resources/when-servers-with-extended-configuration.xml
new file mode 100644
index 00000000..e7e42ce6
--- /dev/null
+++ b/test/resources/when-servers-with-extended-configuration.xml
@@ -0,0 +1,48 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+ foo
+ fu
+ bar
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/resources/when-servers-with-extended-properties.xml b/test/resources/when-servers-with-extended-properties.xml
new file mode 100644
index 00000000..82f90db1
--- /dev/null
+++ b/test/resources/when-servers-with-extended-properties.xml
@@ -0,0 +1,45 @@
+
+
+
+ github
+
+
+
+
+ github
+
+
+ central
+ Maven Central
+ https://repo1.maven.org/maven2
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+ foo
+ fu
+ bar
+ ${user.home}/.ssh/id_dsa
+ some_passphrase
+ 664
+ 775
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/settings.test.js b/test/settings.test.js
deleted file mode 100644
index ee2c74c9..00000000
--- a/test/settings.test.js
+++ /dev/null
@@ -1,222 +0,0 @@
-var assert = require('assert');
-var process = require('process');
-var settings = require('../src/settings')
-var XMLSerializer = require('xmldom').XMLSerializer;
-var DOMParser = require('xmldom').DOMParser;
-
-describe('run settings.js', function () {
-
- describe('#updateServers', function () {
- it(' should be not be changed when input.server is missing', function () {
- // given input
- process.env['INPUT_SERVERS'] = '';
-
- // and default settings
- var xml = new DOMParser().parseFromString("");
-
- // when
- settings.updateServers(xml);
-
- // then
- var expectedXml = '';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_SERVERS'] = '';
- });
- });
-
- describe('#updateServers', function () {
- it(' should be appended with when input.server is present', function () {
- // given input
- process.env['INPUT_SERVERS'] = '[{ "id": "foo", "username": "fu", "password": "bar" }]';
-
- // and default settings
- var xml = new DOMParser().parseFromString("");
-
- // when
- settings.updateServers(xml);
-
- // then
- var expectedXml = 'foofubar';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_SERVERS'] = '';
- });
- });
-
- describe('#updateServers', function () {
- it(' should be appended with when extended configuration is provided', function () {
- // given input
- process.env['INPUT_SERVERS'] = '[{ "id": "foo", "username": "fu", "password": "bar", "configuration": { "httpConfiguration": { "all" : { "usePreemptive": "true" }}}}]';
-
- // and default settings
- var xml = new DOMParser().parseFromString("");
-
- // when
- settings.updateServers(xml);
-
- // then
- var expectedXml = 'foofubartrue';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_SERVERS'] = '';
- });
- });
-
- describe('#updateServers', function () {
- it(' should be appended with and include all maven server properties', function () {
- // given input
- process.env['INPUT_SERVERS'] = '[{ "id": "foo", "username": "fu", "password": "bar", "privateKey": "${user.home}/.ssh/id_dsa", "passphrase": "some_passphrase", "filePermissions": "664", "directoryPermissions": "775" }]';
-
- // and default settings
- var xml = new DOMParser().parseFromString("");
-
- // when
- settings.updateServers(xml);
-
- // then
- var expectedXml = 'foofubar${user.home}/.ssh/id_dsasome_passphrase664775';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_SERVERS'] = '';
- });
- });
-
- describe('#updateMirrors', function () {
- it(' should be appended with when input.mirror is present', function () {
- // given input
- process.env['INPUT_MIRRORS'] = '[{ "id": "nexus", "mirrorOf": "!my-org-snapshots,*", "url": "http://redacted/nexus/content/groups/public" }]';
-
- // and default settings
- var xml = new DOMParser().parseFromString("");
-
- // when
- settings.updateMirrors(xml);
-
- // then
- var expectedXml = 'nexus!my-org-snapshots,*http://redacted/nexus/content/groups/public';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_MIRRORS'] = '';
- });
- });
-
- describe('#doNotUpdateRepositories', function () {
- it(' should not be changed when input.repositories is missing', function () {
- // given input
- process.env['INPUT_REPOSITORIES'] = '[{ "id": "foo", "url": "http://foo.bar" }]';
-
- // and default settings
- var xml = new DOMParser().parseFromString(
- "github");
-
- // when
- settings.updateRepositories(xml);
-
- // then
- var expectedXml = 'githubfoohttp://foo.bar';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_REPOSITORIES'] = '';
- });
- });
-
- describe('#updateRepositories', function () {
- it(' should be appended with when input.repositories is present', function () {
- // given input
- process.env['INPUT_REPOSITORIES'] = '[{ "id": "foo", "name": "foo", "url": "http://foo.bar", "releases": { "enabled": "true" }, "snapshots": { "enabled": "true" } }]';
-
- // and default settings
- var xml = new DOMParser().parseFromString(
- "github");
-
- // when
- settings.updateRepositories(xml);
-
- // then
- var expectedXml = 'githubfoofoohttp://foo.bartruetrue';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_REPOSITORIES'] = '';
- });
- });
-
- describe('#updatePluginRepositories', function () {
- it(' should be appended with when input.pluginRepositories is present', function () {
- // given input
- process.env['INPUT_PLUGIN_REPOSITORIES'] = '[{ "id": "foo.plugin", "name": "foo.plugin", "url": "http://foo.bar.plugin", "releases": { "enabled": "true" }, "snapshots": { "enabled": "true" } }]';
-
- // and default settings
- var xml = new DOMParser().parseFromString(
- "github");
-
- // when
- settings.updatePluginRepositories(xml);
-
- // then
- var expectedXml = 'githubfoo.pluginfoo.pluginhttp://foo.bar.plugintruetrue';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_PLUGIN_REPOSITORIES'] = '';
- });
- });
-
- describe('#updateProfiles', function () {
- it(' should be appended with when input.profiles is present', function () {
- // given input
- process.env['INPUT_PROFILES'] = '[{ "id": "foo.profile", "name": "foo.profile", "url": "http://foo.bar.profile", "properties": { "foo": "property-1", "bar": "property-2"} }]';
-
- // and default settings
- var xml = new DOMParser().parseFromString(
- "github");
-
- // when
- settings.updateProfiles(xml);
-
- // then
- var expectedXml = 'githubfoo.profilefoo.profilehttp://foo.bar.profileproperty-1property-2';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
-
- process.env['INPUT_PROFILES'] = '';
- });
- });
-
- describe('#updateRepositoriesWithSnapshots', function () {
- it(' should build with snapshots, when provided', function () {
- // given input
- process.env['INPUT_REPOSITORIES'] = '[{ "id": "maven-internal", "url": "https://maven.aaaaa.aa", "name": "maven-internal", "snapshots": {"enabled": "true"} }]';
-
- // and default settings
- var xml = new DOMParser().parseFromString(
- "github");
-
- // when
- settings.updateRepositories(xml);
-
- // then
- var expectedXml = 'githubmaven-internalhttps://maven.aaaaa.aamaven-internaltrue';
- assert.equal(new XMLSerializer().serializeToString(xml), expectedXml);
- });
- });
-
- 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'] = '';
- });
- });
-
-});
-
diff --git a/test/update-active-profiles.js b/test/update-active-profiles.js
new file mode 100644
index 00000000..e7644d9b
--- /dev/null
+++ b/test/update-active-profiles.js
@@ -0,0 +1,65 @@
+var assert = require('assert');
+var process = require('process');
+var settings = require('../src/settings')
+
+describe('validate active profiles', function () {
+
+ describe('when input present', function () {
+ it(' should be appended with when input.active_profiles is present', function () {
+ // given input
+ process.env['INPUT_ACTIVE_PROFILES'] = '[ "foo-bar" ]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-active-profiles-present.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_ACTIVE_PROFILES'] = '';
+ });
+ });
+
+ describe('when empty input', function () {
+ it(' should be appended with default when input.active_profiles is empty', function () {
+ // given input
+ process.env['INPUT_ACTIVE_PROFILES'] = '[]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-active-profiles-empty.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_ACTIVE_PROFILES'] = '';
+ });
+ });
+
+ describe('when empty missing', function () {
+ it(' should be appended with default when input.active_profiles is missing', function () {
+ // given input
+ process.env['INPUT_ACTIVE_PROFILES'] = '';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-active-profiles-missing.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_ACTIVE_PROFILES'] = '';
+ });
+ });
+
+});
+
diff --git a/test/update-mirrors.js b/test/update-mirrors.js
new file mode 100644
index 00000000..467e4d0b
--- /dev/null
+++ b/test/update-mirrors.js
@@ -0,0 +1,27 @@
+var assert = require('assert');
+var process = require('process');
+var settings = require('../src/settings')
+
+describe('validate mirrors', function () {
+
+ describe('when input present', function () {
+ it(' should be appended with when input.mirror is present', function () {
+ // given input
+ process.env['INPUT_MIRRORS'] = '[{ "id": "nexus", "mirrorOf": "!my-org-snapshots,*", "url": "http://redacted/nexus/content/groups/public" }]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-mirrors-present.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_MIRRORS'] = '';
+ });
+ });
+
+});
+
diff --git a/test/update-plugin-groups.js b/test/update-plugin-groups.js
new file mode 100644
index 00000000..71ad5875
--- /dev/null
+++ b/test/update-plugin-groups.js
@@ -0,0 +1,27 @@
+var assert = require('assert');
+var process = require('process');
+var settings = require('../src/settings')
+
+describe('validate plugin groups', function () {
+
+ describe('when input present', function () {
+ it(' should be appended with when input.pluginGroups is present', function () {
+ // given input
+ process.env['INPUT_PLUGIN_GROUPS'] = '[ "some.plugin.group.id" ]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-plugin-groups-present.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_PLUGIN_GROUPS'] = '';
+ });
+ });
+
+});
+
diff --git a/test/update-plugin-repositories.js b/test/update-plugin-repositories.js
new file mode 100644
index 00000000..dcc1c701
--- /dev/null
+++ b/test/update-plugin-repositories.js
@@ -0,0 +1,65 @@
+var assert = require('assert');
+var process = require('process');
+var settings = require('../src/settings')
+
+describe('validate plugin repositories', function () {
+
+ describe('when input missing', function () {
+ it(' should not be appended with when input.pluginRepositories is missing', function () {
+ // given input
+ process.env['INPUT_PLUGIN_REPOSITORIES'] = '';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-plugin-repositories-missing.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_PLUGIN_REPOSITORIES'] = '';
+ });
+ });
+
+ describe('when input empty', function () {
+ it(' should not be appended with when input.pluginRepositories is empty', function () {
+ // given input
+ process.env['INPUT_PLUGIN_REPOSITORIES'] = '[]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-plugin-repositories-empty.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_PLUGIN_REPOSITORIES'] = '';
+ });
+ });
+
+ describe('when input present', function () {
+ it(' should be appended with when input.pluginRepositories is present', function () {
+ // given input
+ process.env['INPUT_PLUGIN_REPOSITORIES'] = '[{ "id": "foo.plugin", "name": "foo.plugin", "url": "http://foo.bar.plugin", "releases": { "enabled": "true" }, "snapshots": { "enabled": "true" } }]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-plugin-repositories-present.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_PLUGIN_REPOSITORIES'] = '';
+ });
+ });
+
+});
+
diff --git a/test/update-profiles.js b/test/update-profiles.js
new file mode 100644
index 00000000..ca25d2f5
--- /dev/null
+++ b/test/update-profiles.js
@@ -0,0 +1,27 @@
+var assert = require('assert');
+var process = require('process');
+var settings = require('../src/settings')
+
+describe('validate profiles', function () {
+
+ describe('when input present', function () {
+ it(' should be appended with when input.profiles is present', function () {
+ // given input
+ process.env['INPUT_PROFILES'] = '[{ "id": "foo.profile", "name": "foo.profile", "properties": { "foo": "property-1", "bar": "property-2"} }]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-profiles-present.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_PROFILES'] = '';
+ });
+ });
+
+});
+
diff --git a/test/update-repositories.js b/test/update-repositories.js
new file mode 100644
index 00000000..ccc018a3
--- /dev/null
+++ b/test/update-repositories.js
@@ -0,0 +1,67 @@
+var assert = require('assert');
+var process = require('process');
+var settings = require('../src/settings')
+
+describe('validate repositories', function () {
+
+ describe('when input missing', function () {
+ it(' should be appended with default when input.repositories is missing', function () {
+ // given input
+ process.env['INPUT_REPOSITORIES'] = '';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-repositories-missing.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ process.env['INPUT_REPOSITORIES'] = '';
+ });
+ });
+
+ describe('when input empty', function () {
+ it(' should be appended with default when input.repositories is empty', function () {
+ // given input
+ process.env['INPUT_REPOSITORIES'] = '[]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-repositories-missing.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ // tear down
+ process.env['INPUT_REPOSITORIES'] = '';
+ });
+ });
+
+ describe('when input present', function () {
+ it(' should be appended with when input.repositories is present', function () {
+ // given input
+ process.env['INPUT_REPOSITORIES'] = '[{ "id": "foo", "name": "foo", "url": "http://foo.bar", "releases": { "enabled": "true" }, "snapshots": { "enabled": "true" } }]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-repositories-present.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ // tear down
+ process.env['INPUT_REPOSITORIES'] = '';
+ });
+ });
+
+});
+
diff --git a/test/update-servers.js b/test/update-servers.js
new file mode 100644
index 00000000..5280ca91
--- /dev/null
+++ b/test/update-servers.js
@@ -0,0 +1,88 @@
+var assert = require('assert');
+var process = require('process');
+var settings = require('../src/settings')
+
+describe('validate servers', function () {
+
+ describe('when empty input', function () {
+ it(' should be not be changed when input.server is missing', function () {
+ // given input
+ process.env['INPUT_SERVERS'] = '';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-servers-missing.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ // tear down
+ process.env['INPUT_SERVERS'] = '';
+ });
+ });
+
+ describe('when custom input', function () {
+ it(' should be appended with when input.server is present', function () {
+ // given input
+ process.env['INPUT_SERVERS'] = '[{ "id": "foo", "username": "fu", "password": "bar" }]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-servers-present.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ // tear down
+ process.env['INPUT_SERVERS'] = '';
+ });
+ });
+
+ describe('when extended configuration input', function () {
+ it(' should be appended with when extended configuration is provided', function () {
+ // given input
+ process.env['INPUT_SERVERS'] = '[{ "id": "foo", "username": "fu", "password": "bar", "configuration": { "httpConfiguration": { "all" : { "usePreemptive": "true" }}}}]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-servers-with-extended-configuration.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ // tear down
+ process.env['INPUT_SERVERS'] = '';
+ });
+ });
+
+ describe('when extended properties input', function () {
+ it(' should be appended with and include all maven server properties', function () {
+ // given input
+ process.env['INPUT_SERVERS'] = '[{ "id": "foo", "username": "fu", "password": "bar", "privateKey": "${user.home}/.ssh/id_dsa", "passphrase": "some_passphrase", "filePermissions": "664", "directoryPermissions": "775" }]';
+
+ // when
+ var actualXml = settings.getSettingsTemplate();
+ settings.update(actualXml);
+ var actual = settings.formatSettings(actualXml);
+
+ // then
+ var expectedXml = settings.getTemplate('../test/resources/', 'when-servers-with-extended-properties.xml');
+ expected = settings.formatSettings(expectedXml);
+ assert.equal(actual, expected);
+
+ // tear down
+ process.env['INPUT_SERVERS'] = '';
+ });
+ });
+
+});
+