Skip to content

Commit ff4bc73

Browse files
Make all bootRun tasks run with the configured toolchain
1 parent c314aa9 commit ff4bc73

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

build.gradle

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.springframework.boot.gradle.tasks.run.BootRun
2+
13
plugins {
24
id 'java'
35
id 'java-test-fixtures'
@@ -23,7 +25,14 @@ java {
2325
}
2426
}
2527

26-
tasks.register("keycloakBootRun", org.springframework.boot.gradle.tasks.run.BootRun.class) {
28+
// Configure all bootRun tasks to use the toolchain from above
29+
tasks.withType(BootRun.class).configureEach {
30+
var toolchain = project.extensions.getByType(JavaPluginExtension.class).toolchain;
31+
var toolchainService = project.extensions.getByType(JavaToolchainService.class);
32+
it.javaLauncher.convention(toolchainService.launcherFor(toolchain))
33+
}
34+
35+
tasks.register("keycloakBootRun", BootRun.class) {
2736
description = "Runs the Spring Boot application with the Keycloak profile"
2837
group = ApplicationPlugin.APPLICATION_GROUP
2938
classpath = tasks.bootRun.classpath
@@ -32,7 +41,7 @@ tasks.register("keycloakBootRun", org.springframework.boot.gradle.tasks.run.Boo
3241
systemProperty("spring.profiles.active", "bootRun,keycloak")
3342
}
3443

35-
tasks.register("consoleBootRun", org.springframework.boot.gradle.tasks.run.BootRun.class) {
44+
tasks.register("consoleBootRun", BootRun.class) {
3645
description = "Runs the Spring Boot application with routing config for ContentGrid Console development"
3746
group = ApplicationPlugin.APPLICATION_GROUP
3847
classpath = tasks.bootRun.classpath
@@ -41,7 +50,7 @@ tasks.register("consoleBootRun", org.springframework.boot.gradle.tasks.run.Boot
4150
systemProperty("spring.profiles.active", "bootRun,console")
4251
}
4352

44-
tasks.register("runtimeBootRun", org.springframework.boot.gradle.tasks.run.BootRun.class) {
53+
tasks.register("runtimeBootRun", BootRun.class) {
4554
description = "Runs ContentGrid Gateway with config for ContentGrid Runtime Platform"
4655
group = ApplicationPlugin.APPLICATION_GROUP
4756
classpath = tasks.bootRun.classpath

0 commit comments

Comments
 (0)