Raise the minimum supported version of Gradle to 5.6
Closes gh-18777
This commit is contained in:
@@ -17,16 +17,13 @@
|
||||
package org.springframework.boot.gradle.dsl;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.BasePlugin;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
||||
import org.gradle.jvm.tasks.Jar;
|
||||
|
||||
import org.springframework.boot.gradle.tasks.buildinfo.BuildInfo;
|
||||
@@ -118,7 +115,7 @@ public class SpringBootExtension {
|
||||
|
||||
private String determineArtifactBaseName() {
|
||||
Jar artifactTask = findArtifactTask();
|
||||
return (artifactTask != null) ? getArchiveBaseName(artifactTask) : null;
|
||||
return (artifactTask != null) ? artifactTask.getArchiveBaseName().get() : null;
|
||||
}
|
||||
|
||||
private Jar findArtifactTask() {
|
||||
@@ -129,27 +126,4 @@ public class SpringBootExtension {
|
||||
return (Jar) this.project.getTasks().findByName("bootJar");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static String getArchiveBaseName(AbstractArchiveTask task) {
|
||||
try {
|
||||
Method method = findMethod(task.getClass(), "getArchiveBaseName");
|
||||
if (method != null) {
|
||||
return ((Property<String>) method.invoke(task)).get();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Continue
|
||||
}
|
||||
return task.getBaseName();
|
||||
}
|
||||
|
||||
private static Method findMethod(Class<?> type, String name) {
|
||||
for (Method candidate : type.getMethods()) {
|
||||
if (candidate.getName().equals(name)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ public class SpringBootPlugin implements Plugin<Project> {
|
||||
}
|
||||
|
||||
private void verifyGradleVersion() {
|
||||
if (GradleVersion.current().compareTo(GradleVersion.version("4.10")) < 0) {
|
||||
throw new GradleException("Spring Boot plugin requires Gradle 4.10 or later. The current version is "
|
||||
if (GradleVersion.current().compareTo(GradleVersion.version("5.6")) < 0) {
|
||||
throw new GradleException("Spring Boot plugin requires Gradle 5.6 or later. The current version is "
|
||||
+ GradleVersion.current());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -38,7 +37,6 @@ import org.gradle.api.java.archives.Attributes;
|
||||
import org.gradle.api.specs.Spec;
|
||||
import org.gradle.api.specs.Specs;
|
||||
import org.gradle.api.tasks.WorkResult;
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
||||
import org.gradle.api.tasks.bundling.Jar;
|
||||
import org.gradle.api.tasks.util.PatternSet;
|
||||
|
||||
@@ -95,37 +93,16 @@ class BootArchiveSupport {
|
||||
}
|
||||
|
||||
CopyAction createCopyAction(Jar jar) {
|
||||
CopyAction copyAction = new BootZipCopyAction(getOutputLocation(jar), jar.isPreserveFileTimestamps(),
|
||||
isUsingDefaultLoader(jar), this.requiresUnpack.getAsSpec(), this.exclusions.getAsExcludeSpec(),
|
||||
this.launchScript, this.compressionResolver, jar.getMetadataCharset());
|
||||
CopyAction copyAction = new BootZipCopyAction(jar.getArchiveFile().get().getAsFile(),
|
||||
jar.isPreserveFileTimestamps(), isUsingDefaultLoader(jar), this.requiresUnpack.getAsSpec(),
|
||||
this.exclusions.getAsExcludeSpec(), this.launchScript, this.compressionResolver,
|
||||
jar.getMetadataCharset());
|
||||
if (!jar.isReproducibleFileOrder()) {
|
||||
return copyAction;
|
||||
}
|
||||
return new ReproducibleOrderingCopyAction(copyAction);
|
||||
}
|
||||
|
||||
private static File getOutputLocation(AbstractArchiveTask task) {
|
||||
try {
|
||||
Method method = findMethod(task.getClass(), "getArchiveFile");
|
||||
if (method != null) {
|
||||
return (File) method.invoke(task);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Continue
|
||||
}
|
||||
return task.getArchivePath();
|
||||
}
|
||||
|
||||
private static Method findMethod(Class<?> type, String name) {
|
||||
for (Method candidate : type.getMethods()) {
|
||||
if (candidate.getName().equals(name)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isUsingDefaultLoader(Jar jar) {
|
||||
return DEFAULT_LAUNCHER_CLASSES.contains(jar.getManifest().getAttributes().get("Main-Class"));
|
||||
}
|
||||
|
||||
@@ -19,13 +19,11 @@ package org.springframework.boot.gradle.tasks.bundling;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
||||
|
||||
import org.springframework.boot.loader.tools.FileUtils;
|
||||
@@ -52,35 +50,12 @@ public class LaunchScriptConfiguration implements Serializable {
|
||||
|
||||
LaunchScriptConfiguration(AbstractArchiveTask archiveTask) {
|
||||
Project project = archiveTask.getProject();
|
||||
String baseName = getArchiveBaseName(archiveTask);
|
||||
String baseName = archiveTask.getArchiveBaseName().get();
|
||||
putIfMissing(this.properties, "initInfoProvides", baseName);
|
||||
putIfMissing(this.properties, "initInfoShortDescription", removeLineBreaks(project.getDescription()), baseName);
|
||||
putIfMissing(this.properties, "initInfoDescription", augmentLineBreaks(project.getDescription()), baseName);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static String getArchiveBaseName(AbstractArchiveTask task) {
|
||||
try {
|
||||
Method method = findMethod(task.getClass(), "getArchiveBaseName");
|
||||
if (method != null) {
|
||||
return ((Property<String>) method.invoke(task)).get();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// Continue
|
||||
}
|
||||
return task.getBaseName();
|
||||
}
|
||||
|
||||
private static Method findMethod(Class<?> type, String name) {
|
||||
for (Method candidate : type.getMethods()) {
|
||||
if (candidate.getName().equals(name)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the properties that are applied to the launch script when it's being
|
||||
* including in the executable archive.
|
||||
|
||||
Reference in New Issue
Block a user