mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Merge pull request #776 from corda/clint-cordformwinfix
Fixed noderunner issues on Windows by fixing a windows specific path...
This commit is contained in:
commit
fd9ee1c3bf
@ -1,4 +1,4 @@
|
|||||||
gradlePluginsVersion=0.12.2
|
gradlePluginsVersion=0.12.3
|
||||||
kotlinVersion=1.1.2
|
kotlinVersion=1.1.2
|
||||||
guavaVersion=21.0
|
guavaVersion=21.0
|
||||||
bouncycastleVersion=1.56
|
bouncycastleVersion=1.56
|
||||||
|
@ -3,6 +3,7 @@ package net.corda.plugins
|
|||||||
import java.awt.GraphicsEnvironment
|
import java.awt.GraphicsEnvironment
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Path
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
private val HEADLESS_FLAG = "--headless"
|
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>) {
|
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 {
|
internal val command: List<String> = mutableListOf<String>().apply {
|
||||||
add(File(File(System.getProperty("java.home"), "bin"), "java").path)
|
add(getJavaPath())
|
||||||
add("-Dname=$nodeName")
|
add("-Dname=$nodeName")
|
||||||
null != debugPort && add("-Dcapsule.jvm.args=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$debugPort")
|
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()
|
init()
|
||||||
addAll(args)
|
addAll(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal abstract fun processBuilder(): ProcessBuilder
|
internal abstract fun processBuilder(): ProcessBuilder
|
||||||
internal fun start() = processBuilder().directory(dir).start()
|
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) {
|
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 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) {
|
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(" ")
|
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.
|
private fun quotedFormOf(text: String) = "'${text.replace("'", "'\\''")}'" // Suitable for UNIX shells.
|
||||||
|
Loading…
Reference in New Issue
Block a user