redhat-buildpacks / testing

Project aiming to help us to perform e2e tests using Buildpacks
Apache License 2.0
0 stars 3 forks source link

paketo community UBI builder 0.0.54 cannot build quarkus 3.9 as extender reports : Fatal error compiling: error: release version 21 not supported #52

Open cmoulliard opened 4 months ago

cmoulliard commented 4 months ago

Issue

Latest paketo community UBI image cannot build quarkus 3.9 no matter if we set BP_JVM_VERSION to use as value 17 or 21.

pack build ${REGISTRY_HOST}/quarkus-hello:1.0 \
     --builder paketocommunity/builder-ubi-base:0.0.54 \
     -e BP_NATIVE_IMAGE="false" \
     -e BP_JVM_VERSION="17" \
     -e BP_MAVEN_BUILT_ARTIFACT="target/quarkus-app/lib/ target/quarkus-app/*.jar target/quarkus-app/app/ target/quarkus-app/quarkus/" \
     -e BP_MAVEN_BUILD_ARGUMENTS="package -DskipTests=true -Dmaven.javadoc.skip=true -Dquarkus.package.type=fast-jar" \
     --volume $HOME/.m2:/home/cnb/.m2:rw \
     --path .
...
[extender (build)]       [INFO] ------------------------------------------------------------------------
[extender (build)]       [INFO] BUILD FAILURE
[extender (build)]       [INFO] ------------------------------------------------------------------------
[extender (build)]       [INFO] Total time:  18.781 s
[extender (build)]       [INFO] Finished at: 2024-04-11T10:51:00Z
[extender (build)]       [INFO] ------------------------------------------------------------------------
[extender (build)]       [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.12.1:compile (default-compile) on project quarkus-hello: Fatal error compiling: error: release version 21 not supported -> [Help 1]
[extender (build)]       [ERROR]
[extender (build)]       [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[extender (build)]       [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[extender (build)]       [ERROR]
[extender (build)]       [ERROR] For more information about the errors and possible solutions, please read the following articles:
[extender (build)]       [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[extender (build)] unable to invoke layer creator
[extender (build)] unable to contribute application layer
[extender (build)] error running build
[extender (build)] exit status 1
[extender (build)]       ERROR: failed to build: exit status 1

What should we do ? @BarDweller

cmoulliard commented 4 months ago

The origin of the issue is because when we generate a quarkus project using maven, then it sets the maven compiler to 21 using Quarkus >= 3.8

To get rid of that, we can generate a project where we select the JDK like this

mvn io.quarkus.platform:quarkus-maven-plugin:3.8.3:create \
  -DprojectGroupId=dev.snowdrop \
  -DprojectArtifactId=quarkus-hello \
  -DjavaVersion=17 \
  -DprojectVersion=1.0 \
  -DplatformVersion=3.8.3 \
  -Dextensions='resteasy-reactive,kubernetes,buildpack'
cmoulliard commented 4 months ago

Question: Is there a way to figure out which JDK is packaged (11, 17, 21) by default within the paketo community UBI builder image (paketocommunity/builder-ubi-base:0.0.54) ? Can we override it part of the extension execution (using our own Dockerfile maybe) ?

BarDweller commented 4 months ago

Question: Is there a way to figure out which JDK is packaged (11, 17, 21) by default within the paketo community UBI builder image (paketocommunity/builder-ubi-base:0.0.54) ? Can we override it part of the extension execution (using our own Dockerfile maybe) ?

No JDKs are packaged within the paketo community UBI builder image. The JDK is installed into the builder image during the extend phase by microdnf, which obtains it from the UBI repository for the appropriate version of the runtime.

The version is resolved using libjvm (a paketo library for java buildpack related stuff), that lib will look at the version detected/requested by any maven/gradle etc build files, and will use BP_JVM_VERSION if set, and if all that fails, will fall back to the version defaulted in the extension.toml for the ubi java extension (currently 17 .. https://github.com/paketo-community/ubi-java-extension/blob/main/extension.toml )

BarDweller commented 4 months ago

Latest paketo community UBI image cannot build quarkus 3.9 no matter if we set BP_JVM_VERSION to use as value 17 or 21. What should we do ? @BarDweller

Note that 21 is not a valid option for the paketocommunity UBI builder image, we have PRs pending to add it, and are working through them.

BarDweller commented 4 months ago
     -e BP_MAVEN_BUILT_ARTIFACT="target/quarkus-app/lib/ target/quarkus-app/*.jar target/quarkus-app/app/ target/quarkus-app/quarkus/" \
     -e BP_MAVEN_BUILD_ARGUMENTS="package -DskipTests=true -Dmaven.javadoc.skip=true -Dquarkus.package.type=fast-jar" \

Also, note that these should not be required when using the paketocommunity UBI builder image, as the image contains the paketo quarkus buildpack that will detect quarkus projects and handle this for you.

cmoulliard commented 4 months ago

As JDK 21 is not yet available I will then use 17 which is available [extender (build)] Installing: java-17-openjdk-headless;1:17.0.10.0.7-2.el8;x86_64;ubi-8-appstream-rpms

and force maven to use it when the quarkus project is created

mvn io.quarkus.platform:quarkus-maven-plugin:3.8.3:create \
  -DprojectGroupId=dev.snowdrop \
  -DprojectArtifactId=quarkus-hello \
  -DjavaVersion=17 \
  -DprojectVersion=1.0 \
  -DplatformVersion=3.8.3 \
  -Dextensions='resteasy-reactive,kubernetes,buildpack'

So running now this pack command works

  REGISTRY_HOST="kind-registry.local:5000"
docker rmi ${REGISTRY_HOST}/quarkus-hello:1.0
pack build ${REGISTRY_HOST}/quarkus-hello:1.0 \
     --builder paketocommunity/builder-ubi-base:0.0.54 \
     -e BP_NATIVE_IMAGE="false" \
     -e BP_JVM_VERSION="17" \
     --volume $HOME/.m2:/home/cnb/.m2:rw \
     --path .
  ...
  [extender (build)] Paketo Buildpack for Executable JAR 6.8.5
[extender (build)]   https://github.com/paketo-buildpacks/executable-jar
[extender (build)]
[extender (build)]   Process types:
[extender (build)]     executable-jar: java -jar /workspace/quarkus-run.jar (direct)
[extender (build)]     task:           java -jar /workspace/quarkus-run.jar (direct)
[extender (build)]     web:            java -jar /workspace/quarkus-run.jar (direct)
===> EXPORTING
[exporter] Adding layer 'paketo-community/ubi-java-buildpack:ajre'
[exporter] Adding layer 'paketo-community/ubi-java-buildpack:helper'
[exporter] Adding layer 'paketo-community/ubi-java-buildpack:java-security-properties'
[exporter] Adding layer 'paketo-buildpacks/ca-certificates:helper'
[exporter] Adding layer 'buildpacksio/lifecycle:launch.sbom'
[exporter] Adding 5/5 app layer(s)
[exporter] Adding layer 'buildpacksio/lifecycle:launcher'
[exporter] Adding layer 'buildpacksio/lifecycle:config'
[exporter] Adding layer 'buildpacksio/lifecycle:process-types'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] Setting default process type 'web'
[exporter] Saving kind-registry.local:5000/quarkus-hello:1.0...
[exporter] *** Images (f44f6ea63d6d):
[exporter]       kind-registry.local:5000/quarkus-hello:1.0
[exporter] Reusing cache layer 'paketo-buildpacks/syft:syft'
[exporter] Reusing cache layer 'paketo-buildpacks/maven:application'
[exporter] Reusing cache layer 'paketo-buildpacks/maven:cache'
[exporter] Reusing cache layer 'buildpacksio/lifecycle:cache.sbom'
Successfully built image kind-registry.local:5000/quarkus-hello:1.0