diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/run/BootRun.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/run/BootRun.java index 3769e1ffcd..dc0572eda6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/run/BootRun.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/run/BootRun.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,12 @@ import java.lang.reflect.Method; import java.util.Set; import org.gradle.api.file.SourceDirectorySet; +import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.JavaExec; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetOutput; +import org.gradle.jvm.toolchain.JavaLauncher; /** * Custom {@link JavaExec} task for running a Spring Boot application. @@ -87,6 +89,15 @@ public class BootRun extends JavaExec { } private boolean isJava13OrLater() { + try { + Property javaLauncher = this.getJavaLauncher(); + if (javaLauncher.isPresent()) { + return javaLauncher.get().getMetadata().getLanguageVersion().asInt() >= 13; + } + } + catch (NoSuchMethodError ex) { + // Continue + } for (Method method : String.class.getMethods()) { if (method.getName().equals("stripIndent")) { return true;