Merge pull request #65 from s4u/apache-snapshot

Apache snapshots repository
This commit is contained in:
Slawomir Jaranowski
2020-10-16 16:32:00 +02:00
committed by GitHub
7 changed files with 125 additions and 0 deletions

View File

@ -36,6 +36,7 @@ jobs:
servers: '[{"id": "serverId", "username": "username", "password": "password"}]' servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
properties: '[{"prop1": "value1"}, {"prop2": "value2"}]' properties: '[{"prop1": "value1"}, {"prop2": "value2"}]'
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]' mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
apacheSnapshots: true
sonatypeSnapshots: true sonatypeSnapshots: true
oracleServers: '[{"id": "oServerId", "username": "oUsername", "password": "oPassword"}]' oracleServers: '[{"id": "oServerId", "username": "oUsername", "password": "oPassword"}]'
oracleRepo: true oracleRepo: true

View File

@ -63,6 +63,14 @@ steps:
sonatypeSnapshots: true sonatypeSnapshots: true
``` ```
Create ```settings.xml``` with https://repository.apache.org/snapshots/ in repository list
```yml
steps:
- uses: s4u/maven-settings-action@v2.1.1
with:
apacheSnapshots: true
```
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:

View File

@ -19,6 +19,10 @@ inputs:
description: 'add https://oss.sonatype.org/content/repositories/snapshots to repository list - true or false' description: 'add https://oss.sonatype.org/content/repositories/snapshots to repository list - true or false'
default: "false" default: "false"
required: false required: false
apacheSnapshots:
description: 'add https://repository.apache.org/snapshots to repository list - true or false'
default: "false"
required: false
override: override:
description: 'override existing settings.xml file' description: 'override existing settings.xml file'
default: "true" default: "true"

View File

@ -70,6 +70,7 @@ test('run with all feature', () => {
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_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]' process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
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;
@ -90,6 +91,36 @@ test('run with all feature', () => {
</activation> </activation>
<properties><prop1>value1</prop1><prop2>value2</prop2></properties> <properties><prop1>value1</prop1><prop2>value2</prop2></properties>
</profile> </profile>
<profile>
<id>_apache-snapshots_</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>apache.snapshots.https</id>
<url>https://repository.apache.org/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots.https</id>
<url>https://repository.apache.org/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile> <profile>
<id>_sonatype-snapshots_</id> <id>_sonatype-snapshots_</id>
<activation> <activation>

View File

@ -149,6 +149,12 @@ function addProfile(template, profileName) {
profilesXml.appendChild(sonatypeXml); profilesXml.appendChild(sonatypeXml);
} }
function addApacheSnapshots(template) {
if (isInputTrue('apacheSnapshots')) {
addProfile(template, 'apache-snapshot.xml')
}
}
function addSonatypeSnapshots(template) { function addSonatypeSnapshots(template) {
if (isInputTrue('sonatypeSnapshots')) { if (isInputTrue('sonatypeSnapshots')) {
addProfile(template, 'sonatype-snapshot.xml') addProfile(template, 'sonatype-snapshot.xml')
@ -182,6 +188,7 @@ function generate() {
fillServers(settingsXml, 'oracleServers'); fillServers(settingsXml, 'oracleServers');
fillServerForGithub(settingsXml); fillServerForGithub(settingsXml);
fillProperties(settingsXml); fillProperties(settingsXml);
addApacheSnapshots(settingsXml);
addSonatypeSnapshots(settingsXml); addSonatypeSnapshots(settingsXml);
addOracleRepo(settingsXml); addOracleRepo(settingsXml);
writeSettings(settingsPath, settingsXml); writeSettings(settingsPath, settingsXml);
@ -211,6 +218,7 @@ module.exports = {
fillServers, fillServers,
fillServerForGithub, fillServerForGithub,
fillProperties, fillProperties,
addApacheSnapshots,
addSonatypeSnapshots, addSonatypeSnapshots,
addOracleRepo, addOracleRepo,
generate, generate,

View File

@ -319,6 +319,48 @@ test('fillMirrors incorrect fields', () => {
); );
}); });
test('addApacheSnapshots', () => {
process.env['INPUT_APACHESNAPSHOTS'] = "true";
const xml = new DOMParser().parseFromString('<profiles/>');
settings.addApacheSnapshots(xml);
const xmlStr = new XMLSerializer().serializeToString(xml);
expect(xmlStr).toBe(`<profiles>
<profile>
<id>_apache-snapshots_</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>apache.snapshots.https</id>
<url>https://repository.apache.org/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots.https</id>
<url>https://repository.apache.org/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile></profiles>`);
});
test('addSonatypeSnapshots', () => { test('addSonatypeSnapshots', () => {
process.env['INPUT_SONATYPESNAPSHOTS'] = "true"; process.env['INPUT_SONATYPESNAPSHOTS'] = "true";

View File

@ -0,0 +1,31 @@
<profile>
<id>_apache-snapshots_</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>apache.snapshots.https</id>
<url>https://repository.apache.org/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots.https</id>
<url>https://repository.apache.org/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>