Skip to content

Commit 044758e

Browse files
committed
Fix defaultJavaLauncher fallback logic when JavaPluginExtension is not present
1 parent 5d5a791 commit 044758e

File tree

1 file changed

+7
-6
lines changed
  • paperweight-lib/src/main/kotlin/io/papermc/paperweight/util

1 file changed

+7
-6
lines changed

paperweight-lib/src/main/kotlin/io/papermc/paperweight/util/utils.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,13 @@ fun ByteArray.asHexString(): String {
379379
}
380380

381381
fun JavaToolchainService.defaultJavaLauncher(project: Project): Provider<JavaLauncher> {
382-
return launcherFor(project.extensions.getByType<JavaPluginExtension>().toolchain).orElse(
383-
launcherFor {
384-
// If the java plugin isn't applied, or no toolchain value was set
385-
languageVersion.set(JavaLanguageVersion.of(21))
386-
}
387-
)
382+
// If the java plugin isn't applied, or no toolchain value was set
383+
val fallback = launcherFor {
384+
languageVersion.set(JavaLanguageVersion.of(21))
385+
}
386+
387+
val ext = project.extensions.findByType<JavaPluginExtension>() ?: return fallback
388+
return launcherFor(ext.toolchain).orElse(fallback)
388389
}
389390

390391
fun <P : Property<*>> P.withDisallowChanges(): P = apply { disallowChanges() }

0 commit comments

Comments
 (0)