Execute

 ./gradlew bootBuildImage 

Build Dependencies

classpath
+--- org.springframework.boot:spring-boot-gradle-plugin:3.0.0-RC1
|    +--- org.springframework.boot:spring-boot-buildpack-platform:3.0.0-RC1
|    |    +--- com.fasterxml.jackson.core:jackson-databind:2.14.0-rc2
|    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.14.0-rc2
|    |    |    |    \--- com.fasterxml.jackson:jackson-bom:2.14.0-rc2
|    |    |    |         +--- com.fasterxml.jackson.core:jackson-annotations:2.14.0-rc2 (c)
|    |    |    |         +--- com.fasterxml.jackson.core:jackson-core:2.14.0-rc2 (c)
|    |    |    |         +--- com.fasterxml.jackson.core:jackson-databind:2.14.0-rc2 (c)
|    |    |    |         +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0-rc2 (c)
|    |    |    |         \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.0-rc2 (c)
|    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.14.0-rc2
|    |    |    |    \--- com.fasterxml.jackson:jackson-bom:2.14.0-rc2 (*)
|    |    |    \--- com.fasterxml.jackson:jackson-bom:2.14.0-rc2 (*)
|    |    +--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.0-rc2
|    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.14.0-rc2 (*)
|    |    |    +--- com.fasterxml.jackson.core:jackson-databind:2.14.0-rc2 (*)
|    |    |    \--- com.fasterxml.jackson:jackson-bom:2.14.0-rc2 (*)
|    |    +--- net.java.dev.jna:jna-platform:5.7.0
|    |    |    \--- net.java.dev.jna:jna:5.7.0
|    |    +--- org.apache.commons:commons-compress:1.21
|    |    +--- org.apache.httpcomponents:httpclient:4.5.13
|    |    |    +--- org.apache.httpcomponents:httpcore:4.4.13 -> 4.4.14
|    |    |    +--- commons-logging:commons-logging:1.2
|    |    |    \--- commons-codec:commons-codec:1.11
|    |    +--- org.springframework:spring-core:6.0.0-RC2
|    |    |    \--- org.springframework:spring-jcl:6.0.0-RC2
|    |    \--- org.tomlj:tomlj:1.0.0
|    |         +--- org.antlr:antlr4-runtime:4.7.2
|    |         \--- com.google.code.findbugs:jsr305:3.0.2
|    +--- org.springframework.boot:spring-boot-loader-tools:3.0.0-RC1
|    |    +--- org.apache.commons:commons-compress:1.21
|    |    \--- org.springframework:spring-core:6.0.0-RC2 (*)
|    +--- io.spring.gradle:dependency-management-plugin:1.1.0
|    +--- org.apache.commons:commons-compress:1.21
|    \--- org.springframework:spring-core:6.0.0-RC2 (*)
+--- io.spring.gradle:dependency-management-plugin:1.1.0
+--- net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:1.1.1
|    \--- net.ltgt.gradle:gradle-errorprone-plugin:1.1.1
+--- org.hidetake.ssh:org.hidetake.ssh.gradle.plugin:2.10.1
|    \--- org.hidetake:gradle-ssh-plugin:2.10.1
|         \--- org.hidetake:groovy-ssh:2.10.1
|              +--- org.slf4j:slf4j-api:1.7.7
|              +--- com.jcraft:jsch:0.1.55
|              +--- com.jcraft:jsch.agentproxy.connector-factory:0.0.9
|              |    +--- com.jcraft:jsch.agentproxy.core:0.0.9
|              |    +--- com.jcraft:jsch.agentproxy.usocket-jna:0.0.9
|              |    |    +--- com.jcraft:jsch.agentproxy.core:0.0.9
|              |    |    +--- net.java.dev.jna:jna:4.1.0 -> 5.7.0
|              |    |    \--- net.java.dev.jna:jna-platform:4.1.0 -> 5.7.0 (*)
|              |    +--- com.jcraft:jsch.agentproxy.usocket-nc:0.0.9
|              |    |    \--- com.jcraft:jsch.agentproxy.core:0.0.9
|              |    +--- com.jcraft:jsch.agentproxy.sshagent:0.0.9
|              |    |    \--- com.jcraft:jsch.agentproxy.core:0.0.9
|              |    \--- com.jcraft:jsch.agentproxy.pageant:0.0.9
|              |         +--- com.jcraft:jsch.agentproxy.core:0.0.9
|              |         +--- net.java.dev.jna:jna:4.1.0 -> 5.7.0
|              |         \--- net.java.dev.jna:jna-platform:4.1.0 -> 5.7.0 (*)
|              \--- com.jcraft:jsch.agentproxy.jsch:0.0.9
|                   +--- com.jcraft:jsch:0.1.49 -> 0.1.55
|                   \--- com.jcraft:jsch.agentproxy.core:0.0.9
+--- com.google.cloud.tools.jib:com.google.cloud.tools.jib.gradle.plugin:3.1.1
|    \--- gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:3.1.1
|         +--- com.google.http-client:google-http-client:1.38.1
|         |    +--- org.apache.httpcomponents:httpclient:4.5.13 (*)
|         |    +--- org.apache.httpcomponents:httpcore:4.4.14
|         |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    +--- com.google.guava:guava:30.1-android -> 30.1.1-jre
|         |    |    +--- com.google.guava:failureaccess:1.0.1
|         |    |    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|         |    |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    |    +--- org.checkerframework:checker-qual:3.8.0
|         |    |    +--- com.google.errorprone:error_prone_annotations:2.5.1
|         |    |    \--- com.google.j2objc:j2objc-annotations:1.3
|         |    +--- com.google.j2objc:j2objc-annotations:1.3
|         |    +--- io.opencensus:opencensus-api:0.24.0
|         |    |    \--- io.grpc:grpc-context:1.22.1
|         |    \--- io.opencensus:opencensus-contrib-http-util:0.24.0
|         |         +--- io.opencensus:opencensus-api:0.24.0 (*)
|         |         \--- com.google.guava:guava:26.0-android -> 30.1.1-jre (*)
|         +--- com.google.http-client:google-http-client-apache-v2:1.38.1
|         |    +--- com.google.http-client:google-http-client:1.38.1 (*)
|         |    +--- org.apache.httpcomponents:httpclient:4.5.13 (*)
|         |    \--- org.apache.httpcomponents:httpcore:4.4.14
|         +--- com.google.auth:google-auth-library-oauth2-http:0.22.2
|         |    +--- com.google.auto.value:auto-value-annotations:1.7.4
|         |    +--- com.google.code.findbugs:jsr305:3.0.2
|         |    +--- com.google.auth:google-auth-library-credentials:0.22.2
|         |    +--- com.google.http-client:google-http-client:1.38.0 -> 1.38.1 (*)
|         |    +--- com.google.http-client:google-http-client-jackson2:1.38.0
|         |    |    +--- com.google.http-client:google-http-client:1.38.0 -> 1.38.1 (*)
|         |    |    \--- com.fasterxml.jackson.core:jackson-core:2.11.3 -> 2.14.0-rc2 (*)
|         |    \--- com.google.guava:guava:30.0-android -> 30.1.1-jre (*)
|         +--- org.apache.commons:commons-compress:1.20 -> 1.21
|         +--- com.google.guava:guava:30.1.1-jre (*)
|         +--- com.fasterxml.jackson.core:jackson-databind:2.12.3 -> 2.14.0-rc2 (*)
|         +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3 -> 2.14.0-rc2
|         |    +--- com.fasterxml.jackson.core:jackson-annotations:2.14.0-rc2 (*)
|         |    +--- com.fasterxml.jackson.core:jackson-core:2.14.0-rc2 (*)
|         |    +--- com.fasterxml.jackson.core:jackson-databind:2.14.0-rc2 (*)
|         |    \--- com.fasterxml.jackson:jackson-bom:2.14.0-rc2 (*)
|         +--- org.ow2.asm:asm:9.1
|         +--- com.google.cloud.tools:jib-build-plan:0.4.0
|         +--- com.google.cloud.tools:jib-plugins-extension-common:0.2.0
|         \--- com.google.cloud.tools:jib-gradle-plugin-extension-api:0.4.0
|              +--- com.google.cloud.tools:jib-build-plan:0.4.0
|              \--- com.google.cloud.tools:jib-plugins-extension-common:0.2.0
\--- org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.9.16
     \--- org.graalvm.buildtools:native-gradle-plugin:0.9.16
          +--- org.graalvm.buildtools:utils:0.9.16
          |    \--- com.fasterxml.jackson.core:jackson-databind:2.13.3 -> 2.14.0-rc2 (*)
          \--- org.graalvm.buildtools:graalvm-reachability-metadata:0.9.16
               \--- com.fasterxml.jackson.core:jackson-databind:2.13.3 -> 2.14.0-rc2 (*)

