mirror of
https://github.com/corda/corda.git
synced 2025-02-14 14:42:32 +00:00
Some Gradle refactoring
This commit is contained in:
parent
bc3facaed9
commit
18cc1bbb0c
@ -9,65 +9,11 @@ dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
}
|
||||
|
||||
ext {
|
||||
loaderClassName = "net.corda.launcher.Loader"
|
||||
launcherClassName = "net.corda.launcher.Launcher"
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName 'corda-launcher'
|
||||
}
|
||||
|
||||
//task gatherDependencies(type: Copy, dependsOn: jar) {
|
||||
// from configurations.runtime
|
||||
// from jar
|
||||
// into "$buildDir/bin/lib"
|
||||
//}
|
||||
//
|
||||
//def launcherOutputDir = null
|
||||
//
|
||||
//task makeExecutable(type: Exec, dependsOn: [gatherDependencies]) {
|
||||
// def isLinux = System.properties['os.name'].toLowerCase().contains('linux')
|
||||
// def isMac = System.properties['os.name'].toLowerCase().contains('mac')
|
||||
//
|
||||
// if (!isLinux && !isMac)
|
||||
// throw new GradleException("Preparing distribution package is currently only supported on Linux/Mac")
|
||||
//
|
||||
// def distributionDir = "${buildDir}/tmp/"
|
||||
// if (isLinux) launcherOutputDir = "${distributionDir}/bundles/launcher/"
|
||||
// else launcherOutputDir = "${distributionDir}/bundles/launcher.app/Contents"
|
||||
//
|
||||
// def classPath = []
|
||||
//
|
||||
// workingDir project.projectDir
|
||||
//
|
||||
// def extraArgs = [
|
||||
// "-BjvmOptions=-javaagent:quasar-core-${quasar_version}-jdk8.jar=${project(':node:capsule').quasarExcludeExpression}",
|
||||
// '-BuserJvmOptions=-Xmx=4g',
|
||||
// '-BuserJvmOptions=-XX\\:=+UseG1GC',
|
||||
// '-BjvmProperties=java.system.class.loader=net.corda.launcher.Loader'
|
||||
// ]
|
||||
//
|
||||
// doFirst {
|
||||
// def dependencies = []
|
||||
//
|
||||
// fileTree(gatherDependencies.destinationDir).forEach({ file ->
|
||||
// classPath.add("../../lib/" + file.getName())
|
||||
// })
|
||||
//
|
||||
// commandLine = [
|
||||
// 'javapackager',
|
||||
// '-deploy',
|
||||
// '-nosign',
|
||||
// '-native', 'image',
|
||||
// '-outdir', "$distributionDir",
|
||||
// '-outfile', 'launcher',
|
||||
// '-name', 'launcher',
|
||||
// "-BmainJar=${jar.archiveName}",
|
||||
// "-Bclasspath=${classPath.join(":")}",
|
||||
// '-appclass', 'net.corda.launcher.Launcher',
|
||||
// '-srcdir', "${gatherDependencies.destinationDir}",
|
||||
// '-srcfiles', "${jar.archiveName}"
|
||||
// ] + extraArgs
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//task exportLauncher(type: Copy, dependsOn: makeExecutable ) {
|
||||
// from launcherOutputDir into "${buildDir}/bin"
|
||||
//}
|
||||
|
||||
|
@ -11,7 +11,7 @@ fun main(args: Array<String>) {
|
||||
val sysClassLoader = ClassLoader.getSystemClassLoader()
|
||||
|
||||
val appClassLoader = (sysClassLoader as? Loader) ?: {
|
||||
println("WARNING: failed to overried system classloader")
|
||||
println("WARNING: failed to override system classloader")
|
||||
Loader(sysClassLoader)
|
||||
} ()
|
||||
|
||||
@ -36,8 +36,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
appClassLoader.augmentClasspath(pluginURLs)
|
||||
|
||||
// Propagate current working directory, as workaround for javapackager
|
||||
// corrupting it
|
||||
// Propagate current working directory via system property, to patch it after javapackager
|
||||
System.setProperty("corda.launcher.cwd", nodeBaseDir.toString())
|
||||
System.setProperty("user.dir", nodeBaseDir.toString())
|
||||
|
||||
|
@ -3,8 +3,7 @@ package net.corda.launcher
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
|
||||
class Loader(parent: ClassLoader?):
|
||||
URLClassLoader(Settings.CLASSPATH.toTypedArray(), parent) {
|
||||
class Loader(parent: ClassLoader?): URLClassLoader(Settings.CLASSPATH.toTypedArray(), parent) {
|
||||
|
||||
fun augmentClasspath(urls: List<URL>) {
|
||||
urls.forEach { addURL(it) }
|
||||
|
@ -10,10 +10,11 @@ import kotlin.collections.HashSet
|
||||
|
||||
object Settings {
|
||||
|
||||
val CORDA_RUNTIME_SETTINGS = "../runtime.properties"
|
||||
val WORKING_DIR: Path
|
||||
val CLASSPATH: List<URL>
|
||||
val PLUGINS: List<Path>
|
||||
val CORDA_RUNTIME_SETTINGS = "../runtime.properties"
|
||||
val LIBPATH: Path
|
||||
|
||||
init {
|
||||
WORKING_DIR = Paths.get(System.getenv("CORDA_LAUNCHER_CWD") ?: "..")
|
||||
@ -24,15 +25,16 @@ object Settings {
|
||||
|
||||
CLASSPATH = parseClasspath(settings)
|
||||
PLUGINS = parsePlugins(settings)
|
||||
LIBPATH = Paths.get(settings.getProperty("libpath") ?: ".")
|
||||
}
|
||||
|
||||
private fun parseClasspath(config: Properties): List<URL> {
|
||||
val launcherDir = Paths.get("..").toAbsolutePath()
|
||||
val libDir = Paths.get("..").resolve(LIBPATH).toAbsolutePath()
|
||||
val cp = config.getProperty("classpath") ?:
|
||||
throw Error("Missing 'classpath' property from config")
|
||||
|
||||
return cp.split(':').map {
|
||||
launcherDir.resolve(it).toUri().toURL()
|
||||
libDir.resolve(it).toUri().toURL()
|
||||
}
|
||||
}
|
||||
|
||||
|
124
node/dist/build.gradle
vendored
124
node/dist/build.gradle
vendored
@ -1,37 +1,43 @@
|
||||
description 'Corda Node Executable Image'
|
||||
description 'Package Node as stand-alone application'
|
||||
|
||||
evaluationDependsOn(":node")
|
||||
evaluationDependsOn(":docs")
|
||||
evaluationDependsOn(":launcher")
|
||||
|
||||
def outputDir = "$buildDir/release"
|
||||
ext {
|
||||
outputDir = "$buildDir/corda"
|
||||
}
|
||||
|
||||
def tmpDir = "${buildDir}/tmp/"
|
||||
|
||||
configurations {
|
||||
launcherClasspath
|
||||
}
|
||||
|
||||
// Define location of predefined startup scripts, license and README files
|
||||
sourceSets {
|
||||
binFiles {
|
||||
resources {
|
||||
srcDir file('src/main/resources/bin')
|
||||
}
|
||||
}
|
||||
licenseFiles {
|
||||
readmeFiles {
|
||||
resources {
|
||||
srcDir file('src/main/resources/license')
|
||||
srcDir file('src/main/resources/readme')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Runtime dependencies of launcher
|
||||
dependencies {
|
||||
launcherClasspath "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
|
||||
launcherClasspath "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
launcherClasspath project(':launcher')
|
||||
launcherClasspath "org.slf4j:jul-to-slf4j:$slf4j_version"
|
||||
launcherClasspath "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
|
||||
launcherClasspath "org.apache.logging.log4j:log4j-web:${log4j_version}"
|
||||
|
||||
// Required by JVM agents:
|
||||
launcherClasspath "com.google.guava:guava:$guava_version"
|
||||
launcherClasspath "de.javakaffee:kryo-serializers:0.41"
|
||||
launcherClasspath project(':launcher')
|
||||
}
|
||||
|
||||
task copyLauncherLibs(type: Copy, dependsOn: [project(':launcher').jar]) {
|
||||
@ -39,41 +45,45 @@ task copyLauncherLibs(type: Copy, dependsOn: [project(':launcher').jar]) {
|
||||
into "$buildDir/tmp/launcher-lib"
|
||||
}
|
||||
|
||||
// The launcher building is done as it depends on application-specific settings which
|
||||
// cannot be overridden later
|
||||
task buildLauncher(type: Exec, dependsOn: [copyLauncherLibs]) {
|
||||
description 'Build Launcher executable'
|
||||
|
||||
def isLinux = System.properties['os.name'].toLowerCase().contains('linux')
|
||||
def isMac = System.properties['os.name'].toLowerCase().contains('mac')
|
||||
|
||||
if (!isLinux && !isMac)
|
||||
throw new GradleException("Preparing distribution package is currently only supported on Linux/Mac")
|
||||
|
||||
def distributionDir = "${buildDir}/tmp/"
|
||||
|
||||
def relativeDir
|
||||
if (isLinux) relativeDir = "launcher"
|
||||
else relativeDir = "launcher.app/Contents"
|
||||
|
||||
ext {
|
||||
launcherBinDir = "${distributionDir}/bundles/$relativeDir"
|
||||
}
|
||||
|
||||
workingDir project.projectDir
|
||||
if (isLinux)
|
||||
relativeDir = "launcher"
|
||||
else
|
||||
relativeDir = "launcher.app/Contents"
|
||||
|
||||
def extraArgs = [
|
||||
"-BjvmOptions=-javaagent:../../lib/quasar-core-${quasar_version}-jdk8.jar=${project(':node:capsule').quasarExcludeExpression}",
|
||||
'-BuserJvmOptions=-Xmx=4g',
|
||||
'-BuserJvmOptions=-XX\\:=+UseG1GC',
|
||||
'-BjvmProperties=java.system.class.loader=net.corda.launcher.Loader'
|
||||
"-BjvmProperties=java.system.class.loader=${project(':launcher').loaderClassName}'}"
|
||||
]
|
||||
|
||||
ext {
|
||||
launcherBinDir = "${tmpDir}/bundles/$relativeDir"
|
||||
}
|
||||
|
||||
workingDir project.projectDir
|
||||
|
||||
doFirst {
|
||||
def launcherLib = copyLauncherLibs.destinationDir
|
||||
def srcfiles = []
|
||||
def classpath = []
|
||||
def launcherClasspath = []
|
||||
|
||||
fileTree(launcherLib).forEach({ file ->
|
||||
srcfiles.add("-srcfiles")
|
||||
srcfiles.add(file.name)
|
||||
classpath.add(file.name)
|
||||
launcherClasspath.add(file.name)
|
||||
})
|
||||
|
||||
commandLine = [
|
||||
@ -81,60 +91,62 @@ task buildLauncher(type: Exec, dependsOn: [copyLauncherLibs]) {
|
||||
'-deploy',
|
||||
'-nosign',
|
||||
'-native', 'image',
|
||||
'-outdir', "$distributionDir",
|
||||
'-outdir', "$tmpDir",
|
||||
'-outfile', 'launcher',
|
||||
'-name', 'launcher',
|
||||
"-BmainJar=${project(':launcher').jar.archiveName}",
|
||||
"-Bclasspath=${classpath.join(":")}",
|
||||
'-appclass', 'net.corda.launcher.Launcher',
|
||||
"-Bclasspath=${launcherClasspath.join(":")}",
|
||||
'-appclass', '${project(\':launcher\').launcherClassName}',
|
||||
'-srcdir', "$launcherLib"
|
||||
] + srcfiles + extraArgs
|
||||
}
|
||||
}
|
||||
|
||||
task installNodeLib(type: Copy, dependsOn: [project(':node').jar]) {
|
||||
from project(':node').configurations.runtime
|
||||
from project(':node').jar
|
||||
into "${outputDir}/lib"
|
||||
}
|
||||
|
||||
task installLauncher(type: Copy, dependsOn: [buildLauncher, installNodeLib]) {
|
||||
from buildLauncher.launcherBinDir
|
||||
into "${outputDir}/launcher"
|
||||
|
||||
// Add configuration for running Node application
|
||||
doLast {
|
||||
def classpath = []
|
||||
def nodeClasspath = []
|
||||
def libRelPath = "../lib/"
|
||||
|
||||
fileTree("${outputDir}/lib").forEach({ file ->
|
||||
classpath.add("../lib/" + file.getName())
|
||||
project(':node').configurations.runtime.forEach({ file ->
|
||||
nodeClasspath.add(file.getName())
|
||||
})
|
||||
|
||||
new File("${outputDir}/launcher/runtime.properties").text = [
|
||||
"classpath=${classpath.join(':')}",
|
||||
nodeClasspath.add(project(':node').jar.getName())
|
||||
|
||||
new File("${launcherBinDir}/runtime.properties").text = [
|
||||
"libpath=${libRelPath}",
|
||||
"classpath=${nodeClasspath.join(':')}",
|
||||
"plugins=./drivers:./cordapps"].join("\n")
|
||||
}
|
||||
}
|
||||
|
||||
task installStartupScripts(type: Copy) {
|
||||
from sourceSets.binFiles.resources
|
||||
into "$outputDir/bin"
|
||||
}
|
||||
task buildNode(type: Copy, dependsOn: [buildLauncher, project(':docs').tasks['makeDocs']]) {
|
||||
description 'Build stand-alone Corda Node distribution'
|
||||
|
||||
task installReadmeFiles(type: Copy) {
|
||||
from sourceSets.licenseFiles.resources
|
||||
into "$outputDir"
|
||||
}
|
||||
into(outputDir)
|
||||
|
||||
task installDocs(type: Copy, dependsOn: [project(':docs').tasks['makeDocs']]) {
|
||||
from(project(':docs').buildDir)
|
||||
into "$outputDir/docs"
|
||||
}
|
||||
from(buildLauncher.launcherBinDir) {
|
||||
into("launcher")
|
||||
}
|
||||
|
||||
task buildNode(dependsOn: [installLauncher,
|
||||
installNodeLib,
|
||||
installDocs,
|
||||
installStartupScripts,
|
||||
installReadmeFiles]) {
|
||||
from(project(':node').configurations.runtime) {
|
||||
into("lib")
|
||||
}
|
||||
|
||||
from(project(':node').jar) {
|
||||
into("lib")
|
||||
}
|
||||
|
||||
from(sourceSets.binFiles.resources) {
|
||||
into("bin")
|
||||
}
|
||||
|
||||
from(sourceSets.readmeFiles.resources) {
|
||||
into(".")
|
||||
}
|
||||
|
||||
from(project(':docs').buildDir) {
|
||||
into("docs")
|
||||
}
|
||||
|
||||
doLast {
|
||||
new File("${outputDir}/cordapps").mkdirs()
|
||||
|
@ -6,6 +6,4 @@ To start a node, please edit supplied node.conf file so it contains appropriate
|
||||
|
||||
Your CordApps should be placed in cordapps directory, from which they will be loaded automatically.
|
||||
|
||||
Linux:
|
||||
Main executable file is corda - run by simply ./corda
|
||||
MacOS: Main executable file is MacOS/corda - run simply by typing ./MacOS/corda
|
||||
Linux/Mac: main executable file is ./bin/corda
|
22
node/dist/src/main/resources/readme/example-node.conf
vendored
Normal file
22
node/dist/src/main/resources/readme/example-node.conf
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
myLegalName : "O=Bank A,L=London,C=GB"
|
||||
keyStorePassword : "cordacadevpass"
|
||||
trustStorePassword : "trustpass"
|
||||
dataSourceProperties : {
|
||||
dataSourceClassName : org.h2.jdbcx.JdbcDataSource
|
||||
"dataSource.url" : "jdbc:h2:file:"${baseDirectory}"/persistence"
|
||||
"dataSource.user" : sa
|
||||
"dataSource.password" : ""
|
||||
}
|
||||
p2pAddress : "my-corda-node:10002"
|
||||
rpcSettings = {
|
||||
useSsl = false
|
||||
standAloneBroker = false
|
||||
address : "my-corda-node:10003"
|
||||
adminAddress : "my-corda-node:10004"
|
||||
}
|
||||
webAddress : "localhost:10004"
|
||||
rpcUsers : [
|
||||
{ username=user1, password=letmein, permissions=[ StartFlow.net.corda.protocols.CashProtocol ] }
|
||||
]
|
||||
devMode : true
|
||||
// certificateSigningService : "https://testnet.certificate.corda.net"
|
@ -70,12 +70,10 @@ class NodeArgsParser : AbstractArgsParser<CmdLineOptions>() {
|
||||
}
|
||||
// Note: this is a workaround for javapackager misbehaving with cwd.
|
||||
// The correct working directory is propagated from launcher via system property.
|
||||
|
||||
val baseDirectory = System.getProperty("corda.launcher.cwd")?.let { Paths.get(it) }
|
||||
?: optionSet.valueOf(baseDirectoryArg)
|
||||
.normalize()
|
||||
.toAbsolutePath()
|
||||
|
||||
val configFile = baseDirectory / optionSet.valueOf(configFileArg)
|
||||
val loggingLevel = optionSet.valueOf(loggerLevel)
|
||||
val logToConsole = optionSet.has(logToConsoleArg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user