Ensure a DemoBench installation is relocatable.

This commit is contained in:
Chris Rankin 2017-02-07 19:38:25 +00:00
parent d57f7cd557
commit 006fd98a51
8 changed files with 34 additions and 20 deletions

View File

@ -78,7 +78,10 @@ configurations.all {
jar { jar {
manifest { manifest {
attributes 'Main-Class': mainClassName attributes(
'Main-Class': mainClassName,
'Class-Path': configurations.compile.collect { it.getName() }.join(' ')
)
} }
} }

View File

@ -35,7 +35,18 @@ import tornadofx.addStageIcon
*/ */
class DemoBench : App(DemoBenchView::class) { class DemoBench : App(DemoBenchView::class) {
/*
* This entry point is needed by JavaPackager, as
* otherwise the packaged application cannot run.
*/
companion object {
@JvmStatic
fun main(args: Array<String>) = launch(DemoBench::class.java, *args)
}
init { init {
addStageIcon(Image("r3logo.png")) addStageIcon(Image("r3logo.png"))
} }
} }

View File

@ -6,7 +6,7 @@ import java.nio.file.Paths
class ExplorerController : Controller() { class ExplorerController : Controller() {
private val jvm by inject<JVMConfig>() private val jvm by inject<JVMConfig>()
private val explorerPath = Paths.get("explorer", "node-explorer.jar").toAbsolutePath() private val explorerPath = jvm.applicationDir.resolve("explorer").resolve("node-explorer.jar")
init { init {
log.info("Explorer JAR: " + explorerPath) log.info("Explorer JAR: " + explorerPath)

View File

@ -6,7 +6,9 @@ import tornadofx.Controller
class JVMConfig : Controller() { class JVMConfig : Controller() {
val userHome: Path = Paths.get(System.getProperty("user.home")).toAbsolutePath()
val javaPath: Path = Paths.get(System.getProperty("java.home"), "bin", "java") val javaPath: Path = Paths.get(System.getProperty("java.home"), "bin", "java")
val applicationDir = Paths.get(System.getProperty("user.dir")).toAbsolutePath()
init { init {
log.info("Java executable: " + javaPath) log.info("Java executable: " + javaPath)
@ -20,4 +22,5 @@ class JVMConfig : Controller() {
return Runtime.getRuntime().exec(commandFor(jarPath, *args)) return Runtime.getRuntime().exec(commandFor(jarPath, *args))
} }
} }

View File

@ -11,17 +11,20 @@ import net.corda.demobench.pty.R3Pty
import tornadofx.Controller import tornadofx.Controller
class NodeController : Controller() { class NodeController : Controller() {
companion object Data { private companion object Data {
private const val FIRST_PORT = 10000 const val FIRST_PORT = 10000
} }
private val baseDir = Paths.get("work", localDir).toAbsolutePath()
private val pluginDir = Paths.get("plugins").toAbsolutePath()
private val jvm by inject<JVMConfig>() private val jvm by inject<JVMConfig>()
private val localDir = SimpleDateFormat("yyyyMMddHHmmss")
.format(Date(ManagementFactory.getRuntimeMXBean().startTime))
private val baseDir = jvm.userHome.resolve("demobench").resolve(localDir)
private val pluginDir = jvm.applicationDir.resolve("plugins")
private val bankOfCorda = pluginDir.resolve("bank-of-corda.jar").toFile() private val bankOfCorda = pluginDir.resolve("bank-of-corda.jar").toFile()
private val cordaPath = Paths.get("corda", "corda.jar").toAbsolutePath() private val cordaPath = jvm.applicationDir.resolve("corda").resolve("corda.jar")
private val command = jvm.commandFor(cordaPath) private val command = jvm.commandFor(cordaPath)
private val renderOptions = ConfigRenderOptions.defaults().setOriginComments(false) private val renderOptions = ConfigRenderOptions.defaults().setOriginComments(false)
@ -102,8 +105,4 @@ class NodeController : Controller() {
} }
} }
private val localDir: String
get() = SimpleDateFormat("yyyyMMddHHmmss")
.format(Date(ManagementFactory.getRuntimeMXBean().startTime))
} }

View File

@ -29,6 +29,8 @@ class NodeRPC(config: NodeConfig, invoke: (CordaRPCOps) -> Unit): AutoCloseable
// Cancel the "setup" task now that we've created the RPC client. // Cancel the "setup" task now that we've created the RPC client.
this.cancel() this.cancel()
log.info("Node '{}' is now ready.", config.legalName)
// Schedule a new task that will refresh the display once per second. // Schedule a new task that will refresh the display once per second.
timer.schedule(object: TimerTask() { timer.schedule(object: TimerTask() {
override fun run() { override fun run() {

View File

@ -117,13 +117,9 @@ class NodeTerminalView : Fragment() {
} }
class TerminalSettingsProvider : DefaultSettingsProvider() { class TerminalSettingsProvider : DefaultSettingsProvider() {
override fun getDefaultStyle(): TextStyle { override fun getDefaultStyle() = TextStyle(TerminalColor.WHITE, TerminalColor.BLACK)
return TextStyle(TerminalColor.WHITE, TerminalColor.BLACK)
}
override fun emulateX11CopyPaste(): Boolean { override fun emulateX11CopyPaste() = true
return true
}
} }
} }

View File

@ -3,7 +3,7 @@
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/> <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> <appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>demobench.log</file> <file>${user.home}/demobench.log</file>
<append>false</append> <append>false</append>
<encoder> <encoder>
<pattern>%date %-5level %c{1} - %msg%n</pattern> <pattern>%date %-5level %c{1} - %msg%n</pattern>
@ -13,4 +13,4 @@
<root level="info"> <root level="info">
<appender-ref ref="FILE" /> <appender-ref ref="FILE" />
</root> </root>
</configuration> </configuration>