Error

> Task :flycat-price:bootBuildImage
Building image 'docker.io/library/flycat-price:local-git_main_20221029_211328_82f596a'

 > Pulling builder image 'docker.io/paketobuildpacks/builder:tiny' ..................................................
 > Pulled builder image 'paketobuildpacks/builder@sha256:b8e058067cd45470f2ae4e02d44c410105601a8b3b5a9f85d5274bc8330c99a9'
 > Pulling run image 'docker.io/paketobuildpacks/run:tiny-cnb' ..................................................
 > Pulled run image 'paketobuildpacks/run@sha256:eb543f618cbae8f0c32c7ab11284cc4f3074f5275902f17ece9def661e9b5c50'
 > Executing lifecycle version v0.14.3
 > Using build cache volume 'pack-cache-8dfe90627122.build'

 > Running creator
    [creator]     Previous image with name "docker.io/library/flycat-price:local-git_main_20221029_211328_82f596a" not found
    [creator]     ===> DETECTING
    [creator]     ERROR: No buildpack groups passed detection.
    [creator]     ERROR: Please check that you are running against the correct path.
    [creator]     ERROR: failed to detect: no buildpacks participating

> Task :flycat-price:bootBuildImage FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flycat-price:bootBuildImage'.
> Builder lifecycle 'creator' failed with status code 20

