BlueGit

timfa minecart-trains

Merge branch 'feature/auto-release-tests'

timfa Grok Bot · pushed by timfa

Authored 2026-11-17 · 8 hours ago

Hash
267f7a07d3e8d8c98f22ab42577505e3115300b9
Pipeline
Passed
6 files changed +121 −30
.gitlab-ci.yml +9 −0
@@ -1,3 +1,4 @@
1 # GitLab-backup: test draait eerst; daarna de bestaande tag-release.
1 2 # Release pipeline: runs when a version tag is created (e.g. v1.5.0 or 1.5.0).
2 3 #
3 4 # Required CI/CD variable:
@@ -24,12 +25,19 @@ variables:
24 25 JAR_NAME: "MinecartTrains-${VERSION}.jar"
25 26
26 27 stages:
28 - test
27 29 - validate
28 30 - bump
29 31 - build
30 32 - release
31 33 - rotate
32 34
35 test:
36 stage: test
37 image: maven:3.9.11-eclipse-temurin-25
38 script:
39 - mvn -B test
40
33 41 .validate_image:
34 42 image: alpine:3.20
35 43 before_script:
@@ -40,6 +48,7 @@ stages:
40 48 validate:version:
41 49 extends: .validate_image
42 50 stage: validate
51 needs: [test]
43 52 script:
44 53 - ./scripts/release.sh validate
45 54 artifacts:
@@ -1,3 +1,4 @@
1# GitLab-backup: test draait eerst; daarna de bestaande tag-release.
1# Release pipeline: runs when a version tag is created (e.g. v1.5.0 or 1.5.0).
2# Release pipeline: runs when a version tag is created (e.g. v1.5.0 or 1.5.0).
2#
3#
3# Required CI/CD variable:
4# Required CI/CD variable:
@@ -24,12 +25,19 @@ variables:
24 JAR_NAME: "MinecartTrains-${VERSION}.jar"
25 JAR_NAME: "MinecartTrains-${VERSION}.jar"
25
26
26stages:
27stages:
28 - test
27 - validate
29 - validate
28 - bump
30 - bump
29 - build
31 - build
30 - release
32 - release
31 - rotate
33 - rotate
32
34
35test:
36 stage: test
37 image: maven:3.9.11-eclipse-temurin-25
38 script:
39 - mvn -B test
40
33.validate_image:
41.validate_image:
34 image: alpine:3.20
42 image: alpine:3.20
35 before_script:
43 before_script:
@@ -40,6 +48,7 @@ stages:
40validate:version:
48validate:version:
41 extends: .validate_image
49 extends: .validate_image
42 stage: validate
50 stage: validate
51 needs: [test]
43 script:
52 script:
44 - ./scripts/release.sh validate
53 - ./scripts/release.sh validate
45 artifacts:
54 artifacts:
blue-ci-cd.yml +18 −17
@@ -1,31 +1,34 @@
1 # BlueGit CI (vertaald uit .gitlab-ci.yml; GitLab is alleen nog backup).
1 # BlueGit CI.
2 2 #
3 # Op GitLab startte een nieuwe tag de release (validate, bump-commit terug naar
4 # master met CI_PUSH_TOKEN, build, GitLab-release, token roteren). Op BlueGit
5 # maakt de release-API de tag zelf, dus:
6 # master-push: version (hoogste tag + 1 patch, tag met v-prefix, of RELEASE_VERSION) en build.
7 # release: HANDMATIG (zoals op GitLab een bewuste tag), maakt tag + release
8 # met de jar. Nooit automatisch, nooit dubbel.
9 # De versie wordt alleen in de build gezet (zelfde bump als scripts/release.sh),
10 # er wordt geen bump-commit teruggepusht; CI_PUSH_TOKEN is niet meer nodig.
11 # Tag-pushes starten geen pipeline.
3 # master-push: test + build (geen release-job, zodat de pipeline op success
4 # eindigt in plaats van manual).
5 # tag-push: test + build, daarna automatisch release (geen manual-stap).
6 # De release-API voor bestaande tags maakt de tag niet aan of verplaatst die
7 # niet; de assets komen uit dezelfde pipeline. Een leidende v op de tag wordt
8 # in de versie en bestandsnaam gestript.
12 9
13 10 workflow:
14 11 rules:
15 12 - if: $CI_COMMIT_TAG != ""
16 when: never
17 - if: $CI_COMMIT_BRANCH == "master"
13 - if: $CI_COMMIT_BRANCH != ""
18 14 - if: $CI_PIPELINE_SOURCE == "web"
19 15 - if: $CI_PIPELINE_SOURCE == "api"
20 16
21 17 variables:
22 18 MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
23 19
24 stages: [build, release]
20 stages: [test, build, release]
21
22 test:
23 stage: test
24 image: maven:3.9.11-eclipse-temurin-25
25 script:
26 - mvn -B test
25 27
26 28 build:artifacts:
27 29 stage: build
28 30 image: maven:3.9.11-eclipse-temurin-25
31 needs: [test]
29 32 script:
30 33 - bash scripts/ci/build.sh
31 34 artifacts:
@@ -35,11 +38,9 @@ build:artifacts:
35 38 release:
36 39 stage: release
37 40 image: bluegit/base
38 needs: [build:artifacts]
39 when: manual
41 needs: [test, build:artifacts]
40 42 resource_group: release
41 43 rules:
42 - if: $CI_COMMIT_BRANCH == "master"
43 when: manual
44 - if: $CI_COMMIT_TAG != ""
44 45 script:
45 46 - bash scripts/ci/bluegit-release.sh
@@ -1,31 +1,34 @@
1# BlueGit CI (vertaald uit .gitlab-ci.yml; GitLab is alleen nog backup).
1# BlueGit CI.
2#
2#
3# Op GitLab startte een nieuwe tag de release (validate, bump-commit terug naar
3# master-push: test + build (geen release-job, zodat de pipeline op success
4# master met CI_PUSH_TOKEN, build, GitLab-release, token roteren). Op BlueGit
4# eindigt in plaats van manual).
5# maakt de release-API de tag zelf, dus:
5# tag-push: test + build, daarna automatisch release (geen manual-stap).
6# master-push: version (hoogste tag + 1 patch, tag met v-prefix, of RELEASE_VERSION) en build.
6# De release-API voor bestaande tags maakt de tag niet aan of verplaatst die
7# release: HANDMATIG (zoals op GitLab een bewuste tag), maakt tag + release
7# niet; de assets komen uit dezelfde pipeline. Een leidende v op de tag wordt
8# met de jar. Nooit automatisch, nooit dubbel.
8# in de versie en bestandsnaam gestript.
9# De versie wordt alleen in de build gezet (zelfde bump als scripts/release.sh),
10# er wordt geen bump-commit teruggepusht; CI_PUSH_TOKEN is niet meer nodig.
11# Tag-pushes starten geen pipeline.
12
9
13workflow:
10workflow:
14 rules:
11 rules:
15 - if: $CI_COMMIT_TAG != ""
12 - if: $CI_COMMIT_TAG != ""
16 when: never
13 - if: $CI_COMMIT_BRANCH != ""
17 - if: $CI_COMMIT_BRANCH == "master"
18 - if: $CI_PIPELINE_SOURCE == "web"
14 - if: $CI_PIPELINE_SOURCE == "web"
19 - if: $CI_PIPELINE_SOURCE == "api"
15 - if: $CI_PIPELINE_SOURCE == "api"
20
16
21variables:
17variables:
22 MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
18 MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
23
19
24stages: [build, release]
20stages: [test, build, release]
21
22test:
23 stage: test
24 image: maven:3.9.11-eclipse-temurin-25
25 script:
26 - mvn -B test
25
27
26build:artifacts:
28build:artifacts:
27 stage: build
29 stage: build
28 image: maven:3.9.11-eclipse-temurin-25
30 image: maven:3.9.11-eclipse-temurin-25
31 needs: [test]
29 script:
32 script:
30 - bash scripts/ci/build.sh
33 - bash scripts/ci/build.sh
31 artifacts:
34 artifacts:
@@ -35,11 +38,9 @@ build:artifacts:
35release:
38release:
36 stage: release
39 stage: release
37 image: bluegit/base
40 image: bluegit/base
38 needs: [build:artifacts]
41 needs: [test, build:artifacts]
39 when: manual
40 resource_group: release
42 resource_group: release
41 rules:
43 rules:
42 - if: $CI_COMMIT_BRANCH == "master"
44 - if: $CI_COMMIT_TAG != ""
43 when: manual
44 script:
45 script:
45 - bash scripts/ci/bluegit-release.sh
46 - bash scripts/ci/bluegit-release.sh
pom.xml +17 −0
@@ -21,6 +21,11 @@
21 21 <build>
22 22 <finalName>${project.name}-${project.version}</finalName>
23 23 <plugins>
24 <plugin>
25 <groupId>org.apache.maven.plugins</groupId>
26 <artifactId>maven-surefire-plugin</artifactId>
27 <version>3.5.2</version>
28 </plugin>
24 29 <plugin>
25 30 <groupId>org.apache.maven.plugins</groupId>
26 31 <artifactId>maven-compiler-plugin</artifactId>
@@ -80,5 +85,17 @@
80 85 <version>3.1.0</version>
81 86 <scope>compile</scope>
82 87 </dependency>
88 <dependency>
89 <groupId>org.junit.jupiter</groupId>
90 <artifactId>junit-jupiter</artifactId>
91 <version>5.11.4</version>
92 <scope>test</scope>
93 </dependency>
94 <dependency>
95 <groupId>org.yaml</groupId>
96 <artifactId>snakeyaml</artifactId>
97 <version>2.4</version>
98 <scope>test</scope>
99 </dependency>
83 100 </dependencies>
84 101 </project>
@@ -21,6 +21,11 @@
21 <build>
21 <build>
22 <finalName>${project.name}-${project.version}</finalName>
22 <finalName>${project.name}-${project.version}</finalName>
23 <plugins>
23 <plugins>
24 <plugin>
25 <groupId>org.apache.maven.plugins</groupId>
26 <artifactId>maven-surefire-plugin</artifactId>
27 <version>3.5.2</version>
28 </plugin>
24 <plugin>
29 <plugin>
25 <groupId>org.apache.maven.plugins</groupId>
30 <groupId>org.apache.maven.plugins</groupId>
26 <artifactId>maven-compiler-plugin</artifactId>
31 <artifactId>maven-compiler-plugin</artifactId>
@@ -80,5 +85,17 @@
80 <version>3.1.0</version>
85 <version>3.1.0</version>
81 <scope>compile</scope>
86 <scope>compile</scope>
82 </dependency>
87 </dependency>
88 <dependency>
89 <groupId>org.junit.jupiter</groupId>
90 <artifactId>junit-jupiter</artifactId>
91 <version>5.11.4</version>
92 <scope>test</scope>
93 </dependency>
94 <dependency>
95 <groupId>org.yaml</groupId>
96 <artifactId>snakeyaml</artifactId>
97 <version>2.4</version>
98 <scope>test</scope>
99 </dependency>
83 </dependencies>
100 </dependencies>
84</project>
101</project>
scripts/ci/bluegit-release.sh +19 −10
@@ -1,15 +1,24 @@
1 1 #!/usr/bin/env bash
2 # BlueGit: release maken met de jar als asset.
3 # De release-API maakt de tag zelf aan en weigert een bestaande tag, dus een
4 # release kan nooit twee keer ontstaan. Overslaan als HEAD al een tag heeft.
2 # BlueGit: publicatie van een bestaande tag (de tag is al gepusht).
3 # POST .../releases/$TAG/assets maakt de release met de build-assets en
4 # wijzigt de tag niet. Alleen job-token, alleen in de tag-pipeline.
5 5 set -euo pipefail
6 : "${CI_API_URL:?}" "${CI_JOB_TOKEN:?}" "${CI_COMMIT_SHA:?}" "${CI_PROJECT_PATH:?}"
7 v="$(cat build/version.txt)"; t="v$v"
8 git fetch -q --tags origin 2>/dev/null || true
9 if [[ -n "$(git tag --points-at HEAD)" ]]; then echo "Geen release: HEAD heeft al een tag."; exit 0; fi
10 if git rev-parse -q --verify "refs/tags/$t" >/dev/null; then echo "Tag $t bestaat al" >&2; exit 1; fi
11 body="$(printf '{"tag":"%s","commit":"%s","name":"Minecart Trains %s","body":"Release %s of Minecart Trains.","assets":[{"job":"build:artifacts","path":"build/out/MinecartTrains.jar","name":"MinecartTrains-%s.jar"}]}' "$t" "$CI_COMMIT_SHA" "$v" "$v" "$v")"
6 : "${CI_API_URL:?}" "${CI_JOB_TOKEN:?}" "${CI_COMMIT_SHA:?}" "${CI_PROJECT_PATH:?}" "${CI_COMMIT_TAG:?}"
7 v="${CI_COMMIT_TAG#v}"
8 [[ -f "build/out/MinecartTrains.jar" ]] || { echo "ontbreekt: build/out/MinecartTrains.jar" >&2; ls -la build/out >&2 || true; exit 1; }
9
10 body="$(python3 -c 'import json,sys; print(json.dumps({
11 "commit": sys.argv[1],
12 "name": "Minecart Trains "+sys.argv[2],
13 "body": "Release "+sys.argv[2]+" of Minecart Trains.",
14 "assets": [{"job": "build:artifacts", "path": sys.argv[3], "name": sys.argv[4]}],
15 }))' "$CI_COMMIT_SHA" "$v" "build/out/MinecartTrains.jar" "MinecartTrains-${v}.jar")"
16
12 17 resp="$(mktemp)"
13 code="$(curl -sS -o "$resp" -w '%{http_code}' -X POST "$CI_API_URL/repos/$CI_PROJECT_PATH/releases" -H "Authorization: Bearer $CI_JOB_TOKEN" -H "Content-Type: application/json" -d "$body")" || code=000
18 code="$(curl -sS -o "$resp" -w '%{http_code}' -X POST \
19 "$CI_API_URL/repos/$CI_PROJECT_PATH/releases/${CI_COMMIT_TAG}/assets" \
20 -H "Authorization: Bearer $CI_JOB_TOKEN" \
21 -H "Content-Type: application/json" \
22 --data-binary "$body")" || code=000
14 23 cat "$resp"; echo
15 24 [[ "$code" == 2* ]] || { echo "Release-API gaf HTTP $code" >&2; exit 1; }
@@ -1,15 +1,24 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2# BlueGit: release maken met de jar als asset.
2# BlueGit: publicatie van een bestaande tag (de tag is al gepusht).
3# De release-API maakt de tag zelf aan en weigert een bestaande tag, dus een
3# POST .../releases/$TAG/assets maakt de release met de build-assets en
4# release kan nooit twee keer ontstaan. Overslaan als HEAD al een tag heeft.
4# wijzigt de tag niet. Alleen job-token, alleen in de tag-pipeline.
5set -euo pipefail
5set -euo pipefail
6: "${CI_API_URL:?}" "${CI_JOB_TOKEN:?}" "${CI_COMMIT_SHA:?}" "${CI_PROJECT_PATH:?}"
6: "${CI_API_URL:?}" "${CI_JOB_TOKEN:?}" "${CI_COMMIT_SHA:?}" "${CI_PROJECT_PATH:?}" "${CI_COMMIT_TAG:?}"
7v="$(cat build/version.txt)"; t="v$v"
7v="${CI_COMMIT_TAG#v}"
8git fetch -q --tags origin 2>/dev/null || true
8[[ -f "build/out/MinecartTrains.jar" ]] || { echo "ontbreekt: build/out/MinecartTrains.jar" >&2; ls -la build/out >&2 || true; exit 1; }
9if [[ -n "$(git tag --points-at HEAD)" ]]; then echo "Geen release: HEAD heeft al een tag."; exit 0; fi
9
10if git rev-parse -q --verify "refs/tags/$t" >/dev/null; then echo "Tag $t bestaat al" >&2; exit 1; fi
10body="$(python3 -c 'import json,sys; print(json.dumps({
11body="$(printf '{"tag":"%s","commit":"%s","name":"Minecart Trains %s","body":"Release %s of Minecart Trains.","assets":[{"job":"build:artifacts","path":"build/out/MinecartTrains.jar","name":"MinecartTrains-%s.jar"}]}' "$t" "$CI_COMMIT_SHA" "$v" "$v" "$v")"
11 "commit": sys.argv[1],
12 "name": "Minecart Trains "+sys.argv[2],
13 "body": "Release "+sys.argv[2]+" of Minecart Trains.",
14 "assets": [{"job": "build:artifacts", "path": sys.argv[3], "name": sys.argv[4]}],
15}))' "$CI_COMMIT_SHA" "$v" "build/out/MinecartTrains.jar" "MinecartTrains-${v}.jar")"
16
12resp="$(mktemp)"
17resp="$(mktemp)"
13code="$(curl -sS -o "$resp" -w '%{http_code}' -X POST "$CI_API_URL/repos/$CI_PROJECT_PATH/releases" -H "Authorization: Bearer $CI_JOB_TOKEN" -H "Content-Type: application/json" -d "$body")" || code=000
18code="$(curl -sS -o "$resp" -w '%{http_code}' -X POST \
19 "$CI_API_URL/repos/$CI_PROJECT_PATH/releases/${CI_COMMIT_TAG}/assets" \
20 -H "Authorization: Bearer $CI_JOB_TOKEN" \
21 -H "Content-Type: application/json" \
22 --data-binary "$body")" || code=000
14cat "$resp"; echo
23cat "$resp"; echo
15[[ "$code" == 2* ]] || { echo "Release-API gaf HTTP $code" >&2; exit 1; }
24[[ "$code" == 2* ]] || { echo "Release-API gaf HTTP $code" >&2; exit 1; }
scripts/ci/build.sh +5 −3
@@ -1,9 +1,11 @@
1 1 #!/usr/bin/env bash
2 # Versie bepalen (hoogste tag + 1 patch of RELEASE_VERSION), zelfde bump als
2 # Versie bepalen (tag, RELEASE_VERSION, of hoogste tag + 1 patch), zelfde bump als
3 3 # scripts/release.sh (alleen pom.xml, lokaal in de build, geen commit), jar bouwen.
4 4 set -euo pipefail
5 if [ -n "${RELEASE_VERSION:-}" ]; then v="${RELEASE_VERSION#v}"; else
6 last="$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V | tail -n1)"
5 if [ -n "${RELEASE_VERSION:-}" ]; then v="${RELEASE_VERSION#v}"
6 elif [ -n "${CI_COMMIT_TAG:-}" ]; then v="${CI_COMMIT_TAG#v}"
7 else
8 last="$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V | tail -n1 || true)"
7 9 IFS=. read -r a b c <<<"${last:-0.0.0}"; v="$a.$b.$((c+1))"
8 10 fi
9 11 echo "Versie voor deze build: $v"
@@ -1,9 +1,11 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2# Versie bepalen (hoogste tag + 1 patch of RELEASE_VERSION), zelfde bump als
2# Versie bepalen (tag, RELEASE_VERSION, of hoogste tag + 1 patch), zelfde bump als
3# scripts/release.sh (alleen pom.xml, lokaal in de build, geen commit), jar bouwen.
3# scripts/release.sh (alleen pom.xml, lokaal in de build, geen commit), jar bouwen.
4set -euo pipefail
4set -euo pipefail
5if [ -n "${RELEASE_VERSION:-}" ]; then v="${RELEASE_VERSION#v}"; else
5if [ -n "${RELEASE_VERSION:-}" ]; then v="${RELEASE_VERSION#v}"
6 last="$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V | tail -n1)"
6elif [ -n "${CI_COMMIT_TAG:-}" ]; then v="${CI_COMMIT_TAG#v}"
7else
8 last="$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V | tail -n1 || true)"
7 IFS=. read -r a b c <<<"${last:-0.0.0}"; v="$a.$b.$((c+1))"
9 IFS=. read -r a b c <<<"${last:-0.0.0}"; v="$a.$b.$((c+1))"
8fi
10fi
9echo "Versie voor deze build: $v"
11echo "Versie voor deze build: $v"
src/test/java/me/fridtjof/minecarttrains/PluginConfigTest.java added +53 −0
@@ -0,0 +1,53 @@
1 package me.fridtjof.minecarttrains;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.nio.charset.StandardCharsets;
6 import java.nio.file.Files;
7 import java.nio.file.Path;
8 import java.util.Map;
9 import java.util.regex.Matcher;
10 import java.util.regex.Pattern;
11
12 import org.junit.jupiter.api.Test;
13 import org.yaml.snakeyaml.Yaml;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import static org.junit.jupiter.api.Assertions.assertNotNull;
17 import static org.junit.jupiter.api.Assertions.assertTrue;
18
19 class PluginConfigTest {
20
21 @Test
22 void pluginYmlDeclaresPaper26AndMainClass() throws IOException {
23 Map<String, Object> yaml = loadYaml("plugin.yml");
24 assertEquals("MinecartTrains", yaml.get("name"));
25 assertEquals("me.fridtjof.minecarttrains.MinecartTrains", yaml.get("main"));
26 assertEquals("26.2", String.valueOf(yaml.get("api-version")));
27 String version = String.valueOf(yaml.get("version"));
28 assertTrue(
29 version.equals("${project.version}") || version.equals(pomVersion()),
30 "unexpected version: " + version);
31 }
32
33 @Test
34 void pomVersionIsSemver() throws IOException {
35 assertTrue(pomVersion().matches("\\d+\\.\\d+\\.\\d+"), pomVersion());
36 }
37
38 private static Map<String, Object> loadYaml(String name) throws IOException {
39 try (InputStream in = PluginConfigTest.class.getClassLoader().getResourceAsStream(name)) {
40 assertNotNull(in, name);
41 return new Yaml().load(in);
42 }
43 }
44
45 private static String pomVersion() throws IOException {
46 String pom = Files.readString(Path.of("pom.xml"), StandardCharsets.UTF_8);
47 Matcher m = Pattern.compile(
48 "<artifactId>minecarttrains</artifactId>\\s*<version>([^<]+)</version>",
49 Pattern.DOTALL).matcher(pom);
50 if (!m.find()) throw new IOException("project version in pom.xml");
51 return m.group(1);
52 }
53 }
@@ -0,0 +1,53 @@
1package me.fridtjof.minecarttrains;
2
3import java.io.IOException;
4import java.io.InputStream;
5import java.nio.charset.StandardCharsets;
6import java.nio.file.Files;
7import java.nio.file.Path;
8import java.util.Map;
9import java.util.regex.Matcher;
10import java.util.regex.Pattern;
11
12import org.junit.jupiter.api.Test;
13import org.yaml.snakeyaml.Yaml;
14
15import static org.junit.jupiter.api.Assertions.assertEquals;
16import static org.junit.jupiter.api.Assertions.assertNotNull;
17import static org.junit.jupiter.api.Assertions.assertTrue;
18
19class PluginConfigTest {
20
21 @Test
22 void pluginYmlDeclaresPaper26AndMainClass() throws IOException {
23 Map<String, Object> yaml = loadYaml("plugin.yml");
24 assertEquals("MinecartTrains", yaml.get("name"));
25 assertEquals("me.fridtjof.minecarttrains.MinecartTrains", yaml.get("main"));
26 assertEquals("26.2", String.valueOf(yaml.get("api-version")));
27 String version = String.valueOf(yaml.get("version"));
28 assertTrue(
29 version.equals("${project.version}") || version.equals(pomVersion()),
30 "unexpected version: " + version);
31 }
32
33 @Test
34 void pomVersionIsSemver() throws IOException {
35 assertTrue(pomVersion().matches("\\d+\\.\\d+\\.\\d+"), pomVersion());
36 }
37
38 private static Map<String, Object> loadYaml(String name) throws IOException {
39 try (InputStream in = PluginConfigTest.class.getClassLoader().getResourceAsStream(name)) {
40 assertNotNull(in, name);
41 return new Yaml().load(in);
42 }
43 }
44
45 private static String pomVersion() throws IOException {
46 String pom = Files.readString(Path.of("pom.xml"), StandardCharsets.UTF_8);
47 Matcher m = Pattern.compile(
48 "<artifactId>minecarttrains</artifactId>\\s*<version>([^<]+)</version>",
49 Pattern.DOTALL).matcher(pom);
50 if (!m.find()) throw new IOException("project version in pom.xml");
51 return m.group(1);
52 }
53}