mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-19 00:00:25 +08:00
Merge remote-tracking branch 'origin/master' into releases/v3
This commit is contained in:
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"commonjs": true,
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": "eslint:recommended",
|
|
||||||
"globals": {
|
|
||||||
"Atomics": "readonly",
|
|
||||||
"SharedArrayBuffer": "readonly"
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2018
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -25,8 +25,8 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-java@v4
|
- uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'temurin'
|
||||||
java-version: '8'
|
java-version: '17'
|
||||||
|
|
||||||
|
|
||||||
- run: npm version
|
- run: npm version
|
||||||
|
|||||||
25
MAINTENANCE.md
Normal file
25
MAINTENANCE.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# update dependencies
|
||||||
|
|
||||||
|
npm update
|
||||||
|
npm outdated
|
||||||
|
|
||||||
|
If new version exist put '*' in `package.json` and run again `npm update`
|
||||||
|
|
||||||
|
- new commit with dependency updates
|
||||||
|
|
||||||
|
# new release
|
||||||
|
|
||||||
|
- run - npm version patch -m "prepare release %s"
|
||||||
|
or
|
||||||
|
- run - npm version minor -m "prepare release %s"
|
||||||
|
|
||||||
|
- push commit
|
||||||
|
|
||||||
|
- checkout release/vX
|
||||||
|
- merge master and push
|
||||||
|
- run
|
||||||
|
npm update
|
||||||
|
npm install
|
||||||
|
npm prune --production
|
||||||
|
- commit and push "update dependency after merge from master"
|
||||||
|
- git tag and git push --tags
|
||||||
43
README.md
43
README.md
@ -31,14 +31,14 @@ See [action.yml](action.yml)
|
|||||||
## default ```settings.xml```
|
## default ```settings.xml```
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## ```settings.xml``` with servers section
|
## ```settings.xml``` with servers section
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||||
```
|
```
|
||||||
@ -62,7 +62,7 @@ Please refer to the [servers](http://maven.apache.org/settings.html#Servers) doc
|
|||||||
|
|
||||||
``` yml
|
``` yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
servers: |
|
servers: |
|
||||||
[{
|
[{
|
||||||
@ -80,7 +80,7 @@ steps:
|
|||||||
result will be:
|
result will be:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<server>
|
<servers><server>
|
||||||
<id>serverId</id>
|
<id>serverId</id>
|
||||||
<configuration>
|
<configuration>
|
||||||
<item1>value1</item1>
|
<item1>value1</item1>
|
||||||
@ -96,7 +96,7 @@ result will be:
|
|||||||
## ```settings.xml``` with mirrors section
|
## ```settings.xml``` with mirrors section
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
|
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
|
||||||
```
|
```
|
||||||
@ -104,15 +104,16 @@ steps:
|
|||||||
## ```settings.xml``` with proxies section
|
## ```settings.xml``` with proxies section
|
||||||
```yml
|
```yml
|
||||||
step:
|
step:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
proxies: '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost"}]'
|
proxies: '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost", "user": "proxUser", "password": "proxPassword"}]'
|
||||||
```
|
```
|
||||||
|
Note: Authentication details are optional.
|
||||||
|
|
||||||
## ```settings.xml``` with properties
|
## ```settings.xml``` with properties
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
||||||
```
|
```
|
||||||
@ -121,7 +122,7 @@ steps:
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
sonatypeSnapshots: true
|
sonatypeSnapshots: true
|
||||||
```
|
```
|
||||||
@ -130,7 +131,7 @@ steps:
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
apacheSnapshots: true
|
apacheSnapshots: true
|
||||||
```
|
```
|
||||||
@ -138,7 +139,7 @@ steps:
|
|||||||
## Do not override existing ```settings.xml```, from version **2.0** file is override by default :
|
## Do not override existing ```settings.xml```, from version **2.0** file is override by default :
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
override: false
|
override: false
|
||||||
```
|
```
|
||||||
@ -146,7 +147,7 @@ steps:
|
|||||||
## Do not add github to server in ```settings.xml```, by default is added:
|
## Do not add github to server in ```settings.xml```, by default is added:
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
githubServer: false
|
githubServer: false
|
||||||
```
|
```
|
||||||
@ -155,7 +156,7 @@ steps:
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
oracleServers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
oracleServers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||||
```
|
```
|
||||||
@ -163,7 +164,7 @@ steps:
|
|||||||
## ```settings.xml``` with [Oracle Maven Repository](https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9017)
|
## ```settings.xml``` with [Oracle Maven Repository](https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9017)
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
oracleRepo: true
|
oracleRepo: true
|
||||||
```
|
```
|
||||||
@ -171,11 +172,19 @@ steps:
|
|||||||
## ```settings.xml``` with custom repositories
|
## ```settings.xml``` with custom repositories
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
repositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
repositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## ```settings.xml``` with custom plugin repositories
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
|
with:
|
||||||
|
pluginRepositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## GitHub actions secrets
|
## GitHub actions secrets
|
||||||
|
|
||||||
@ -183,7 +192,7 @@ It is also possible pass in Github Secrets e.g.
|
|||||||
|
|
||||||
``` yml
|
``` yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
with:
|
with:
|
||||||
servers: |
|
servers: |
|
||||||
[{
|
[{
|
||||||
@ -213,7 +222,7 @@ steps:
|
|||||||
with:
|
with:
|
||||||
java-version: 8
|
java-version: 8
|
||||||
|
|
||||||
- uses: s4u/maven-settings-action@v3.0.0
|
- uses: s4u/maven-settings-action@v3.1.0
|
||||||
|
|
||||||
- run: mvn verify
|
- run: mvn verify
|
||||||
```
|
```
|
||||||
|
|||||||
@ -46,6 +46,9 @@ inputs:
|
|||||||
repositories:
|
repositories:
|
||||||
description: 'list of custom repositories as json array, e.g: [{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
description: 'list of custom repositories as json array, e.g: [{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
required: false
|
required: false
|
||||||
|
pluginRepositories:
|
||||||
|
description: 'list of custom plugin repositories as json array, e.g: [{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
|
|||||||
@ -49,7 +49,7 @@ afterAll(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(testHomePath);
|
fs.rmSync(testHomePath, { recursive: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
29
eslint.config.mjs
Normal file
29
eslint.config.mjs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import globals from "globals";
|
||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import js from "@eslint/js";
|
||||||
|
import { FlatCompat } from "@eslint/eslintrc";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
recommendedConfig: js.configs.recommended,
|
||||||
|
allConfig: js.configs.all
|
||||||
|
});
|
||||||
|
|
||||||
|
export default [...compat.extends("eslint:recommended"), {
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.commonjs,
|
||||||
|
...globals.node,
|
||||||
|
Atomics: "readonly",
|
||||||
|
SharedArrayBuffer: "readonly",
|
||||||
|
},
|
||||||
|
|
||||||
|
ecmaVersion: 2018,
|
||||||
|
sourceType: "commonjs",
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {},
|
||||||
|
}];
|
||||||
@ -55,7 +55,7 @@ afterAll(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(testHomePath);
|
fs.rmSync(testHomePath, { recursive: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -75,6 +75,7 @@ test('run with all feature', () => {
|
|||||||
process.env['INPUT_SONATYPESNAPSHOTS'] = true;
|
process.env['INPUT_SONATYPESNAPSHOTS'] = true;
|
||||||
process.env['INPUT_ORACLEREPO'] = true;
|
process.env['INPUT_ORACLEREPO'] = true;
|
||||||
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
|
process.env['INPUT_PLUGINREPOSITORIES'] = '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
|
|
||||||
cp.spawnSync('node', [ `${indexPath}` ], { env: process.env, stdio: 'inherit' });
|
cp.spawnSync('node', [ `${indexPath}` ], { env: process.env, stdio: 'inherit' });
|
||||||
const settingsStatus = fs.lstatSync(settingsPath);
|
const settingsStatus = fs.lstatSync(settingsPath);
|
||||||
@ -213,7 +214,12 @@ test('run with all feature', () => {
|
|||||||
<url>url</url>
|
<url>url</url>
|
||||||
<snapshots><enabled>true</enabled></snapshots>
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
</repository></repositories>
|
</repository></repositories>
|
||||||
<pluginRepositories/>
|
<pluginRepositories> <pluginRepository>
|
||||||
|
<id>repoId</id>
|
||||||
|
<name>repoName</name>
|
||||||
|
<url>url</url>
|
||||||
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
|
</pluginRepository></pluginRepositories>
|
||||||
</profile></profiles>
|
</profile></profiles>
|
||||||
<servers>
|
<servers>
|
||||||
<server>
|
<server>
|
||||||
|
|||||||
1819
package-lock.json
generated
1819
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "maven-settings-action",
|
"name": "maven-settings-action",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"description": "Prepare maven settings",
|
"description": "Prepare maven settings",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -30,7 +30,7 @@
|
|||||||
"@xmldom/xmldom": "^0.8.10"
|
"@xmldom/xmldom": "^0.8.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^9.14.0",
|
||||||
"jest": "^29.7.0"
|
"jest": "^29.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
settings.js
50
settings.js
@ -124,7 +124,7 @@ function fillServers(template, templateName) {
|
|||||||
server.configuration));
|
server.configuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillRepository(templateXml, templateName, id, name, url, snapshots) {
|
function fillRepository(templateXml, templateName, id, name, url, releases, snapshots) {
|
||||||
|
|
||||||
if (!id || !url) {
|
if (!id || !url) {
|
||||||
core.setFailed(templateName + ' must contain id and url');
|
core.setFailed(templateName + ' must contain id and url');
|
||||||
@ -148,22 +148,30 @@ function fillRepository(templateXml, templateName, id, name, url, snapshots) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const snapshotsTag = repositoryXml.getElementsByTagName('snapshots')[0];
|
const additionalTags = {
|
||||||
if (snapshots) {
|
'releases': releases,
|
||||||
jsonToXml(templateXml, snapshotsTag, snapshots);
|
'snapshots': snapshots
|
||||||
|
};
|
||||||
|
for (const tag in additionalTags) {
|
||||||
|
const repositoryTag = repositoryXml.getElementsByTagName(tag)[0];
|
||||||
|
const tagValue = additionalTags[tag];
|
||||||
|
if (tagValue) {
|
||||||
|
jsonToXml(templateXml, repositoryTag, tagValue);
|
||||||
} else {
|
} else {
|
||||||
repositoryXml.documentElement.removeChild(snapshotsTag);
|
repositoryXml.documentElement.removeChild(repositoryTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const repositoriesXml = templateXml.getElementsByTagName('repositories')[0];
|
const repositoriesXml = templateXml.getElementsByTagName(templateName)[0];
|
||||||
repositoriesXml.appendChild(repositoryXml);
|
repositoriesXml.appendChild(repositoryXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillRepositories(template, templateName) {
|
function fillRepositories(template) {
|
||||||
|
|
||||||
const repositories = core.getInput(templateName);
|
const repositories = core.getInput('repositories');
|
||||||
|
const pluginRepositories = core.getInput('pluginRepositories');
|
||||||
|
|
||||||
if (!repositories) {
|
if (!repositories && !pluginRepositories) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,9 +180,16 @@ function fillRepositories(template, templateName) {
|
|||||||
const profilesXml = template.getElementsByTagName('profiles')[0];
|
const profilesXml = template.getElementsByTagName('profiles')[0];
|
||||||
profilesXml.appendChild(customRepositoriesTemplate);
|
profilesXml.appendChild(customRepositoriesTemplate);
|
||||||
|
|
||||||
|
if (repositories) {
|
||||||
JSON.parse(repositories).forEach((repository) =>
|
JSON.parse(repositories).forEach((repository) =>
|
||||||
fillRepository(customRepositoriesTemplate, templateName, repository.id, repository.name, repository.url,
|
fillRepository(customRepositoriesTemplate, 'repositories',
|
||||||
repository.snapshots));
|
repository.id, repository.name, repository.url, repository.releases, repository.snapshots));
|
||||||
|
}
|
||||||
|
if (pluginRepositories) {
|
||||||
|
JSON.parse(pluginRepositories).forEach((repository) =>
|
||||||
|
fillRepository(customRepositoriesTemplate, 'pluginRepositories',
|
||||||
|
repository.id, repository.name, repository.url, repository.releases, repository.snapshots));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillMirror(template, id, name, mirrorOf, url) {
|
function fillMirror(template, id, name, mirrorOf, url) {
|
||||||
@ -213,10 +228,10 @@ function fillProxies(template) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSON.parse(proxies).forEach((proxy) => fillProxy(template, proxy.id, proxy.active, proxy.protocol, proxy.host, proxy.port, proxy.nonProxyHosts));
|
JSON.parse(proxies).forEach((proxy) => fillProxy(template, proxy.id, proxy.active, proxy.protocol, proxy.host, proxy.port, proxy.nonProxyHosts, proxy.user, proxy.password));
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillProxy(template, id, active, protocol, host, port, nonProxyHosts) {
|
function fillProxy(template, id, active, protocol, host, port, nonProxyHosts, proxyUser, proxyPassword) {
|
||||||
if(!id || !active || !protocol || !host || !port || !nonProxyHosts) {
|
if(!id || !active || !protocol || !host || !port || !nonProxyHosts) {
|
||||||
core.setFailed('proxies must contain id, active, protocol, host, port and nonProxyHosts');
|
core.setFailed('proxies must contain id, active, protocol, host, port and nonProxyHosts');
|
||||||
return;
|
return;
|
||||||
@ -230,6 +245,13 @@ function fillProxy(template, id, active, protocol, host, port, nonProxyHosts) {
|
|||||||
proxyXml.getElementsByTagName("port")[0].textContent = port;
|
proxyXml.getElementsByTagName("port")[0].textContent = port;
|
||||||
proxyXml.getElementsByTagName("nonProxyHosts")[0].textContent = nonProxyHosts;
|
proxyXml.getElementsByTagName("nonProxyHosts")[0].textContent = nonProxyHosts;
|
||||||
|
|
||||||
|
if(proxyUser) {
|
||||||
|
jsonToXml(proxyXml, proxyXml.documentElement, {username: proxyUser});
|
||||||
|
}
|
||||||
|
if(proxyPassword) {
|
||||||
|
jsonToXml(proxyXml, proxyXml.documentElement, {password: proxyPassword});
|
||||||
|
}
|
||||||
|
|
||||||
const proxiesXml = template.getElementsByTagName('proxies')[0];
|
const proxiesXml = template.getElementsByTagName('proxies')[0];
|
||||||
proxiesXml.appendChild(proxyXml);
|
proxiesXml.appendChild(proxyXml);
|
||||||
}
|
}
|
||||||
@ -321,7 +343,7 @@ function generate() {
|
|||||||
addApacheSnapshots(settingsXml);
|
addApacheSnapshots(settingsXml);
|
||||||
addSonatypeSnapshots(settingsXml);
|
addSonatypeSnapshots(settingsXml);
|
||||||
addOracleRepo(settingsXml);
|
addOracleRepo(settingsXml);
|
||||||
fillRepositories(settingsXml,'repositories')
|
fillRepositories(settingsXml)
|
||||||
writeSettings(settingsPath, settingsXml);
|
writeSettings(settingsPath, settingsXml);
|
||||||
core.saveState('maven-settings', 'ok');
|
core.saveState('maven-settings', 'ok');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ afterAll(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(testHomePath);
|
fs.rmSync(testHomePath, { recursive: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -466,6 +466,26 @@ test("fillProxies one proxy", () => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("fillProxies one proxy with auth info", () => {
|
||||||
|
const xml = stringAsXml("<proxies/>");
|
||||||
|
|
||||||
|
process.env['INPUT_PROXIES'] = `[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol",
|
||||||
|
"host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost", "user": "proxyUser", "password": "somepassword"}]`;
|
||||||
|
|
||||||
|
settings.fillProxies(xml);
|
||||||
|
|
||||||
|
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||||
|
expect(xmlStr).toBe(`<proxies><proxy>
|
||||||
|
<id>proxyId</id>
|
||||||
|
<active>isActive</active>
|
||||||
|
<protocol>proxyProtocol</protocol>
|
||||||
|
<host>proxyHost</host>
|
||||||
|
<port>proxyPort</port>
|
||||||
|
<nonProxyHosts>nonProxyHost</nonProxyHosts>
|
||||||
|
<username>proxyUser</username><password>somepassword</password></proxy></proxies>`)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
test("fillProxies two proxies", () => {
|
test("fillProxies two proxies", () => {
|
||||||
const xml = stringAsXml("<proxies/>");
|
const xml = stringAsXml("<proxies/>");
|
||||||
|
|
||||||
@ -821,17 +841,60 @@ test('addCustomRepositories - one with snapshots one without', () => {
|
|||||||
<id>repoId</id>
|
<id>repoId</id>
|
||||||
<name>repoName</name>
|
<name>repoName</name>
|
||||||
<url>url</url>
|
<url>url</url>
|
||||||
|
|
||||||
<snapshots><enabled>true</enabled></snapshots>
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
</repository> <repository>
|
</repository> <repository>
|
||||||
<id>repoId2</id>
|
<id>repoId2</id>
|
||||||
|
|
||||||
<url>url2</url>
|
<url>url2</url>
|
||||||
|
|
||||||
|
|
||||||
</repository></repositories>
|
</repository></repositories>
|
||||||
<pluginRepositories/>
|
<pluginRepositories/>
|
||||||
</profile></profiles>`);
|
</profile></profiles>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('addCustomPluginRepositories - one with releases and snapshots one without', () => {
|
||||||
|
|
||||||
|
process.env['INPUT_PLUGINREPOSITORIES'] = `
|
||||||
|
[{"id":"repoId",
|
||||||
|
"name":"repoName",
|
||||||
|
"url":"url",
|
||||||
|
"releases":{"enabled":false},
|
||||||
|
"snapshots":{"enabled":true}
|
||||||
|
},{
|
||||||
|
"id":"repoId2",
|
||||||
|
"url":"url2"
|
||||||
|
}]`
|
||||||
|
|
||||||
|
const xml = stringAsXml('<profiles/>');
|
||||||
|
|
||||||
|
settings.fillRepositories(xml,'pluginRepositories');
|
||||||
|
|
||||||
|
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||||
|
expect(xmlStr).toBe(`<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>_custom_repositories_</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<repositories/>
|
||||||
|
<pluginRepositories> <pluginRepository>
|
||||||
|
<id>repoId</id>
|
||||||
|
<name>repoName</name>
|
||||||
|
<url>url</url>
|
||||||
|
<releases><enabled>false</enabled></releases>
|
||||||
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
|
</pluginRepository> <pluginRepository>
|
||||||
|
<id>repoId2</id>
|
||||||
|
|
||||||
|
<url>url2</url>
|
||||||
|
|
||||||
|
|
||||||
|
</pluginRepository></pluginRepositories>
|
||||||
|
</profile></profiles>`);
|
||||||
|
});
|
||||||
|
|
||||||
test('addCustomRepositories - fail if url is missing', () => {
|
test('addCustomRepositories - fail if url is missing', () => {
|
||||||
|
|
||||||
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName"}]'
|
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName"}]'
|
||||||
|
|||||||
7
templates/pluginRepositories.xml
Normal file
7
templates/pluginRepositories.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<pluginRepository>
|
||||||
|
<id/>
|
||||||
|
<name/>
|
||||||
|
<url/>
|
||||||
|
<releases/>
|
||||||
|
<snapshots/>
|
||||||
|
</pluginRepository>
|
||||||
@ -2,5 +2,6 @@
|
|||||||
<id/>
|
<id/>
|
||||||
<name/>
|
<name/>
|
||||||
<url/>
|
<url/>
|
||||||
|
<releases/>
|
||||||
<snapshots/>
|
<snapshots/>
|
||||||
</repository>
|
</repository>
|
||||||
Reference in New Issue
Block a user