Version

❯ uname -a
Darwin MacBook-Air 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:07 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8110 arm64

❯ java --version
openjdk 17.0.4 2022-07-19 LTS
OpenJDK Runtime Environment GraalVM 22.2.0 (build 17.0.4+8-LTS)
OpenJDK 64-Bit Server VM GraalVM 22.2.0 (build 17.0.4+8-LTS, mixed mode, sharing)

~/Dropbox/Project/flycat-projects main*
❯ ./gradlew --version

------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------

Build time:   2022-08-05 21:17:56 UTC
Revision:     d1daa0cbf1a0103000b71484e1dbfe096e095918

Kotlin:       1.6.21
Groovy:       3.0.10
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.4 (BellSoft 17.0.4+8-LTS)
OS:           Mac OS X 12.6 aarch64


Comment From: wilkinsona

This could be a duplicate of https://github.com/spring-projects/spring-boot/issues/32886. @zgqq can you please share your build.gradle script?

Comment From: zgqq

@wilkinsona Thanks for your reply, the problem has been found, caused by that bootJar is disabled.

bootJar.enabled = false
bootJar {
    archiveClassifier = ''
}

Comment From: wilkinsona

Thanks for letting us know.

Comment From: jabrena

Hi @wilkinsona,

I have the same issue using maven:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-RC1:build-image 
(default-cli) on project benchmark-jibber: Execution default-cli of goal 
org.springframework.boot:spring-boot-maven-plugin:3.0.0-RC1:build-image failed: 
Builder lifecycle 'creator' failed with status code 20 -> [Help 1]
[ERROR] 

