salesforce / rules_spring

Bazel rule for building Spring Boot apps as a deployable jar
BSD 3-Clause "New" or "Revised" License
229 stars 49 forks source link

Add support for new Boot Loader in Spring Boot 3.2.0 #177

Closed hjellek closed 10 months ago

hjellek commented 10 months ago

In Spring Boot 3.2.0 a new org.springframework.boot.loader.launch.JarLauncher has been introduced.

Currently the old loader is hardcoded in write_manifest.sh and springboot_pkg.sh.

This should be open for overriding, or automatically switch between the loaders based on detected Spring Boot version.

As a workaround, one can include spring-boot-loader-classic in the application dependencies to get the old JarLauncher.

plaird commented 10 months ago

Good suggestion, thanks! Should be pretty easy to add.

plaird commented 10 months ago

🔔 we just hit a limitation of this new feature internally. Coincidentally, we had a work item to migrate a Spring Boot app from Maven to Bazel, and we just started doing it and found it happens to need this boot-launcher-class feature.

BUT, the app has written a custom launcher, not one of the ones from Spring Boot. This surfaced an issue. This feature assumes that the launcher class is written into the root of the springboot jar, not in BOOT-INF/lib.

tar -tvf myspringboot.jar
...
com/salesforce/boot/MyCustomJarLauncher.class
...

We will work on a solution to support custom launchers in #129

luangong commented 10 months ago

I’m using Spring Boot 3 and I also ran into this issue. Hope it could be fixed soon in #129. Thanks!

plaird commented 10 months ago

@luangong release 2.3.1 should have the fix you need. You will need to set the new boot_launcher_class attribute.

   # use the spring boot 3 launcher
   boot_launcher_class = 'org.springframework.boot.loader.launch.JarLauncher',
luangong commented 10 months ago

Specifying the new JarLauncher via the boot_launcher_class attribute works. Thanks!