Merge pull request #776 from corda/clint-cordformwinfix

Fixed noderunner issues on Windows by fixing a windows specific path...
This commit is contained in:
Clinton 2017-06-02 14:40:31 +01:00 committed by GitHub
commit fd9ee1c3bf
2 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,4 @@
gradlePluginsVersion=0.12.2
gradlePluginsVersion=0.12.3
kotlinVersion=1.1.2
guavaVersion=21.0
bouncycastleVersion=1.56

View File

@ -3,6 +3,7 @@ package net.corda.plugins
import java.awt.GraphicsEnvironment
import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.util.*
private val HEADLESS_FLAG = "--headless"
@ -64,20 +65,23 @@ private object WebJarType : JarType("corda-webserver.jar") {
private abstract class JavaCommand(jarName: String, internal val dir: File, debugPort: Int?, internal val nodeName: String, init: MutableList<String>.() -> Unit, args: List<String>) {
internal val command: List<String> = mutableListOf<String>().apply {
add(File(File(System.getProperty("java.home"), "bin"), "java").path)
add(getJavaPath())
add("-Dname=$nodeName")
null != debugPort && add("-Dcapsule.jvm.args=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$debugPort")
add("-jar"); add(jarName)
add("-jar")
add(jarName)
init()
addAll(args)
}
internal abstract fun processBuilder(): ProcessBuilder
internal fun start() = processBuilder().directory(dir).start()
internal abstract fun getJavaPath(): String
}
private class HeadlessJavaCommand(jarName: String, dir: File, debugPort: Int?, args: List<String>) : JavaCommand(jarName, dir, debugPort, dir.name, { add("--no-local-shell") }, args) {
override fun processBuilder() = ProcessBuilder(command).redirectError(File("error.$nodeName.log")).inheritIO()
override fun getJavaPath() = File(File(System.getProperty("java.home"), "bin"), "java").path
}
private class TerminalWindowJavaCommand(jarName: String, dir: File, debugPort: Int?, args: List<String>) : JavaCommand(jarName, dir, debugPort, "${dir.name}-$jarName", {}, args) {
@ -105,6 +109,12 @@ end tell""")
})
private fun unixCommand() = command.map(::quotedFormOf).joinToString(" ")
override fun getJavaPath(): String {
val path = File(File(System.getProperty("java.home"), "bin"), "java").path
// Replace below is to fix an issue with spaces in paths on Windows.
// Quoting the entire path does not work, only the space or directory within the path.
return if(os == OS.WINDOWS) path.replace(" ", "\" \"") else path
}
}
private fun quotedFormOf(text: String) = "'${text.replace("'", "'\\''")}'" // Suitable for UNIX shells.