This is the default configuration provided from the generator: https://start.spring.io/

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <buildpacks>
                            <buildpack>gcr.io/paketo-buildpacks/bellsoft-liberica:9.9.0-ea</buildpack>
                            <buildpack>gcr.io/paketo-buildpacks/java-native-image</buildpack>
                        </buildpacks>
                    </image>
                </configuration>
            </plugin>

What is the solution for maven?

Many thanks in advance

Comment From: scottfrederick

@jabrena Please show the full output from Maven so we can see what the buildpacks are doing.

Comment From: jabrena

Yes of course :)

Current plugin configuration:

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <!-- <name>jibber-benchmark:buildpack.0.0.1-SNAPSHOT</name>
                        <builder>docker.io/paketobuildpacks/builder:base</builder>
                        <runImage>docker.io/paketobuildpacks/run:base-cnb</runImage>
                        -->
                        <buildpacks>
                            <buildpack>gcr.io/paketo-buildpacks/bellsoft-liberica:9.9.0-ea</buildpack>
                            <buildpack>gcr.io/paketo-buildpacks/java-native-image</buildpack>
                        </buildpacks>
                        <!--
                        <env>
                            <BP_NATIVE_IMAGE_BUILD_ARGUMENTS> - - verbose</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
                            <BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
                        </env>
                        -->
                    </image>
                </configuration>
            </plugin>

Command line execution:

mvn clean spring-boot:build-image

Logs:

