Versions spring boot - 2.7.1 spring boot plugin - 2.7.1 gradle - 7.5.1
Issue I am trying to build spring boot image from source. The default buildpack works, but it requires me to have the source/target java version in the machine which is used to launch gradle. The sample application is here Repo.
Details
My gradle.build looks like this - (Note that I have specified the default buildpacks along with the gradle buildpack which I assume should help launch gradle build in the build container)
plugins {
id 'org.springframework.boot' version "$springBootVersion"
id 'io.spring.dependency-management' version '1.0.13.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
repositories {
mavenCentral()
}
bootBuildImage {
imageName = "docker.io/psinhadocker/source-build:${project.version}"
bindings = ["${projectDir}/bindings:/platform/bindings"]
environment = ["BP_JVM_VERSION": "17"]
buildpacks = [
'paketo-buildpacks/ca-certificates',
'paketo-buildpacks/bellsoft-liberica',
'paketo-buildpacks/syft',
'paketo-buildpacks/gradle',
'paketo-buildpacks/dist-zip',
'paketo-buildpacks/spring-boot',
]
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
I have also specified my gradle.properties file in the bindings directory -
bindings
└── gradle
├── gradle.properties
└── type
Error
When I run gradle bootBuildImage I get the following error -
➜ gradle bootBuildImage
executing gradlew instead of gradle
> Task :bootBuildImage
Building image 'docker.io/psinhadocker/source-build:0.0.1-SNAPSHOT'
> Pulling builder image 'docker.io/paketobuildpacks/builder:base' ..................................................
> Pulled builder image 'paketobuildpacks/builder@sha256:9fb2c87caff867c9a49f04bf2ceb24c87bde504f3fed88227e9ab5d9a572060c'
> Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' ..................................................
> Pulled run image 'paketobuildpacks/run@sha256:fed727f0622994807560102d6a2d37116ed2e03dddef5445119eb017212bbfd7'
> Executing lifecycle version v0.14.2
> Using build cache volume 'pack-cache-266a6e3487e1.build'
> Running creator
[creator] Previous image with name "docker.io/psinhadocker/source-build:0.0.1-SNAPSHOT" 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 :bootBuildImage FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootBuildImage'.
> Builder lifecycle 'creator' failed with status code 20
Alternative Pack command is working, but it doesn't layer the image the same way as the gradle plugin.
-> pack build --volume $(pwd)/bindings:/platform/bindings applications/gradle -e BP_JVM_VERSION=17
base: Pulling from paketobuildpacks/builder
Digest: sha256:9fb2c87caff867c9a49f04bf2ceb24c87bde504f3fed88227e9ab5d9a572060c
Status: Image is up to date for paketobuildpacks/builder:base
base-cnb: Pulling from paketobuildpacks/run
Digest: sha256:fed727f0622994807560102d6a2d37116ed2e03dddef5445119eb017212bbfd7
Status: Image is up to date for paketobuildpacks/run:base-cnb
Restoring data for SBOM from previous image
===> DETECTING
10 of 24 buildpacks participating
paketo-buildpacks/ca-certificates 3.4.0
paketo-buildpacks/bellsoft-liberica 9.6.1
paketo-buildpacks/syft 1.18.0
paketo-buildpacks/gradle 6.8.0
paketo-buildpacks/executable-jar 6.4.0
paketo-buildpacks/apache-tomcat 7.5.0
paketo-buildpacks/apache-tomee 1.2.0
paketo-buildpacks/liberty 2.1.1
paketo-buildpacks/dist-zip 5.3.0
paketo-buildpacks/spring-boot 5.18.0
...
Adding cache layer 'paketo-buildpacks/bellsoft-liberica:jdk'
Reusing cache layer 'paketo-buildpacks/syft:syft'
Adding cache layer 'paketo-buildpacks/gradle:application'
Adding cache layer 'paketo-buildpacks/gradle:cache'
Reusing cache layer 'cache.sbom'
Successfully built image applications/gradle
Comment From: scottfrederick
I am trying to build spring boot image from source.
This is not possible using the Spring Boot build plugins. The Spring Boot plugins always send the contents of the Boot-generated jar or war file to the builder, and will never send the source code for the project. If you want to build from source, you will need to use a different CNB platform that is designed for that use case.
The rest of your questions are being answered in the discussion started in the Paketo Slack. As we prefer to use GitHub issues only for bugs and enhancements, let's continue the discussion there.