paketo-buildpacks / spring-boot

A Cloud Native Buildpack that contributes Spring Boot dependency information and slices an application into multiple layers
Apache License 2.0
178 stars 21 forks source link

Unable to find Spring Boot Executable Jar #499

Closed zhoufenqin closed 3 months ago

zhoufenqin commented 4 months ago

We package spring boot project as a war package, without maven plugin

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

Then the MANIFEST.MF is like below, there is no Spring-Boot-Version or Main-Class in the file

Manifest-Version: 1.0
Created-By: Maven WAR Plugin 3.3.2
Build-Jdk-Spec: 17
Implementation-Title: containerapps-albumapi-java
Implementation-Version: 0.0.1-SNAPSHOT

In previous 5.28.0 version, the build can be passes, but after upgrading to 5.30.0, the build will failed, the error shows that

......
Tanzu Buildpack for Spring Boot 5.30.0
  unable to find Spring Boot Executable Jar
  open : no such file or directory
Timer: Builder ran for 500.172212ms and ended at 2024-07-24T05:03:21Z
ERROR: failed to build: exit status 1

the detect buildpacks include

Timer: Detector started at 2024-07-24T09:25:34Z
9 of 42 buildpacks participating
tanzu-buildpacks/ca-certificates            3.8.0
tanzu-buildpacks/microsoft-openjdk          4.0.1
paketo-buildpacks/syft                      1.10.1
tanzu-buildpacks/apache-tomcat              7.16.0
tanzu-buildpacks/apache-tomee               1.9.0
tanzu-buildpacks/liberty                    3.10.0
tanzu-buildpacks/dist-zip                   5.8.0
tanzu-buildpacks/spring-boot                5.30.0
tanzu-buildpacks/azure-application-insights 5.19.0

If we add maven plugin to pom.xml, it works, and the MANIFEST.MF shows like

Manifest-Version: 1.0
Created-By: Maven WAR Plugin 3.3.2
Build-Jdk-Spec: 17
Implementation-Title: containerapps-albumapi-java
Implementation-Version: 0.0.1-SNAPSHOT
Main-Class: org.springframework.boot.loader.WarLauncher
Start-Class: examples.azure.containerappsalbumapijava.ContainerappsAlbum
 apiJavaApplication
Spring-Boot-Version: 3.1.5
Spring-Boot-Classes: WEB-INF/classes/
Spring-Boot-Lib: WEB-INF/lib/
Spring-Boot-Classpath-Index: WEB-INF/classpath.idx
Spring-Boot-Layers-Index: WEB-INF/layers.idx

I saw there is a commit about build.go and it caused by this change: https://github.com/paketo-buildpacks/spring-boot/commit/d8787acef1eb291d0a82fcce6e4f8b437789e421?diff=split&w=0#diff-f5e7f5225075621503ea53e37014cf808702bf28601c68fdb152b3afcf503591

why restrict to include Spring-Boot-Version or Main-Class in MANIFEST.MF file?

Expected Behavior

The build should work for fat/thin war

Current Behavior

if the war MANIFEST.MF doesn't container Spring-Boot-Version, it will fail.

Possible Solution

Steps to Reproduce

1.

Motivations

zhoufenqin commented 4 months ago

@pivotal-david-osullivan can you help to check this?