mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-18 00:00:26 +08:00
update dependency, code cleanup
This commit is contained in:
29
settings.js
29
settings.js
@ -1,10 +1,14 @@
|
||||
const core = require('@actions/core');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const DOMParser = require('xmldom').DOMParser;
|
||||
const XMLSerializer = require('xmldom').XMLSerializer;
|
||||
const xpath = require('xpath');
|
||||
|
||||
|
||||
const settingsPath = path.join(os.homedir(), '.m2', 'settings.xml');
|
||||
|
||||
function getSettingsTemplate() {
|
||||
const templatePath = path.join(__dirname, 'templates', 'settings.xml');
|
||||
const templateStr = fs.readFileSync(templatePath).toString();
|
||||
@ -82,10 +86,33 @@ function addSonatypeSnapshots(template) {
|
||||
}
|
||||
}
|
||||
|
||||
function generate() {
|
||||
core.info('Prepare maven setings: ' + settingsPath);
|
||||
|
||||
if (fs.existsSync(settingsPath)) {
|
||||
core.warning('maven settings.xml already exists - skip');
|
||||
return;
|
||||
}
|
||||
|
||||
const templateXml = getSettingsTemplate();
|
||||
fillServers(templateXml);
|
||||
fillProperties(templateXml);
|
||||
addSonatypeSnapshots(templateXml);
|
||||
writeSettings(settingsPath, templateXml);
|
||||
core.saveState('maven-settings', 'ok');
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
const mavenSettingsState = core.getState('maven-settings');
|
||||
core.info('Cleanup maven setings: ' + settingsPath + " state: " + mavenSettingsState);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSettingsTemplate,
|
||||
writeSettings,
|
||||
fillServers,
|
||||
fillProperties,
|
||||
addSonatypeSnapshots
|
||||
addSonatypeSnapshots,
|
||||
generate,
|
||||
cleanup
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user