Files
id_configurator/tests/dockerfiles/Java.Dockerfile

73 lines
3.6 KiB
Docker

FROM maven:3.9-eclipse-temurin-21 AS target
FROM interdiode/id-configurator:latest AS configuration
COPY --from=target / /src/
COPY --from=generated-config Java.yaml /config.yaml
RUN id-configurator apply --config /config.yaml --src /src --dst /dst
FROM target AS runtime
ARG JAVA_REPO_SCHEME
# Every build tool the `java` module configures: Maven itself (already part
# of this image), Gradle, Ivy and Leiningen (all packaged for this Ubuntu
# base), and SBT (no package available, fetched as a plain release tarball).
RUN apt-get update \
&& apt-get install -y --no-install-recommends gradle ivy leiningen curl \
&& curl -sL https://github.com/sbt/sbt/releases/download/v1.10.1/sbt-1.10.1.tgz -o /tmp/sbt.tgz \
&& tar -xzf /tmp/sbt.tgz -C /opt \
&& rm /tmp/sbt.tgz
ENV PATH="/opt/sbt/bin:${PATH}"
# Warm up every tool's own bootstrap/plugin dependencies from the real,
# network-reachable Maven Central while the default resolvers are still in
# place, so the actual tests below never need anything but the fixture
# repository configured by id-configurator (plus, for SBT only, the
# maven-central-fallback repository also configured below).
RUN mvn -q org.apache.maven.plugins:maven-dependency-plugin:3.6.1:get -Dartifact=org.apache.commons:commons-lang3:3.12.0
RUN mkdir -p /opt/sbt-warmup/project \
&& echo 'scalaVersion := "2.13.14"' > /opt/sbt-warmup/build.sbt \
&& echo 'sbt.version=1.10.1' > /opt/sbt-warmup/project/build.properties \
&& cd /opt/sbt-warmup && sbt update
COPY --from=configuration /dst/ /
RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.6.1:get -Dartifact=org.interdiode:idconfiguratortestpkg:0.0.1 \
&& test -f /root/.m2/repository/org/interdiode/idconfiguratortestpkg/0.0.1/idconfiguratortestpkg-0.0.1.jar
RUN mkdir -p /tmp/gradletest && cd /tmp/gradletest \
&& cat > build.gradle <<'EOF'
configurations { deps }
dependencies { deps 'org.interdiode:idconfiguratortestpkg:0.0.1' }
task resolveDeps { doLast { configurations.deps.each { println it } } }
EOF
RUN cd /tmp/gradletest && gradle -q resolveDeps | grep -q idconfiguratortestpkg
RUN java -jar /usr/share/java/ivy.jar -settings /root/.ivy2/ivysettings.xml \
-dependency org.interdiode idconfiguratortestpkg 0.0.1 \
-retrieve "/tmp/ivyretrieve/[artifact]-[revision].[ext]" \
&& test -f /tmp/ivyretrieve/idconfiguratortestpkg-0.0.1.jar
# Leiningen's standalone launcher unconditionally refuses any plain-HTTP
# repository ("Tried to use insecure HTTP repository without TLS") before
# even reading project.clj/profiles.clj - there is no `:insecure` key or
# other configuration escape hatch for this (confirmed from Leiningen's own
# source: leiningen.core.main/-main registers an aborting wagon for the
# "http" scheme unconditionally). So this check is skipped for the
# module-java-http variant: no id-configurator config could make it pass.
RUN mkdir -p /tmp/leintest && cd /tmp/leintest \
&& cat > project.clj <<'EOF'
(defproject leintest "0.1.0"
:dependencies [[org.interdiode/idconfiguratortestpkg "0.0.1"]])
EOF
RUN if [ "$JAVA_REPO_SCHEME" = "https" ]; then \
cd /tmp/leintest && lein deps :tree | grep -q idconfiguratortestpkg; \
else \
echo "skipping leiningen: it cannot use a non-HTTPS repository"; \
fi
RUN mkdir -p /tmp/sbttest/project \
&& cat > /tmp/sbttest/build.sbt <<'EOF'
scalaVersion := "2.13.14"
libraryDependencies += "org.interdiode" % "idconfiguratortestpkg" % "0.0.1"
EOF
RUN echo 'sbt.version=1.10.1' > /tmp/sbttest/project/build.properties
RUN cd /tmp/sbttest \
&& sbt -Dsbt.override.build.repos=true "show Compile/dependencyClasspath" | grep -q idconfiguratortestpkg