[INFO] --- spring-boot-maven-plugin:3.0.0-RC1:build-image (default-cli) @ my-demo ---
[INFO] Building image 'docker.io/library/my-demo:0.0.1-SNAPSHOT'
[INFO] 
[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
[INFO]  > Pulled builder image 'paketobuildpacks/builder@sha256:357e0a15daed9d3d7da69d893acbbf5d25947e9652b72d4beef3ef210233e8f0'
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 100%
[INFO]  > Pulled run image 'paketobuildpacks/run@sha256:00aa8f345b7ae947cd6dbecf0e8536ebccfd9828dffe454b5e7e3f929723aaa8'
[INFO]  > Pulling buildpack image 'gcr.io/paketo-buildpacks/bellsoft-liberica:9.9.0-ea' 100%
[INFO]  > Pulled buildpack image 'gcr.io/paketo-buildpacks/bellsoft-liberica@sha256:32e69e3fcc17725ed8a7bddd9d2881a0f1019354a0e653521dac55898c0e8c36'
[INFO]  > Pulling buildpack image 'gcr.io/paketo-buildpacks/java-native-image:latest' 100%
[INFO]  > Pulled buildpack image 'gcr.io/paketo-buildpacks/java-native-image@sha256:f431fcb5a37e0719e7f4848027c9bd8d29da862913b481b2a55646b613e396b0'
[INFO]  > Executing lifecycle version v0.15.0
[INFO]  > Using build cache volume 'pack-cache-b61a4113329f.build'
[INFO] 
[INFO]  > Running creator
[INFO]     [creator]     ===> ANALYZING
[INFO]     [creator]     Previous image with name "docker.io/library/my-demo:0.0.1-SNAPSHOT" not found
[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     err:  paketo-buildpacks/leiningen@4.4.0
[INFO]     [creator]     ERROR: No buildpack groups passed detection.
[INFO]     [creator]     ERROR: Please check that you are running against the correct path.
[INFO]     [creator]     ERROR: failed to detect: no buildpacks participating
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.002 s
[INFO] Finished at: 2022-11-03T20:55:41+01:00
[INFO] ------------------------------------------------------------------------

Note: the projects work fine with other goals mvn spring-boot:run but if I want to create a docker image with the plugin, it is failing with 3.x

Comment From: scottfrederick

As mentioned in the documentation, the build command should be mvn -Pnative spring-boot:build-image. Without the native profile, the application won't be AOT-processed and it can't be built into a native image.

Comment From: jabrena

Hi @scottfrederick,

I can confirm that I was able to create the docker image in that way with a native compilation.

[INFO]     [creator]     Adding layer 'paketo-buildpacks/ca-certificates:helper'
[INFO]     [creator]     Adding layer 'launch.sbom'
[INFO]     [creator]     Adding 1/1 app layer(s)
[INFO]     [creator]     Adding layer 'launcher'
[INFO]     [creator]     Adding layer 'config'
[INFO]     [creator]     Adding layer 'process-types'
[INFO]     [creator]     Adding label 'io.buildpacks.lifecycle.metadata'
[INFO]     [creator]     Adding label 'io.buildpacks.build.metadata'
[INFO]     [creator]     Adding label 'io.buildpacks.project.metadata'
[INFO]     [creator]     Adding label 'org.opencontainers.image.title'
[INFO]     [creator]     Adding label 'org.opencontainers.image.version'
[INFO]     [creator]     Adding label 'org.springframework.boot.version'
[INFO]     [creator]     Setting default process type 'web'
[INFO]     [creator]     Saving docker.io/library/my-demo:0.0.1-SNAPSHOT...
[INFO]     [creator]     *** Images (243c88284144):
[INFO]     [creator]           docker.io/library/my-demo:0.0.1-SNAPSHOT
[INFO]     [creator]     Adding cache layer 'paketo-buildpacks/bellsoft-liberica:native-image-svm'
[INFO]     [creator]     Adding cache layer 'paketo-buildpacks/syft:syft'
[INFO]     [creator]     Adding cache layer 'paketo-buildpacks/native-image:native-image'
[INFO]     [creator]     Adding cache layer 'cache.sbom'
[INFO] 
[INFO] Successfully built image 'docker.io/library/my-demo:0.0.1-SNAPSHOT'

but, how to build the Docker image for a non native build? I would like to create the typical docker with a jar, how to do it?

Current plugin configuration:

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <buildpacks>
                            <buildpack>gcr.io/paketo-buildpacks/bellsoft-liberica:9.9.0-ea</buildpack>
                            <buildpack>gcr.io/paketo-buildpacks/java-native-image</buildpack>
                        </buildpacks>
                        <env>
                            <!--
                            <BP_BINARY_COMPRESSION_METHOD>upx</BP_BINARY_COMPRESSION_METHOD>
                            <BP_NATIVE_IMAGE_BUILD_ARGUMENTS>- -static</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
                            <BP_NATIVE_IMAGE>false</BP_NATIVE_IMAGE>
                            -->
                        </env>
                    </image>
                </configuration>
            </plugin>

Comment From: scottfrederick

how to build the Docker image for a non native build?

Remove the <buildpacks></buildpacks> configuration from pom.xml and allow the default buildpacks to be used. You're explicitly configuring the image build to use the java-native-image buildpack, which you don't want to do if you want an image that runs the jar in a JVM.

Configuring the buildpacks to use when you want a native image, as in these examples, is a short-term work-around that will not be required by the time Spring Framework 6.0 and Spring Boot 3.0 are released. At that time, the correct buildpacks will be chosen based on whether you're building with a native profile or not without any explicit <buildpacks> configuration.

This discussions is straying away from the original issue now. If you have further questions, please post them to StackOverflow.

Comment From: jabrena

Hi @scottfrederick,

I share with the community a way to build docker images with JVM inside and Native one:

    <profiles>
        <profile>
            <id>jvm</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <imageName>my-demo:buildpacks-jvm.0.0.1-SNAPSHOT</imageName>
                            <image>
                                <buildpacks>
                                    <!-- EMPTY -->
                                </buildpacks>
                            </image>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>native</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <imageName>my-demo:buildpacks-native.0.0.1-SNAPSHOT</imageName>
                            <image>
                                <buildpacks>
                                    <buildpack>gcr.io/paketo-buildpacks/bellsoft-liberica:9.10</buildpack>
                                    <buildpack>gcr.io/paketo-buildpacks/java-native-image</buildpack>
                                </buildpacks>
                            </image>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
echo "Generated Executables with buildpacks"
mvn -Pnative spring-boot:build-image
mvn spring-boot:build-image