mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Remove obsolete Java compatibility code
See gh-31452
This commit is contained in:
parent
cb22905944
commit
a639685053
@ -17,16 +17,13 @@
|
|||||||
package org.springframework.boot.gradle.tasks.run;
|
package org.springframework.boot.gradle.tasks.run;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.gradle.api.file.SourceDirectorySet;
|
import org.gradle.api.file.SourceDirectorySet;
|
||||||
import org.gradle.api.provider.Property;
|
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.JavaExec;
|
import org.gradle.api.tasks.JavaExec;
|
||||||
import org.gradle.api.tasks.SourceSet;
|
import org.gradle.api.tasks.SourceSet;
|
||||||
import org.gradle.api.tasks.SourceSetOutput;
|
import org.gradle.api.tasks.SourceSetOutput;
|
||||||
import org.gradle.jvm.toolchain.JavaLauncher;
|
|
||||||
import org.gradle.work.DisableCachingByDefault;
|
import org.gradle.work.DisableCachingByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,9 +75,6 @@ public class BootRun extends JavaExec {
|
|||||||
public void exec() {
|
public void exec() {
|
||||||
if (this.optimizedLaunch) {
|
if (this.optimizedLaunch) {
|
||||||
setJvmArgs(getJvmArgs());
|
setJvmArgs(getJvmArgs());
|
||||||
if (!isJava13OrLater()) {
|
|
||||||
jvmArgs("-Xverify:none");
|
|
||||||
}
|
|
||||||
jvmArgs("-XX:TieredStopAtLevel=1");
|
jvmArgs("-XX:TieredStopAtLevel=1");
|
||||||
}
|
}
|
||||||
if (System.console() != null) {
|
if (System.console() != null) {
|
||||||
@ -90,17 +84,4 @@ public class BootRun extends JavaExec {
|
|||||||
super.exec();
|
super.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isJava13OrLater() {
|
|
||||||
Property<JavaLauncher> javaLauncher = this.getJavaLauncher();
|
|
||||||
if (javaLauncher.isPresent()) {
|
|
||||||
return javaLauncher.get().getMetadata().getLanguageVersion().asInt() >= 13;
|
|
||||||
}
|
|
||||||
for (Method method : String.class.getMethods()) {
|
|
||||||
if (method.getName().equals("stripIndent")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import java.util.jar.Attributes;
|
|||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
import org.gradle.api.JavaVersion;
|
|
||||||
import org.gradle.testkit.runner.BuildResult;
|
import org.gradle.testkit.runner.BuildResult;
|
||||||
import org.gradle.testkit.runner.TaskOutcome;
|
import org.gradle.testkit.runner.TaskOutcome;
|
||||||
import org.junit.jupiter.api.TestTemplate;
|
import org.junit.jupiter.api.TestTemplate;
|
||||||
@ -96,13 +95,8 @@ class BootRunIntegrationTests {
|
|||||||
copyJvmArgsApplication();
|
copyJvmArgsApplication();
|
||||||
BuildResult result = this.gradleBuild.build("bootRun");
|
BuildResult result = this.gradleBuild.build("bootRun");
|
||||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||||
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) {
|
|
||||||
assertThat(result.getOutput()).contains("-XX:TieredStopAtLevel=1");
|
assertThat(result.getOutput()).contains("-XX:TieredStopAtLevel=1");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
assertThat(result.getOutput()).contains("-Xverify:none").contains("-XX:TieredStopAtLevel=1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestTemplate
|
@TestTemplate
|
||||||
void optimizedLaunchDisabledJvmArgs() throws IOException {
|
void optimizedLaunchDisabledJvmArgs() throws IOException {
|
||||||
@ -117,15 +111,9 @@ class BootRunIntegrationTests {
|
|||||||
copyJvmArgsApplication();
|
copyJvmArgsApplication();
|
||||||
BuildResult result = this.gradleBuild.build("bootRun");
|
BuildResult result = this.gradleBuild.build("bootRun");
|
||||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||||
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) {
|
|
||||||
assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar")
|
assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar")
|
||||||
.contains("-XX:TieredStopAtLevel=1");
|
.contains("-XX:TieredStopAtLevel=1");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
assertThat(result.getOutput()).contains("-Dcom.bar=baz").contains("-Dcom.foo=bar").contains("-Xverify:none")
|
|
||||||
.contains("-XX:TieredStopAtLevel=1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestTemplate
|
@TestTemplate
|
||||||
void jarTypeFilteringIsAppliedToTheClasspath() throws IOException {
|
void jarTypeFilteringIsAppliedToTheClasspath() throws IOException {
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.springframework.boot.maven;
|
package org.springframework.boot.maven;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.TestTemplate;
|
import org.junit.jupiter.api.TestTemplate;
|
||||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||||
@ -38,8 +37,7 @@ class RunIntegrationTests {
|
|||||||
@TestTemplate
|
@TestTemplate
|
||||||
void whenTheRunGoalIsExecutedTheApplicationIsForkedWithOptimizedJvmArguments(MavenBuild mavenBuild) {
|
void whenTheRunGoalIsExecutedTheApplicationIsForkedWithOptimizedJvmArguments(MavenBuild mavenBuild) {
|
||||||
mavenBuild.project("run").goals("spring-boot:run", "-X").execute((project) -> {
|
mavenBuild.project("run").goals("spring-boot:run", "-X").execute((project) -> {
|
||||||
String jvmArguments = isJava13OrLater() ? "JVM argument(s): -XX:TieredStopAtLevel=1"
|
String jvmArguments = "JVM argument(s): -XX:TieredStopAtLevel=1";
|
||||||
: "JVM argument(s): -Xverify:none -XX:TieredStopAtLevel=1";
|
|
||||||
assertThat(buildLog(project)).contains("I haz been run").contains(jvmArguments);
|
assertThat(buildLog(project)).contains("I haz been run").contains(jvmArguments);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -136,13 +134,4 @@ class RunIntegrationTests {
|
|||||||
return contentOf(new File(project, "target/build.log"));
|
return contentOf(new File(project, "target/build.log"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isJava13OrLater() {
|
|
||||||
for (Method method : String.class.getMethods()) {
|
|
||||||
if (method.getName().equals("stripIndent")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.springframework.boot.maven;
|
package org.springframework.boot.maven;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -56,22 +55,10 @@ public class RunMojo extends AbstractApplicationRunMojo {
|
|||||||
RunArguments jvmArguments = super.resolveJvmArguments();
|
RunArguments jvmArguments = super.resolveJvmArguments();
|
||||||
if (this.optimizedLaunch) {
|
if (this.optimizedLaunch) {
|
||||||
jvmArguments.getArgs().addFirst("-XX:TieredStopAtLevel=1");
|
jvmArguments.getArgs().addFirst("-XX:TieredStopAtLevel=1");
|
||||||
if (!isJava13OrLater()) {
|
|
||||||
jvmArguments.getArgs().addFirst("-Xverify:none");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return jvmArguments;
|
return jvmArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isJava13OrLater() {
|
|
||||||
for (Method method : String.class.getMethods()) {
|
|
||||||
if (method.getName().equals("stripIndent")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void run(File workingDirectory, List<String> args, Map<String, String> environmentVariables)
|
protected void run(File workingDirectory, List<String> args, Map<String, String> environmentVariables)
|
||||||
throws MojoExecutionException {
|
throws MojoExecutionException {
|
||||||
|
@ -11,10 +11,8 @@ dependencies {
|
|||||||
|
|
||||||
runtimeOnly("jaxen:jaxen")
|
runtimeOnly("jaxen:jaxen")
|
||||||
runtimeOnly("wsdl4j:wsdl4j")
|
runtimeOnly("wsdl4j:wsdl4j")
|
||||||
if (JavaVersion.current().java11Compatible) {
|
|
||||||
runtimeOnly("jakarta.activation:jakarta.activation-api")
|
runtimeOnly("jakarta.activation:jakarta.activation-api")
|
||||||
runtimeOnly("org.glassfish.jaxb:jaxb-runtime")
|
runtimeOnly("org.glassfish.jaxb:jaxb-runtime")
|
||||||
}
|
|
||||||
|
|
||||||
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||||
testImplementation("org.springframework.ws:spring-ws-test")
|
testImplementation("org.springframework.ws:spring-ws-test")
|
||||||
|
Loading…
Reference in New Issue
Block a user