Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
id: tests
run: ./mvnw -U -B -ntp verify

- name: Verify external BOM consumption
run: bash scripts/verify-bom-consumer.sh

- name: Print failing test reports
if: failure() && steps.tests.outcome == 'failure'
shell: bash
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ jobs:
|| { echo "Tag $GITHUB_REF_NAME does not match Maven version $PROJECT_VERSION." >&2; exit 1; }
echo "value=$PROJECT_VERSION" >> "$GITHUB_OUTPUT"

- name: Verify external BOM consumption
run: bash scripts/verify-bom-consumer.sh

- name: Verify and publish the exact release reactor
env:
PLATFORM_ACCEPTANCE_WORK_DIRECTORY: ${{ runner.temp }}/featureframework-platform-acceptance
Expand Down
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten.plugin.version}</version>
<configuration><flattenMode>resolveCiFriendliesOnly</flattenMode></configuration>
<configuration>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<updatePomFile>true</updatePomFile>
</configuration>
<executions>
<execution><id>flatten</id><phase>process-resources</phase><goals><goal>flatten</goal></goals></execution>
<execution><id>flatten-clean</id><phase>clean</phase><goals><goal>clean</goal></goals></execution>
Expand Down
96 changes: 96 additions & 0 deletions scripts/verify-bom-consumer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
set -euo pipefail

repository_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repository_root"

version="$(
./mvnw -q -ntp -DforceStdout help:evaluate -Dexpression=project.version \
| awk '/^[0-9]+\.[0-9]+\.[0-9]+$/ { print; exit }'
)"
if [[ -z "$version" ]]; then
echo "Unable to resolve the FeatureFramework project version." >&2
exit 1
fi

local_repository="$(mktemp -d)"
consumer_directory="$(mktemp -d)"
cleanup() {
rm -rf "$local_repository" "$consumer_directory"
}
trap cleanup EXIT

./mvnw -B -ntp \
-pl featureframework-bom -am \
-DskipTests \
-Dmaven.repo.local="$local_repository" \
install

parent_pom="$local_repository/nl/hauntedmc/featureframework/featureframework-parent/$version/featureframework-parent-$version.pom"
bom_pom="$local_repository/nl/hauntedmc/featureframework/featureframework-bom/$version/featureframework-bom-$version.pom"

for installed_pom in "$parent_pom" "$bom_pom"; do
if [[ ! -f "$installed_pom" ]]; then
echo "Expected installed consumer POM was not created: $installed_pom" >&2
exit 1
fi
if grep -Fq "\${revision}" "$installed_pom"; then
echo "Installed consumer POM still contains an unresolved \${revision}: $installed_pom" >&2
exit 1
fi
done

cat >"$consumer_directory/pom.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nl.hauntedmc.featureframework.acceptance</groupId>
<artifactId>bom-consumer</artifactId>
<version>1.0.0</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>nl.hauntedmc.featureframework</groupId>
<artifactId>featureframework-bom</artifactId>
<version>$version</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>nl.hauntedmc.featureframework</groupId>
<artifactId>featureframework-theme-api</artifactId>
</dependency>
</dependencies>
</project>
EOF

effective_pom="$consumer_directory/effective-pom.xml"
./mvnw -B -ntp \
-f "$consumer_directory/pom.xml" \
-Dmaven.repo.local="$local_repository" \
help:effective-pom \
-Doutput="$effective_pom"

if ! awk -v expected="$version" '
/<artifactId>featureframework-theme-api<\/artifactId>/ { candidate = 1; next }
candidate && /<version>/ {
value = $0
sub(/^.*<version>/, "", value)
sub(/<\/version>.*$/, "", value)
if (value == expected) {
found = 1
}
candidate = 0
}
END { exit found ? 0 : 1 }
' "$effective_pom"; then
echo "External BOM consumer did not receive featureframework-theme-api:$version from dependency management." >&2
exit 1
fi

echo "Verified external consumption of featureframework-bom:$version."