mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-15 00:00:30 +08:00
Compare commits
147 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d06ffc01c1 | |||
| 85a676bfd7 | |||
| 7c3a8b283a | |||
| db48270276 | |||
| 0120fc220b | |||
| 86e28b1256 | |||
| f7c867403d | |||
| 65009cbda6 | |||
| 4304bcedb3 | |||
| a1400c985d | |||
| 625171aa24 | |||
| 04f57f5f0e | |||
| dd913c92b1 | |||
| 8063cbe254 | |||
| ed58d20239 | |||
| c99cacf8e5 | |||
| 1bd3a222e0 | |||
| 2c724b5972 | |||
| a8a76a7b1e | |||
| 41cc972a6e | |||
| c253de7654 | |||
| e2a43d69f6 | |||
| d20dda0d1e | |||
| 9c3f6ce289 | |||
| fe82f409d0 | |||
| eb293947b5 | |||
| b703e0a7d7 | |||
| 1cf39ceb1b | |||
| 134cffbe71 | |||
| 38474872a0 | |||
| 49cd6b8c78 | |||
| 2e21981438 | |||
| afc0d7896a | |||
| 2e58029a96 | |||
| 80a4416636 | |||
| 3ef9aea393 | |||
| bf2f085f63 | |||
| f7a604dc6b | |||
| c1153c4b91 | |||
| 64d0152d7a | |||
| 5ac0323dc5 | |||
| ee25a92a84 | |||
| fb4ef3151e | |||
| f972cb7ea0 | |||
| eff73b239d | |||
| 8a5150d3c2 | |||
| 13bd1e5d92 | |||
| ceff4e7641 | |||
| ec0855f7cb | |||
| 074e0bfd5e | |||
| 06520eb502 | |||
| 45ea8e67c7 | |||
| adfd5fdbd9 | |||
| 5a796027b8 | |||
| 162ea4b86f | |||
| ed4f3a253e | |||
| f1d20e06f1 | |||
| a72cf9566e | |||
| eaf7fdc666 | |||
| 2300ba896e | |||
| d7a1cbd9a6 | |||
| ac4057b57d | |||
| 89310fb576 | |||
| d8e9709ef0 | |||
| 879f94d6bf | |||
| 25432ff633 | |||
| fa974055b8 | |||
| b09cecc467 | |||
| 90774c5e4a | |||
| 39de721118 | |||
| d2caa874cf | |||
| 51dd9e6a27 | |||
| 656f00e6c3 | |||
| de1640533d | |||
| 1d9b75d383 | |||
| 97fed6ec95 | |||
| 684cea1eed | |||
| 09d4653a85 | |||
| a343407dc0 | |||
| fdd7389b05 | |||
| dfb2ccea7f | |||
| 06eb0c4e33 | |||
| a4747963fd | |||
| b550d25288 | |||
| 57c6d5534f | |||
| ad6e19bf22 | |||
| 4e994b0af9 | |||
| 29b5c3e071 | |||
| 60261ed05e | |||
| be65e70753 | |||
| 30dcff9bf2 | |||
| 4ddcfe5843 | |||
| dc70c1232b | |||
| 712fea742c | |||
| 6da4e99f6e | |||
| 2ba0ae16c3 | |||
| dd92e98a57 | |||
| ffb873a39b | |||
| 499a91c156 | |||
| be814177e9 | |||
| ab664173c6 | |||
| 7669be9e26 | |||
| de15375a60 | |||
| 40b0fc9e3c | |||
| 81b7b67684 | |||
| e6d8814f92 | |||
| e204770e52 | |||
| e4252b9282 | |||
| d80c14480e | |||
| a4fae4024d | |||
| 52fa27d07a | |||
| 4a3e3d7344 | |||
| 268ea183e3 | |||
| c29ea0c1c0 | |||
| 21b6739860 | |||
| dab358be20 | |||
| 00b26a6024 | |||
| 39d3d4092c | |||
| 361aa89eba | |||
| 3835f74748 | |||
| 4c44e52acf | |||
| bc43503d76 | |||
| 033e2b9038 | |||
| 0e3f5e55fa | |||
| b8227c6eb7 | |||
| f971349eef | |||
| fbeab14fb7 | |||
| d47b56a6d1 | |||
| bbae39e33a | |||
| 5e8c1f94f3 | |||
| 02430100a5 | |||
| 4ccfd15f81 | |||
| 42f915d25e | |||
| 783a4c597d | |||
| 6412b866e9 | |||
| 2139b8a41d | |||
| 18af7969c4 | |||
| e6923122c3 | |||
| 17c084c58d | |||
| 9fc918bcdd | |||
| 452305c241 | |||
| 368fd0e83c | |||
| 58f43d2838 | |||
| 83fbfa9571 | |||
| c2f54fb876 | |||
| a8398d8de4 | |||
| 481a4a47bb |
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"commonjs": true,
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": "eslint:recommended",
|
|
||||||
"globals": {
|
|
||||||
"Atomics": "readonly",
|
|
||||||
"SharedArrayBuffer": "readonly"
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2018
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
6
.github/workflows/audit.yml
vendored
6
.github/workflows/audit.yml
vendored
@ -17,11 +17,11 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: '12.x'
|
node-version: '24.x'
|
||||||
|
|
||||||
- run: npm version
|
- run: npm version
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|||||||
13
.github/workflows/release-drafter.yml
vendored
13
.github/workflows/release-drafter.yml
vendored
@ -5,18 +5,9 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'master'
|
||||||
- 'main'
|
- 'main'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update_release_draft:
|
update_release_draft:
|
||||||
name: Update Release Draft
|
name: Update Release Draft
|
||||||
runs-on: ubuntu-latest
|
uses: s4u/.github/.github/workflows/release-drafter.yml@master
|
||||||
concurrency: release-drafter
|
|
||||||
|
|
||||||
if: >
|
|
||||||
github.repository_owner == 's4u'
|
|
||||||
&& !startsWith(github.event.head_commit.message , '[maven-release-plugin]')
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: release-drafter/release-drafter@v5.19.0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|||||||
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
@ -17,16 +17,16 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: '12.x'
|
node-version: '24.x'
|
||||||
|
|
||||||
- uses: actions/setup-java@v3
|
- uses: actions/setup-java@v5
|
||||||
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
|
||||||
56
README.md
56
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@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## ```settings.xml``` with servers section
|
## ```settings.xml``` with servers section
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.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@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.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,24 +96,33 @@ result will be:
|
|||||||
## ```settings.xml``` with mirrors section
|
## ```settings.xml``` with mirrors section
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
|
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## ```settings.xml``` with proxies section
|
||||||
|
```yml
|
||||||
|
step:
|
||||||
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
|
with:
|
||||||
|
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@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
||||||
```
|
```
|
||||||
|
|
||||||
## ```settings.xml``` with https://oss.sonatype.org/content/repositories/snapshots in repository list
|
## ```settings.xml``` with https://central.sonatype.com/repository/maven-snapshots in repository list
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
sonatypeSnapshots: true
|
sonatypeSnapshots: true
|
||||||
```
|
```
|
||||||
@ -122,7 +131,7 @@ steps:
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
apacheSnapshots: true
|
apacheSnapshots: true
|
||||||
```
|
```
|
||||||
@ -130,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@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
override: false
|
override: false
|
||||||
```
|
```
|
||||||
@ -138,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@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
githubServer: false
|
githubServer: false
|
||||||
```
|
```
|
||||||
@ -147,7 +156,7 @@ steps:
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
oracleServers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
oracleServers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||||
```
|
```
|
||||||
@ -155,18 +164,35 @@ 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@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
oracleRepo: true
|
oracleRepo: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## ```settings.xml``` with custom repositories
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
|
with:
|
||||||
|
repositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
|
```
|
||||||
|
|
||||||
|
## ```settings.xml``` with custom plugin repositories
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
|
with:
|
||||||
|
pluginRepositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## GitHub actions secrets
|
## GitHub actions secrets
|
||||||
|
|
||||||
It is also possible pass in Github Secrets e.g.
|
It is also possible pass in Github Secrets e.g.
|
||||||
|
|
||||||
``` yml
|
``` yml
|
||||||
steps:
|
steps:
|
||||||
- uses: s4u/maven-settings-action@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
servers: |
|
servers: |
|
||||||
[{
|
[{
|
||||||
@ -196,7 +222,7 @@ steps:
|
|||||||
with:
|
with:
|
||||||
java-version: 8
|
java-version: 8
|
||||||
|
|
||||||
- uses: s4u/maven-settings-action@v2.6.0
|
- uses: s4u/maven-settings-action@v4.0.0
|
||||||
|
|
||||||
- run: mvn verify
|
- run: mvn verify
|
||||||
```
|
```
|
||||||
|
|||||||
10
action.yml
10
action.yml
@ -15,6 +15,8 @@ inputs:
|
|||||||
mirrors:
|
mirrors:
|
||||||
description: 'mirrors definition in json array, eg: [{"id": "id", "name": "name", "mirrorOf": "mirrorOf", "url": "url"}]'
|
description: 'mirrors definition in json array, eg: [{"id": "id", "name": "name", "mirrorOf": "mirrorOf", "url": "url"}]'
|
||||||
required: false
|
required: false
|
||||||
|
proxies:
|
||||||
|
description: 'proxies definition in json array, eg: [{"id": "id", "active": "active", "protocol": "protocol", "host": "hostl", "port": "port", "nonProxyHosts", "nonProxyHosts"}]'
|
||||||
properties:
|
properties:
|
||||||
description: 'json array with properties, eg [{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
description: 'json array with properties, eg [{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
||||||
required: false
|
required: false
|
||||||
@ -41,8 +43,14 @@ inputs:
|
|||||||
description: 'add Oracle Maven Repository'
|
description: 'add Oracle Maven Repository'
|
||||||
default: "false"
|
default: "false"
|
||||||
required: false
|
required: false
|
||||||
|
repositories:
|
||||||
|
description: 'list of custom repositories as json array, e.g: [{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
|
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: 'node12'
|
using: 'node24'
|
||||||
main: 'index.js'
|
main: 'index.js'
|
||||||
post: 'cleanup.js'
|
post: 'cleanup.js'
|
||||||
|
|||||||
@ -49,12 +49,12 @@ afterAll(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(testHomePath);
|
fs.rmSync(testHomePath, { recursive: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test('run with default values', () => {
|
test('run with default values', () => {
|
||||||
cp.execSync(`node ${cleanupPath}`, { env: process.env }).toString();
|
cp.spawnSync('node', [ `${cleanupPath}` ], { env: process.env }).toString();
|
||||||
})
|
})
|
||||||
|
|||||||
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) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -68,14 +68,16 @@ test('run with all feature', () => {
|
|||||||
process.env['INPUT_GITHUBSERVER'] = true;
|
process.env['INPUT_GITHUBSERVER'] = true;
|
||||||
|
|
||||||
process.env['INPUT_MIRRORS'] = '[{"id": "mirrorId", "name": "mirror Name", "mirrorOf": "mirror Off *", "url": "mirror url"}]';
|
process.env['INPUT_MIRRORS'] = '[{"id": "mirrorId", "name": "mirror Name", "mirrorOf": "mirror Off *", "url": "mirror url"}]';
|
||||||
|
process.env['INPUT_PROXIES'] = '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost"}]';
|
||||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||||
|
|
||||||
process.env['INPUT_APACHESNAPSHOTS'] = true;
|
process.env['INPUT_APACHESNAPSHOTS'] = true;
|
||||||
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_PLUGINREPOSITORIES'] = '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||||
|
|
||||||
cp.execSync(`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);
|
||||||
expect(settingsStatus.isFile()).toBeTruthy();
|
expect(settingsStatus.isFile()).toBeTruthy();
|
||||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||||
@ -128,18 +130,8 @@ test('run with all feature', () => {
|
|||||||
</activation>
|
</activation>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype-snapshots</id>
|
<id>central-snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@ -150,18 +142,8 @@ test('run with all feature', () => {
|
|||||||
</repositories>
|
</repositories>
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>sonatype-snapshots</id>
|
<id>central-snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@ -200,6 +182,24 @@ test('run with all feature', () => {
|
|||||||
</snapshots>
|
</snapshots>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>_custom_repositories_</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<repositories> <repository>
|
||||||
|
<id>repoId</id>
|
||||||
|
<name>repoName</name>
|
||||||
|
<url>url</url>
|
||||||
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
|
</repository></repositories>
|
||||||
|
<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>
|
||||||
@ -242,5 +242,13 @@ test('run with all feature', () => {
|
|||||||
<mirrorOf>mirror Off *</mirrorOf>
|
<mirrorOf>mirror Off *</mirrorOf>
|
||||||
<url>mirror url</url>
|
<url>mirror url</url>
|
||||||
</mirror></mirrors>
|
</mirror></mirrors>
|
||||||
|
<proxies><proxy>
|
||||||
|
<id>proxyId</id>
|
||||||
|
<active>isActive</active>
|
||||||
|
<protocol>proxyProtocol</protocol>
|
||||||
|
<host>proxyHost</host>
|
||||||
|
<port>proxyPort</port>
|
||||||
|
<nonProxyHosts>nonProxyHost</nonProxyHosts>
|
||||||
|
</proxy></proxies>
|
||||||
</settings>`);
|
</settings>`);
|
||||||
})
|
})
|
||||||
|
|||||||
8444
package-lock.json
generated
8444
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "maven-settings-action",
|
"name": "maven-settings-action",
|
||||||
"version": "2.6.0",
|
"version": "4.0.0",
|
||||||
"description": "Prepare maven settings",
|
"description": "Prepare maven settings",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -26,11 +26,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/s4u/maven-settings-action#readme",
|
"homepage": "https://github.com/s4u/maven-settings-action#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.6.0",
|
"@actions/core": "^2.0.3",
|
||||||
"@xmldom/xmldom": "^0.8.1"
|
"@xmldom/xmldom": "^0.8.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.12.0",
|
"eslint": "^9.39.1",
|
||||||
"jest": "^27.5.1"
|
"jest": "^30.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
116
settings.js
116
settings.js
@ -124,6 +124,74 @@ function fillServers(template, templateName) {
|
|||||||
server.configuration));
|
server.configuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fillRepository(templateXml, templateName, id, name, url, releases, snapshots) {
|
||||||
|
|
||||||
|
if (!id || !url) {
|
||||||
|
core.setFailed(templateName + ' must contain id and url');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const repositoryXml = getTemplate(templateName + '.xml')
|
||||||
|
repositoryXml.getElementsByTagName('id')[0].textContent = id;
|
||||||
|
|
||||||
|
const repositoryTags = {
|
||||||
|
'name': name,
|
||||||
|
'url': url
|
||||||
|
};
|
||||||
|
for (const tag in repositoryTags) {
|
||||||
|
const repositoryTag = repositoryXml.getElementsByTagName(tag)[0];
|
||||||
|
const tagValue = repositoryTags[tag];
|
||||||
|
if (tagValue) {
|
||||||
|
repositoryTag.textContent = tagValue;
|
||||||
|
} else {
|
||||||
|
repositoryXml.documentElement.removeChild(repositoryTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const additionalTags = {
|
||||||
|
'releases': releases,
|
||||||
|
'snapshots': snapshots
|
||||||
|
};
|
||||||
|
for (const tag in additionalTags) {
|
||||||
|
const repositoryTag = repositoryXml.getElementsByTagName(tag)[0];
|
||||||
|
const tagValue = additionalTags[tag];
|
||||||
|
if (tagValue) {
|
||||||
|
jsonToXml(templateXml, repositoryTag, tagValue);
|
||||||
|
} else {
|
||||||
|
repositoryXml.documentElement.removeChild(repositoryTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const repositoriesXml = templateXml.getElementsByTagName(templateName)[0];
|
||||||
|
repositoriesXml.appendChild(repositoryXml);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillRepositories(template) {
|
||||||
|
|
||||||
|
const repositories = core.getInput('repositories');
|
||||||
|
const pluginRepositories = core.getInput('pluginRepositories');
|
||||||
|
|
||||||
|
if (!repositories && !pluginRepositories) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const customRepositoriesTemplate = getTemplate('custom-repositories.xml');
|
||||||
|
const profilesXml = template.getElementsByTagName('profiles')[0];
|
||||||
|
profilesXml.appendChild(customRepositoriesTemplate);
|
||||||
|
|
||||||
|
if (repositories) {
|
||||||
|
JSON.parse(repositories).forEach((repository) =>
|
||||||
|
fillRepository(customRepositoriesTemplate, 'repositories',
|
||||||
|
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) {
|
||||||
|
|
||||||
if (!id || !name || !mirrorOf || !url) {
|
if (!id || !name || !mirrorOf || !url) {
|
||||||
@ -152,6 +220,42 @@ function fillMirrors(template) {
|
|||||||
JSON.parse(mirrors).forEach((mirror) => fillMirror(template, mirror.id, mirror.name, mirror.mirrorOf, mirror.url));
|
JSON.parse(mirrors).forEach((mirror) => fillMirror(template, mirror.id, mirror.name, mirror.mirrorOf, mirror.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fillProxies(template) {
|
||||||
|
|
||||||
|
const proxies = core.getInput('proxies');
|
||||||
|
|
||||||
|
if (!proxies) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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, proxyUser, proxyPassword) {
|
||||||
|
if(!id || !active || !protocol || !host || !port || !nonProxyHosts) {
|
||||||
|
core.setFailed('proxies must contain id, active, protocol, host, port and nonProxyHosts');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const proxyXml = getTemplate('proxy.xml');
|
||||||
|
proxyXml.getElementsByTagName("id")[0].textContent = id;
|
||||||
|
proxyXml.getElementsByTagName("active")[0].textContent = active;
|
||||||
|
proxyXml.getElementsByTagName("protocol")[0].textContent = protocol;
|
||||||
|
proxyXml.getElementsByTagName("host")[0].textContent = host;
|
||||||
|
proxyXml.getElementsByTagName("port")[0].textContent = port;
|
||||||
|
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];
|
||||||
|
proxiesXml.appendChild(proxyXml);
|
||||||
|
}
|
||||||
|
|
||||||
function isInputTrue(inputName) {
|
function isInputTrue(inputName) {
|
||||||
const val = core.getInput(inputName);
|
const val = core.getInput(inputName);
|
||||||
return val && val.toLocaleLowerCase() == 'true';
|
return val && val.toLocaleLowerCase() == 'true';
|
||||||
@ -218,7 +322,7 @@ function generate() {
|
|||||||
|
|
||||||
const settingsPath = getSettingsPath();
|
const settingsPath = getSettingsPath();
|
||||||
|
|
||||||
core.info('Prepare maven setings: ' + settingsPath);
|
core.info('Prepare maven settings: ' + settingsPath);
|
||||||
|
|
||||||
if (fs.existsSync(settingsPath)) {
|
if (fs.existsSync(settingsPath)) {
|
||||||
if (isInputTrue('override')) {
|
if (isInputTrue('override')) {
|
||||||
@ -230,6 +334,7 @@ function generate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const settingsXml = getTemplate('settings.xml');
|
const settingsXml = getTemplate('settings.xml');
|
||||||
|
fillProxies(settingsXml);
|
||||||
fillMirrors(settingsXml);
|
fillMirrors(settingsXml);
|
||||||
fillServers(settingsXml, 'servers');
|
fillServers(settingsXml, 'servers');
|
||||||
fillServers(settingsXml, 'oracleServers');
|
fillServers(settingsXml, 'oracleServers');
|
||||||
@ -238,6 +343,7 @@ function generate() {
|
|||||||
addApacheSnapshots(settingsXml);
|
addApacheSnapshots(settingsXml);
|
||||||
addSonatypeSnapshots(settingsXml);
|
addSonatypeSnapshots(settingsXml);
|
||||||
addOracleRepo(settingsXml);
|
addOracleRepo(settingsXml);
|
||||||
|
fillRepositories(settingsXml)
|
||||||
writeSettings(settingsPath, settingsXml);
|
writeSettings(settingsPath, settingsXml);
|
||||||
core.saveState('maven-settings', 'ok');
|
core.saveState('maven-settings', 'ok');
|
||||||
}
|
}
|
||||||
@ -249,12 +355,12 @@ function cleanup() {
|
|||||||
if (mavenSettingsState == 'ok') {
|
if (mavenSettingsState == 'ok') {
|
||||||
if (fs.existsSync(settingsPath)) {
|
if (fs.existsSync(settingsPath)) {
|
||||||
fs.unlinkSync(settingsPath);
|
fs.unlinkSync(settingsPath);
|
||||||
core.info('Cleanup maven setings: ' + settingsPath + ' - file was removed');
|
core.info('Cleanup maven settings: ' + settingsPath + ' - file was removed');
|
||||||
} else {
|
} else {
|
||||||
core.warning('Cleanup maven setings: ' + settingsPath + ' - file not exist');
|
core.warning('Cleanup maven settings: ' + settingsPath + ' - file not exist');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
core.info('Cleanup maven setings: ' + settingsPath + ' - file wasn\'t generated by action');
|
core.info('Cleanup maven settings: ' + settingsPath + ' - file wasn\'t generated by action');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,8 +369,10 @@ module.exports = {
|
|||||||
writeSettings,
|
writeSettings,
|
||||||
fillMirrors,
|
fillMirrors,
|
||||||
fillServers,
|
fillServers,
|
||||||
|
fillProxies,
|
||||||
fillServerForGithub,
|
fillServerForGithub,
|
||||||
fillProperties,
|
fillProperties,
|
||||||
|
fillRepositories,
|
||||||
addApacheSnapshots,
|
addApacheSnapshots,
|
||||||
addSonatypeSnapshots,
|
addSonatypeSnapshots,
|
||||||
addOracleRepo,
|
addOracleRepo,
|
||||||
|
|||||||
244
settings.test.js
244
settings.test.js
@ -87,7 +87,7 @@ afterAll(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(testHomePath);
|
fs.rmSync(testHomePath, { recursive: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -436,6 +436,103 @@ test('fillMirrors incorrect fields', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("fillProxies do noting if no params", () => {
|
||||||
|
const xml = stringAsXml("<proxies/>");
|
||||||
|
|
||||||
|
settings.fillProxies(xml);
|
||||||
|
|
||||||
|
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||||
|
expect(xmlStr).toBe("<proxies/>");
|
||||||
|
expect(consoleOutput).toEqual([]);
|
||||||
|
})
|
||||||
|
|
||||||
|
test("fillProxies one proxy", () => {
|
||||||
|
const xml = stringAsXml("<proxies/>");
|
||||||
|
|
||||||
|
process.env['INPUT_PROXIES'] = `[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol",
|
||||||
|
"host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost"}]`;
|
||||||
|
|
||||||
|
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>
|
||||||
|
</proxy></proxies>`)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
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", () => {
|
||||||
|
const xml = stringAsXml("<proxies/>");
|
||||||
|
|
||||||
|
process.env['INPUT_PROXIES'] = `[{"id": "proxyId1", "active": "isActive1", "protocol": "proxyProtocol1",
|
||||||
|
"host": "proxyHost1", "port": "proxyPort1", "nonProxyHosts": "nonProxyHost1"},
|
||||||
|
{"id": "proxyId2", "active": "isActive2", "protocol": "proxyProtocol2",
|
||||||
|
"host": "proxyHost2", "port": "proxyPort2", "nonProxyHosts": "nonProxyHost2"}]`;
|
||||||
|
|
||||||
|
settings.fillProxies(xml);
|
||||||
|
|
||||||
|
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||||
|
expect(xmlStr).toBe(`<proxies><proxy>
|
||||||
|
<id>proxyId1</id>
|
||||||
|
<active>isActive1</active>
|
||||||
|
<protocol>proxyProtocol1</protocol>
|
||||||
|
<host>proxyHost1</host>
|
||||||
|
<port>proxyPort1</port>
|
||||||
|
<nonProxyHosts>nonProxyHost1</nonProxyHosts>
|
||||||
|
</proxy><proxy>
|
||||||
|
<id>proxyId2</id>
|
||||||
|
<active>isActive2</active>
|
||||||
|
<protocol>proxyProtocol2</protocol>
|
||||||
|
<host>proxyHost2</host>
|
||||||
|
<port>proxyPort2</port>
|
||||||
|
<nonProxyHosts>nonProxyHost2</nonProxyHosts>
|
||||||
|
</proxy></proxies>`)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
test('fillProxies incorrect fields', () => {
|
||||||
|
|
||||||
|
const xml = stringAsXml("<proxies/>");
|
||||||
|
|
||||||
|
process.env['INPUT_PROXIES'] = '[{"idx": "id1"}]';
|
||||||
|
|
||||||
|
settings.fillProxies(xml);
|
||||||
|
|
||||||
|
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||||
|
|
||||||
|
expect(xmlStr).toBe('<proxies/>');
|
||||||
|
expect(consoleOutput).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.stringMatching(/::error::proxies must contain id, active, protocol, host, port and nonProxyHosts/)
|
||||||
|
])
|
||||||
|
);
|
||||||
|
})
|
||||||
|
|
||||||
test('addApacheSnapshots', () => {
|
test('addApacheSnapshots', () => {
|
||||||
|
|
||||||
process.env['INPUT_APACHESNAPSHOTS'] = "true";
|
process.env['INPUT_APACHESNAPSHOTS'] = "true";
|
||||||
@ -495,18 +592,8 @@ test('addSonatypeSnapshots', () => {
|
|||||||
</activation>
|
</activation>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype-snapshots</id>
|
<id>central-snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@ -517,18 +604,8 @@ test('addSonatypeSnapshots', () => {
|
|||||||
</repositories>
|
</repositories>
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>sonatype-snapshots</id>
|
<id>central-snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@ -631,7 +708,7 @@ test('cleanup - not generated', () => {
|
|||||||
|
|
||||||
expect(consoleOutput).toEqual(
|
expect(consoleOutput).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.stringMatching(/Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file wasn\'t generated by action/)
|
expect.stringMatching(/Cleanup maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file wasn\'t generated by action/)
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -644,7 +721,7 @@ test('cleanup - not exist', () => {
|
|||||||
|
|
||||||
expect(consoleOutput).toEqual(
|
expect(consoleOutput).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.stringMatching(/::warning::Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file not exist/)
|
expect.stringMatching(/::warning::Cleanup maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file not exist/)
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -658,13 +735,13 @@ test('cleanup - ok', () => {
|
|||||||
|
|
||||||
expect(consoleOutput).toEqual(
|
expect(consoleOutput).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.stringMatching(/Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file was removed/)
|
expect.stringMatching(/Cleanup maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file was removed/)
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
expect(fs.existsSync(settingsPath)).not.toBeTruthy();
|
expect(fs.existsSync(settingsPath)).not.toBeTruthy();
|
||||||
})
|
})
|
||||||
|
|
||||||
test('genereate', () => {
|
test('generate', () => {
|
||||||
|
|
||||||
process.env['INPUT_SERVERS'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
process.env['INPUT_SERVERS'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||||
@ -674,13 +751,13 @@ test('genereate', () => {
|
|||||||
|
|
||||||
expect(consoleOutput).toEqual(
|
expect(consoleOutput).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
expect.stringMatching(/Prepare maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||||
expect.stringMatching(/:save-state name=maven-settings::ok/)
|
expect.stringMatching(/:save-state name=maven-settings::ok/)
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
||||||
test('genereate - skip', () => {
|
test('generate - skip', () => {
|
||||||
|
|
||||||
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
||||||
|
|
||||||
@ -688,13 +765,13 @@ test('genereate - skip', () => {
|
|||||||
|
|
||||||
expect(consoleOutput).toEqual(
|
expect(consoleOutput).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
expect.stringMatching(/Prepare maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||||
expect.stringMatching(/::warning::maven settings.xml already exists - skip/)
|
expect.stringMatching(/::warning::maven settings.xml already exists - skip/)
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
||||||
test('genereate - override', () => {
|
test('generate - override', () => {
|
||||||
|
|
||||||
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
||||||
process.env['INPUT_OVERRIDE'] = 'true';
|
process.env['INPUT_OVERRIDE'] = 'true';
|
||||||
@ -703,7 +780,7 @@ test('genereate - override', () => {
|
|||||||
|
|
||||||
expect(consoleOutput).toEqual(
|
expect(consoleOutput).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
expect.stringMatching(/Prepare maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||||
expect.stringMatching(/maven settings.xml already exists - override/),
|
expect.stringMatching(/maven settings.xml already exists - override/),
|
||||||
expect.stringMatching(/:save-state name=maven-settings::ok/)
|
expect.stringMatching(/:save-state name=maven-settings::ok/)
|
||||||
])
|
])
|
||||||
@ -724,3 +801,102 @@ test('generate - custom path', () => {
|
|||||||
expect(settingsStatus.isFile()).toBeTruthy();
|
expect(settingsStatus.isFile()).toBeTruthy();
|
||||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('addCustomRepositories - one with snapshots one without', () => {
|
||||||
|
|
||||||
|
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}},{"id":"repoId2","url":"url2"}]'
|
||||||
|
|
||||||
|
const xml = stringAsXml('<profiles/>');
|
||||||
|
|
||||||
|
settings.fillRepositories(xml,'repositories');
|
||||||
|
|
||||||
|
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||||
|
expect(xmlStr).toBe(`<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>_custom_repositories_</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<repositories> <repository>
|
||||||
|
<id>repoId</id>
|
||||||
|
<name>repoName</name>
|
||||||
|
<url>url</url>
|
||||||
|
|
||||||
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
|
</repository> <repository>
|
||||||
|
<id>repoId2</id>
|
||||||
|
|
||||||
|
<url>url2</url>
|
||||||
|
|
||||||
|
|
||||||
|
</repository></repositories>
|
||||||
|
<pluginRepositories/>
|
||||||
|
</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', () => {
|
||||||
|
|
||||||
|
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName"}]'
|
||||||
|
|
||||||
|
const xml = stringAsXml('<profiles/>');
|
||||||
|
|
||||||
|
settings.fillRepositories(xml,'repositories');
|
||||||
|
|
||||||
|
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||||
|
|
||||||
|
expect(xmlStr).toBe(`<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>_custom_repositories_</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<repositories/>
|
||||||
|
<pluginRepositories/>
|
||||||
|
</profile></profiles>`);
|
||||||
|
expect(consoleOutput).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.stringMatching(/::error::repositories must contain id and url/)
|
||||||
|
])
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
9
templates/custom-repositories.xml
Normal file
9
templates/custom-repositories.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>_custom_repositories_</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<repositories/>
|
||||||
|
<pluginRepositories/>
|
||||||
|
</profile>
|
||||||
7
templates/pluginRepositories.xml
Normal file
7
templates/pluginRepositories.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<pluginRepository>
|
||||||
|
<id/>
|
||||||
|
<name/>
|
||||||
|
<url/>
|
||||||
|
<releases/>
|
||||||
|
<snapshots/>
|
||||||
|
</pluginRepository>
|
||||||
8
templates/proxy.xml
Normal file
8
templates/proxy.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<proxy>
|
||||||
|
<id />
|
||||||
|
<active />
|
||||||
|
<protocol />
|
||||||
|
<host />
|
||||||
|
<port />
|
||||||
|
<nonProxyHosts />
|
||||||
|
</proxy>
|
||||||
7
templates/repositories.xml
Normal file
7
templates/repositories.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<repository>
|
||||||
|
<id/>
|
||||||
|
<name/>
|
||||||
|
<url/>
|
||||||
|
<releases/>
|
||||||
|
<snapshots/>
|
||||||
|
</repository>
|
||||||
@ -3,4 +3,5 @@
|
|||||||
<profiles/>
|
<profiles/>
|
||||||
<servers />
|
<servers />
|
||||||
<mirrors />
|
<mirrors />
|
||||||
|
<proxies />
|
||||||
</settings>
|
</settings>
|
||||||
|
|||||||
@ -6,18 +6,8 @@
|
|||||||
</activation>
|
</activation>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype-snapshots</id>
|
<id>central-snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@ -28,18 +18,8 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>sonatype-snapshots</id>
|
<id>central-snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>false</enabled>
|
<enabled>false</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
|
|||||||
Reference in New Issue
Block a user