From b74bdba2123ac4eaadf2654d52a3b6e05647d1b2 Mon Sep 17 00:00:00 2001 From: Matthias Linhuber Date: Tue, 25 Aug 2026 18:56:08 +0200 Subject: [PATCH] build: parameterise the version with Maven CI-friendly versions The version was hardcoded as 1.2.0-SNAPSHOT in six poms and three Dockerfiles, in COPY paths and entrypoint scripts. A release meant editing nine files, which is why the tag 1.1.0 and the source version had drifted apart entirely. Now one flag: mvn -Drevision=2.3.0, or --build-arg APP_VERSION=2.3.0. The default in the parent pom keeps plain mvn install working unchanged, and CI passes the derived release tag automatically. Each image also copies its jar to a stable name, so the version never reaches runtime. That is not cosmetic: the operator and service entrypoints are written by a RUN heredoc with a quoted delimiter, so ${APP_VERSION} would be written literally and expand to empty at container start, and the conversion-webhook ENTRYPOINT is JSON exec form where Docker never expands variables at all. Verified by building, not by reading: docker build with APP_VERSION=9.9.9-test produces a jar reporting Implementation-Version: 9.9.9-test, and a default build still succeeds. That test found three bugs. flatten-maven-plugin was missing, so the installed pom kept the literal ${revision} and the next module could not resolve its parent - I had wrongly assumed it was unnecessary because nothing is published to a Maven repo. mvn clean package never received -Drevision. And ARG is per stage, so removing it from the runtime stage broke the COPY --from=builder source path. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_019qeiQRFu8xAMRYWPdZewjG --- .github/workflows/build.yml | 4 ++ .gitignore | 1 + dockerfiles/conversion-webhook/Dockerfile | 12 +++--- dockerfiles/operator/Dockerfile | 14 ++++--- dockerfiles/service/Dockerfile | 12 +++--- java/common/maven-conf/pom.xml | 37 ++++++++++++++++++- .../org.eclipse.theia.cloud.common/pom.xml | 2 +- .../pom.xml | 4 +- .../pom.xml | 6 +-- .../org.eclipse.theia.cloud.operator/pom.xml | 4 +- .../org.eclipse.theia.cloud.service/pom.xml | 4 +- 11 files changed, 73 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df4572ae6..0b083d887 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,10 @@ jobs: image-name: eduide/eduide-cloud/${{ matrix.component }} docker-context: . image-tag: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event_name == 'workflow_dispatch' && inputs.image_tag || '' }} + # The Java build stamps the version into the jar manifest, so the version + # inside the image should match the tag on the outside. The shared workflow + # derives the tag (stripping any leading v) and passes it as APP_VERSION. + stamp-app-version: true no-cache: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.disable_layer_cache) || false }} # These are small Java images; the disk-reclaim step is not worth the time. free-disk-space: false diff --git a/.gitignore b/.gitignore index 0cab4cd17..30413fb30 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ openapitools.json target/ node_modules node/e2e-tests/test-results/.last-run.json +.flattened-pom.xml diff --git a/dockerfiles/conversion-webhook/Dockerfile b/dockerfiles/conversion-webhook/Dockerfile index 6a2fcebee..dbf41a291 100644 --- a/dockerfiles/conversion-webhook/Dockerfile +++ b/dockerfiles/conversion-webhook/Dockerfile @@ -1,4 +1,5 @@ FROM eclipse-temurin:21-jdk AS builder +ARG APP_VERSION=1.2.0-SNAPSHOT # Accept APT_HTTP_PROXY build-arg for caching ARG APT_HTTP_PROXY # Configure apt proxy if provided (hybrid: works on ARC and GitHub runners) @@ -17,17 +18,18 @@ COPY java/common ./common COPY java/conversion ./conversion RUN --mount=type=cache,target=/root/.m2 \ cd /conversion/common/maven-conf && \ - mvn clean install --no-transfer-progress && \ + mvn clean install --no-transfer-progress -Drevision=${APP_VERSION} && \ cd /conversion/common/org.eclipse.theia.cloud.common && \ - mvn clean install --no-transfer-progress && \ + mvn clean install --no-transfer-progress -Drevision=${APP_VERSION} && \ cd /conversion/conversion/org.eclipse.theia.cloud.conversion && \ - mvn clean package -Dmaven.test.skip=true -Dquarkus.package.type=uber-jar --no-transfer-progress + mvn clean package -Drevision=${APP_VERSION} -Dmaven.test.skip=true -Dquarkus.package.type=uber-jar --no-transfer-progress FROM eclipse-temurin:21-jre-alpine +ARG APP_VERSION=1.2.0-SNAPSHOT WORKDIR /conversion -COPY --from=builder /conversion/conversion/org.eclipse.theia.cloud.conversion/target/conversion-webhook-1.2.0-SNAPSHOT-runner.jar . +COPY --from=builder /conversion/conversion/org.eclipse.theia.cloud.conversion/target/conversion-webhook-${APP_VERSION}-runner.jar ./conversion-webhook.jar ENV CERT_RELOAD_PERIOD=604800 -ENTRYPOINT ["java", "-Dquarkus.http.ssl.certificate.reload-period=${CERT_RELOAD_PERIOD}", "-jar", "./conversion-webhook-1.2.0-SNAPSHOT-runner.jar"] +ENTRYPOINT ["java", "-Dquarkus.http.ssl.certificate.reload-period=${CERT_RELOAD_PERIOD}", "-jar", "./conversion-webhook.jar"] CMD [ "" ] diff --git a/dockerfiles/operator/Dockerfile b/dockerfiles/operator/Dockerfile index 5190e4a3f..6a18c366d 100644 --- a/dockerfiles/operator/Dockerfile +++ b/dockerfiles/operator/Dockerfile @@ -1,4 +1,5 @@ FROM eclipse-temurin:21-jdk AS builder +ARG APP_VERSION=1.2.0-SNAPSHOT # Accept APT_HTTP_PROXY build-arg for caching ARG APT_HTTP_PROXY # Configure apt proxy if provided (hybrid: works on ARC and GitHub runners) @@ -27,15 +28,16 @@ RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \ echo "No SENTRY_AUTH_TOKEN provided, skipping Sentry build integration"; \ fi && \ cd /operator/common/maven-conf && \ - mvn clean install --no-transfer-progress $MAVEN_SENTRY_ARGS && \ + mvn clean install --no-transfer-progress -Drevision=${APP_VERSION} $MAVEN_SENTRY_ARGS && \ cd /operator/common/org.eclipse.theia.cloud.common && \ - mvn clean install --no-transfer-progress $MAVEN_SENTRY_ARGS && \ + mvn clean install --no-transfer-progress -Drevision=${APP_VERSION} $MAVEN_SENTRY_ARGS && \ cd /operator/operator/org.eclipse.theia.cloud.operator && \ - mvn clean install --no-transfer-progress $MAVEN_SENTRY_ARGS && \ + mvn clean install --no-transfer-progress -Drevision=${APP_VERSION} $MAVEN_SENTRY_ARGS && \ cd /operator/operator/org.eclipse.theia.cloud.defaultoperator && \ - mvn clean verify --no-transfer-progress $MAVEN_SENTRY_ARGS + mvn clean verify --no-transfer-progress -Drevision=${APP_VERSION} $MAVEN_SENTRY_ARGS FROM eclipse-temurin:21-jre-alpine +ARG APP_VERSION=1.2.0-SNAPSHOT RUN apk add --no-cache curl unzip RUN mkdir /templates WORKDIR /log-config @@ -44,7 +46,7 @@ WORKDIR /operator RUN curl -fsSL -o sentry-agent.zip https://github.com/getsentry/sentry-java/releases/download/8.29.0/sentry-opentelemetry-agent-8.29.0.zip && \ unzip -j sentry-agent.zip -d . && \ rm sentry-agent.zip -COPY --from=builder /operator/operator/org.eclipse.theia.cloud.defaultoperator/target/defaultoperator-1.2.0-SNAPSHOT-jar-with-dependencies.jar . +COPY --from=builder /operator/operator/org.eclipse.theia.cloud.defaultoperator/target/defaultoperator-${APP_VERSION}-jar-with-dependencies.jar ./operator.jar COPY --from=builder /operator/operator/org.eclipse.theia.cloud.defaultoperator/sentry.properties ./sentry.properties # If set to true, enables Sentry Java agent flags. @@ -67,7 +69,7 @@ fi exec java $JAVA_OPTS \ -Dlog4j2.configurationFile=/log-config/log4j2.xml \ - -jar ./defaultoperator-1.2.0-SNAPSHOT-jar-with-dependencies.jar \ + -jar ./operator.jar \ "$@" EOF_ENTRYPOINT diff --git a/dockerfiles/service/Dockerfile b/dockerfiles/service/Dockerfile index b4530792d..481da2efd 100644 --- a/dockerfiles/service/Dockerfile +++ b/dockerfiles/service/Dockerfile @@ -1,4 +1,5 @@ FROM eclipse-temurin:21-jdk AS builder +ARG APP_VERSION=1.2.0-SNAPSHOT # Accept APT_HTTP_PROXY build-arg for caching ARG APT_HTTP_PROXY # Configure apt proxy if provided (hybrid: works on ARC and GitHub runners) @@ -27,19 +28,20 @@ RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \ echo "No SENTRY_AUTH_TOKEN provided, skipping Sentry build integration"; \ fi && \ cd /service/common/maven-conf && \ - mvn clean install --no-transfer-progress $MAVEN_SENTRY_ARGS && \ + mvn clean install --no-transfer-progress -Drevision=${APP_VERSION} $MAVEN_SENTRY_ARGS && \ cd /service/common/org.eclipse.theia.cloud.common && \ - mvn clean install --no-transfer-progress $MAVEN_SENTRY_ARGS && \ + mvn clean install --no-transfer-progress -Drevision=${APP_VERSION} $MAVEN_SENTRY_ARGS && \ cd /service/service/org.eclipse.theia.cloud.service && \ - mvn clean package -Dmaven.test.skip=true -Dquarkus.package.type=uber-jar --no-transfer-progress $MAVEN_SENTRY_ARGS + mvn clean package -Drevision=${APP_VERSION} -Dmaven.test.skip=true -Dquarkus.package.type=uber-jar --no-transfer-progress $MAVEN_SENTRY_ARGS FROM eclipse-temurin:21-jre-alpine +ARG APP_VERSION=1.2.0-SNAPSHOT RUN apk add --no-cache curl unzip WORKDIR /service RUN curl -fsSL -o sentry-agent.zip https://github.com/getsentry/sentry-java/releases/download/8.29.0/sentry-opentelemetry-agent-8.29.0.zip && \ unzip -j sentry-agent.zip -d . && \ rm sentry-agent.zip -COPY --from=builder /service/service/org.eclipse.theia.cloud.service/target/service-1.2.0-SNAPSHOT-runner.jar . +COPY --from=builder /service/service/org.eclipse.theia.cloud.service/target/service-${APP_VERSION}-runner.jar ./service.jar COPY --from=builder /service/service/org.eclipse.theia.cloud.service/sentry.properties ./sentry.properties ENV SERVICE_PORT=8081 @@ -84,7 +86,7 @@ exec java $JAVA_OPTS \ -Dquarkus.oidc.auth-server-url="${KEYCLOAK_SERVERURL}" \ -Dquarkus.oidc.client-id="${KEYCLOAK_CLIENTID}" \ -Dquarkus.oidc.credentials.secret="${KEYCLOAK_CLIENTSECRET}" \ - -jar ./service-1.2.0-SNAPSHOT-runner.jar \ + -jar ./service.jar \ "$@" EOF_ENTRYPOINT diff --git a/java/common/maven-conf/pom.xml b/java/common/maven-conf/pom.xml index 8944bcae2..f9d0c217a 100644 --- a/java/common/maven-conf/pom.xml +++ b/java/common/maven-conf/pom.xml @@ -5,12 +5,14 @@ 4.0.0 org.eclipse.theia.cloud conf - 1.2.0-SNAPSHOT + ${revision} pom Theia Cloud Maven Configuration Common properties and configuration + + 1.2.0-SNAPSHOT false UTF-8 UTF-8 @@ -42,6 +44,39 @@ + + + + + org.codehaus.mojo + flatten-maven-plugin + 1.6.0 + + true + resolveCiFriendliesOnly + + + + flatten + process-resources + flatten + + + flatten.clean + clean + clean + + + + + + github diff --git a/java/common/org.eclipse.theia.cloud.common/pom.xml b/java/common/org.eclipse.theia.cloud.common/pom.xml index 3af633dc6..97a74d97d 100644 --- a/java/common/org.eclipse.theia.cloud.common/pom.xml +++ b/java/common/org.eclipse.theia.cloud.common/pom.xml @@ -11,7 +11,7 @@ org.eclipse.theia.cloud conf - 1.2.0-SNAPSHOT + ${revision} ../../common/maven-conf/ diff --git a/java/conversion/org.eclipse.theia.cloud.conversion/pom.xml b/java/conversion/org.eclipse.theia.cloud.conversion/pom.xml index 07d136338..26dea5138 100644 --- a/java/conversion/org.eclipse.theia.cloud.conversion/pom.xml +++ b/java/conversion/org.eclipse.theia.cloud.conversion/pom.xml @@ -9,7 +9,7 @@ org.eclipse.theia.cloud conf - 1.2.0-SNAPSHOT + ${revision} ../../common/maven-conf/ @@ -45,7 +45,7 @@ org.eclipse.theia.cloud common - 1.2.0-SNAPSHOT + ${revision} diff --git a/java/operator/org.eclipse.theia.cloud.defaultoperator/pom.xml b/java/operator/org.eclipse.theia.cloud.defaultoperator/pom.xml index b1ecdece2..0168b2719 100644 --- a/java/operator/org.eclipse.theia.cloud.defaultoperator/pom.xml +++ b/java/operator/org.eclipse.theia.cloud.defaultoperator/pom.xml @@ -11,7 +11,7 @@ org.eclipse.theia.cloud conf - 1.2.0-SNAPSHOT + ${revision} ../../common/maven-conf/ @@ -19,12 +19,12 @@ org.eclipse.theia.cloud operator - 1.2.0-SNAPSHOT + ${revision} org.eclipse.theia.cloud common - 1.2.0-SNAPSHOT + ${revision} org.json diff --git a/java/operator/org.eclipse.theia.cloud.operator/pom.xml b/java/operator/org.eclipse.theia.cloud.operator/pom.xml index c49a34589..d575434b3 100644 --- a/java/operator/org.eclipse.theia.cloud.operator/pom.xml +++ b/java/operator/org.eclipse.theia.cloud.operator/pom.xml @@ -11,7 +11,7 @@ org.eclipse.theia.cloud conf - 1.2.0-SNAPSHOT + ${revision} ../../common/maven-conf/ @@ -19,7 +19,7 @@ org.eclipse.theia.cloud common - 1.2.0-SNAPSHOT + ${revision} org.json diff --git a/java/service/org.eclipse.theia.cloud.service/pom.xml b/java/service/org.eclipse.theia.cloud.service/pom.xml index ff4d31ffe..7ab94ff50 100644 --- a/java/service/org.eclipse.theia.cloud.service/pom.xml +++ b/java/service/org.eclipse.theia.cloud.service/pom.xml @@ -9,7 +9,7 @@ org.eclipse.theia.cloud conf - 1.2.0-SNAPSHOT + ${revision} ../../common/maven-conf/ @@ -76,7 +76,7 @@ org.eclipse.theia.cloud common - 1.2.0-SNAPSHOT + ${revision} io.fabric8