Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 5fe1d31

Browse files
committed
More debug logging
1 parent d32defa commit 5fe1d31

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/main/kotlin/nebula/plugin/compile/JavaCrossCompilePlugin.kt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.gradle.api.plugins.JavaPluginConvention
1010
import org.gradle.api.tasks.compile.GroovyCompile
1111
import org.gradle.api.tasks.compile.JavaCompile
1212
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
13+
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
1314
import org.slf4j.Logger
1415
import org.slf4j.LoggerFactory
1516
import java.io.File
@@ -53,18 +54,30 @@ class JavaCrossCompilePlugin : Plugin<Project> {
5354
private fun JavaVersion.locate(): JavaLocation {
5455
logger.debug("Locating JDK for $this")
5556
val jdkHome = providers
56-
.map { it.provide(this) }
57-
.firstOrNull() ?: throw cannotLocate()
57+
.firstNotNullResult {
58+
val jdkHome = it.provide(this)
59+
if (jdkHome == null) {
60+
logger.debug("Provider $it did not find a JDK")
61+
null
62+
} else {
63+
logger.debug("Provider $it found a JDK at $jdkHome")
64+
jdkHome
65+
}
66+
} ?: throw cannotLocate()
5867
logger.debug("Found JDK for $this at $jdkHome")
5968
val runtimeJars = listOf(
6069
File(jdkHome, RT_JAR_PATH),
6170
File(jdkHome, CLASSES_JAR_PATH)
6271
)
6372
val bootClasspath = runtimeJars
64-
.firstOrNull {
65-
val exists = it.exists()
66-
if (exists) logger.debug("Found runtime classes jar $it") else logger.debug("Runtime classes jar $it does not exist")
67-
exists
73+
.firstNotNullResult {
74+
if (it.exists()) {
75+
logger.debug("Found runtime classes jar $it")
76+
it
77+
} else {
78+
logger.debug("Runtime classes jar $it does not exist")
79+
null
80+
}
6881
} ?: throw cannotLocate()
6982
return JavaLocation(jdkHome, bootClasspath.absolutePath)
7083
}

0 commit comments

Comments
 (0)