Skip to content

Commit

Permalink
More debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielThomas committed Jul 26, 2017
1 parent d32defa commit 5fe1d31
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/main/kotlin/nebula/plugin/compile/JavaCrossCompilePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.compile.GroovyCompile
import org.gradle.api.tasks.compile.JavaCompile
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.File
Expand Down Expand Up @@ -53,18 +54,30 @@ class JavaCrossCompilePlugin : Plugin<Project> {
private fun JavaVersion.locate(): JavaLocation {
logger.debug("Locating JDK for $this")
val jdkHome = providers
.map { it.provide(this) }
.firstOrNull() ?: throw cannotLocate()
.firstNotNullResult {
val jdkHome = it.provide(this)
if (jdkHome == null) {
logger.debug("Provider $it did not find a JDK")
null
} else {
logger.debug("Provider $it found a JDK at $jdkHome")
jdkHome
}
} ?: throw cannotLocate()
logger.debug("Found JDK for $this at $jdkHome")
val runtimeJars = listOf(
File(jdkHome, RT_JAR_PATH),
File(jdkHome, CLASSES_JAR_PATH)
)
val bootClasspath = runtimeJars
.firstOrNull {
val exists = it.exists()
if (exists) logger.debug("Found runtime classes jar $it") else logger.debug("Runtime classes jar $it does not exist")
exists
.firstNotNullResult {
if (it.exists()) {
logger.debug("Found runtime classes jar $it")
it
} else {
logger.debug("Runtime classes jar $it does not exist")
null
}
} ?: throw cannotLocate()
return JavaLocation(jdkHome, bootClasspath.absolutePath)
}
Expand Down

0 comments on commit 5fe1d31

Please sign in to comment.