Added support for Spring Boot 3.2.0

This commit is contained in:
Erik C. Thauvin 2023-12-14 21:59:38 -08:00
parent 26654821bf
commit 8d5686a5c3
7 changed files with 149 additions and 80 deletions

View file

@ -86,7 +86,7 @@ public class BootJarOperation extends AbstractBootOperation<BootJarOperation> {
.destinationFileName(project.archiveBaseName() + "-" + project.version() + "-boot.jar")
.infLibs(project.compileClasspathJars())
.infLibs(project.runtimeClasspathJars())
.launcherClass("org.springframework.boot.loader.JarLauncher")
.launcherClass(BootUtils.launcherClass(project, "JarLauncher"))
.launcherLibs(project.standaloneClasspathJars())
.mainClass(project.mainClass())
.manifestAttributes(List.of(

View file

@ -16,12 +16,14 @@
package rife.bld.extension;
import rife.bld.Project;
import rife.tools.FileUtils;
import rife.tools.exceptions.FileUtilsErrorException;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.regex.Pattern;
/**
* Collection of utility-type methods used by {@link AbstractBootOperation Spring Boot operations}.
@ -30,6 +32,8 @@ import java.text.DecimalFormat;
* @since 1.0
*/
public final class BootUtils {
private static final Pattern LOADER_JAR = Pattern.compile("spring-boot-loader-(\\d+).(\\d+).(\\d+).jar");
private BootUtils() {
// no-op
}
@ -65,6 +69,28 @@ public final class BootUtils {
+ ' ' + units[digitGroups];
}
/**
* Return the fully qualified name of the launcher class.
*
* @param project the project
* @param name the class name
* @return the fully qualified class name
*/
public static String launcherClass(Project project, String name) {
for (var jar : project.standaloneClasspathJars()) {
var matcher = LOADER_JAR.matcher(jar.getName());
if (matcher.find()) {
var major = Integer.parseInt(matcher.group(1));
var minor = Integer.parseInt(matcher.group(2));
if (major == 3 && minor >= 2 || major > 3) {
return "org.springframework.boot.loader.launch." + name;
}
}
}
return "org.springframework.boot.loader." + name;
}
/**
* Makes a directory for the given path, including any necessary but nonexistent parent directories.
*

View file

@ -110,7 +110,7 @@ public class BootWarOperation extends AbstractBootOperation<BootWarOperation> {
.infLibs(project.compileClasspathJars())
.infLibs(project.runtimeClasspathJars())
.infLibs(project.buildDistDirectory())
.launcherClass("org.springframework.boot.loader.WarLauncher")
.launcherClass(BootUtils.launcherClass(project, "WarLauncher"))
.launcherLibs(project.standaloneClasspathJars())
.mainClass(project.mainClass())
.manifestAttributes(List.of(