Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: larhauga/nexus-casc-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: vx.3.67.1-01.0-java11
Choose a base ref
...
head repository: larhauga/nexus-casc-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @larhauga
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -16,10 +16,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'adopt'
15 changes: 11 additions & 4 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -3,23 +3,30 @@ name: Build and test nexus-casc-plugin

on:
push:
branches: [ master ]
branches: ["**"]

jobs:
verify:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'adopt'
- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.32.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
continue-on-error: false

- run: ./mvnw -B verify --file pom.xml
- run: mkdir staging && cp target/*.{k,j}ar staging
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: nexus-casc-plugin
path: staging
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG SONATYPE_IMAGE=sonatype/nexus3:3.67.1-java11
ARG SONATYPE_IMAGE=sonatype/nexus3:3.70.1-java11

# hadolint ignore=DL3006
FROM amazoncorretto:11-alpine3.19-jdk as BUILDER
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,11 +6,10 @@ This plugin allows to specify a YAML file to configure a Nexus instance on start

This repository maintains a fork with releases kept in track with the nexus releases.


## Why Fork?

Forked from: https://github.com/AdaptiveConsulting/nexus-casc-plugin
Who forked from: https://github.com/sventschui/nexus-casc-plugin
Forked from: <https://github.com/AdaptiveConsulting/nexus-casc-plugin>
Who forked from: <https://github.com/sventschui/nexus-casc-plugin>

The original provider was unable to maintain the project

@@ -26,16 +25,19 @@ The original provider was unable to maintain the project
## Building

Requires:
* Java 8 JDK (OpenJDK is fine)

* Java 11 JDK (OpenJDK is fine)
* Maven (3.6.3 or higher preferred)
* docker-compose (only if running the integration tests)

To just build the `.kar` archive:

```bash
./mvnw package
```

To build the `.kar` archive and execute the (limited!) integration tests via `docker-compose`:

```bash
./mvnw verify
```
@@ -61,6 +63,7 @@ There is a `docker-compose.yml` file with all the necessary to test this. The te
is located in the `password_johndoe` file. The YAML configuration is located in `default-nexus.yml`. It has a non-working
proxy configuration just to test its configuration. Removing `httpProxy` and/or `httpsProxy` entirely will also clear the relevant
proxy settings on the next boot.

```shell
./mvnw package
docker-compose run nexus
@@ -128,10 +131,10 @@ security:
role: nx-admin
```
#### Repository
for any repositories that require authentication it looks like this:
```yaml
repository:
repositories:
12 changes: 8 additions & 4 deletions default-nexus.yml
Original file line number Diff line number Diff line change
@@ -280,7 +280,8 @@ repository:
apt:
distribution: focal
aptSigning:
keypair: "${file:/run/secrets/gpg_key_example}"
keypair: |
${file:/run/secrets/gpg_key_example}
passphrase: "${file:/run/secrets/gpg_passphrase_example}"
storage:
blobStoreName: apt
@@ -296,7 +297,8 @@ repository:
apt:
distribution: focal
aptSigning:
keypair: "${file:/run/secrets/gpg_key_example}"
keypair: |
${file:/run/secrets/gpg_key_example}
passphrase: "${file:/run/secrets/gpg_passphrase_example}"
proxy:
contentMaxAge: -1
@@ -762,7 +764,8 @@ repository:
repodataDepth: 3
deployPolicy: STRICT # PERMISSIVE for maven yum deployment
yumSigning:
keypair: "${file:/run/secrets/gpg_key_example}"
keypair: |
${file:/run/secrets/gpg_key_example}
passphrase: "${file:/run/secrets/gpg_passphrase_example}"
httpclient:
blocked: false
@@ -792,7 +795,8 @@ repository:
- yum-hosted
- yum-centos
yumSigning:
keypair: "${file:/run/secrets/gpg_key_example}"
keypair: |
${file:/run/secrets/gpg_key_example}
passphrase: "${file:/run/secrets/gpg_passphrase_example}"
storage:
blobStoreName: yum
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -5,26 +5,26 @@
<parent>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-plugins</artifactId>
<version>3.67.1-01</version>
<version>3.70.1-02</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>com.weareadaptive.nexus</groupId>
<artifactId>nexus-casc-plugin</artifactId>
<version>3.67.1-01</version>
<version>3.70.1-02</version>
<packaging>bundle</packaging>

<properties>
<nexus.docker.version>3.67.1</nexus.docker.version>
<nexus.docker.version>3.70.1</nexus.docker.version>

<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<maven-enforcer-plugin.version>3.4.1</maven-enforcer-plugin.version>
<build-helper-maven-plugin.version>3.5.0</build-helper-maven-plugin.version>
<maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
<maven-enforcer-plugin.version>3.5.0</maven-enforcer-plugin.version>
<build-helper-maven-plugin.version>3.6.0</build-helper-maven-plugin.version>
<docker-compose-maven-plugin.version>4.0.0</docker-compose-maven-plugin.version>

<snakeyaml.version>2.2</snakeyaml.version>
<snakeyaml.version>2.3</snakeyaml.version>

<junit-jupiter.version>5.10.2</junit-jupiter.version>
<junit-jupiter.version>5.11.4</junit-jupiter.version>
<system-lambda.version>1.2.1</system-lambda.version>

<kar.finalName>${project.artifactId}-${project.version}</kar.finalName>
Original file line number Diff line number Diff line change
@@ -14,17 +14,17 @@
@Named
public class Interpolator extends ComponentSupport {
public String interpolate(String str) {
String pattern = "\\$(([A-Z0-9_]+)|\\{([^:}]+)(:(\"([^\"}]*)\"|([^}]*)))?})";
Pattern expr = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
String pattern = "(^\\s+)?\\$(([A-Z0-9_]+)|\\{([^:}]+)(:(\"([^\"}]*)\"|([^}]*)))?})";
Pattern expr = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
Matcher matcher = expr.matcher(str);
while (matcher.find()) {
String varName = matcher.group(2);
String varName = matcher.group(3);
if (varName == null) {
varName = matcher.group(3);
varName = matcher.group(4);
}
String defaultValue = matcher.group(6);
String defaultValue = matcher.group(7);
if (defaultValue == null) {
defaultValue = matcher.group(7);
defaultValue = matcher.group(8);
}

String value = null;
@@ -60,6 +60,18 @@ public String interpolate(String str) {
value = defaultValue;
}

// If the variable is prefixed with only whitespaces, we need to prefix all lines in
// the value with the same whitespaces to keep the indentation.
String prefixWhitespaces = matcher.group(1);
if (prefixWhitespaces != null) {
String[] lines = value.split("\r\n|\r|\n");
StringBuilder sb = new StringBuilder();
for (String line : lines) {
sb.append(prefixWhitespaces).append(line).append(System.lineSeparator());
}
value = sb.toString();
}

Pattern subexpr = Pattern.compile(Pattern.quote(matcher.group(0)));
str = subexpr.matcher(str).replaceAll(value);
}
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@ class InterpolatorTest {
@Test
void interpolateWithFile() {
assertEquals("hello world", new Interpolator().interpolate("hello ${file:" + getClass().getClassLoader().getResource("test").getPath() + "}"));
assertEquals("hello\nworld", new Interpolator().interpolate("${file:" + getClass().getClassLoader().getResource("test.multiline").getPath() + "}"));
assertEquals(" hello\n world\n", new Interpolator().interpolate(" ${file:" + getClass().getClassLoader().getResource("test.multiline").getPath() + "}"));
}

@Test
2 changes: 2 additions & 0 deletions src/test/resources/test.multiline
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello
world