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"}]'
properties: '[{"prop1": "value1"}, {"prop2": "value2"}]'
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
apacheSnapshots: true
sonatypeSnapshots: true
oracleServers: '[{"id": "oServerId", "username": "oUsername", "password": "oPassword"}]'
oracleRepo: true

View File

@ -63,6 +63,14 @@ steps:
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 :
```yml
steps:

View File

@ -19,6 +19,10 @@ inputs:
description: 'add https://oss.sonatype.org/content/repositories/snapshots to repository list - true or false'
default: "false"
required: false
apacheSnapshots:
description: 'add https://repository.apache.org/snapshots to repository list - true or false'
default: "false"
required: false
override:
description: 'override existing settings.xml file'
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_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
process.env['INPUT_APACHESNAPSHOTS'] = true;
process.env['INPUT_SONATYPESNAPSHOTS'] = true;
process.env['INPUT_ORACLEREPO'] = true;
@ -90,6 +91,36 @@ test('run with all feature', () => {
</activation>
<properties><prop1>value1</prop1><prop2>value2</prop2></properties>
</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>
<id>_sonatype-snapshots_</id>
<activation>

View File

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