mirror of
https://github.com/corda/corda.git
synced 2025-02-15 15:12:46 +00:00
159 lines
4.4 KiB
Groovy
159 lines
4.4 KiB
Groovy
description 'Package Node as stand-alone application'
|
|
|
|
evaluationDependsOn(":node")
|
|
evaluationDependsOn(":docs")
|
|
evaluationDependsOn(":launcher")
|
|
|
|
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')
|
|
}
|
|
}
|
|
readmeFiles {
|
|
resources {
|
|
srcDir file('src/main/resources/readme')
|
|
}
|
|
}
|
|
}
|
|
|
|
// Runtime dependencies of launcher
|
|
dependencies {
|
|
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"
|
|
}
|
|
|
|
task copyLauncherLibs(type: Copy, dependsOn: [project(':launcher').jar]) {
|
|
from configurations.launcherClasspath
|
|
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 relativeDir
|
|
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=${project(':launcher').loaderClassName}"
|
|
]
|
|
|
|
ext {
|
|
launcherBinDir = "${tmpDir}/bundles/$relativeDir"
|
|
}
|
|
|
|
workingDir project.projectDir
|
|
|
|
doFirst {
|
|
def launcherLib = copyLauncherLibs.destinationDir
|
|
def srcfiles = []
|
|
def launcherClasspath = []
|
|
|
|
fileTree(launcherLib).forEach({ file ->
|
|
srcfiles.add("-srcfiles")
|
|
srcfiles.add(file.name)
|
|
launcherClasspath.add(file.name)
|
|
})
|
|
|
|
commandLine = [
|
|
'javapackager',
|
|
'-deploy',
|
|
'-nosign',
|
|
'-native', 'image',
|
|
'-outdir', "$tmpDir",
|
|
'-outfile', 'launcher',
|
|
'-name', 'launcher',
|
|
"-BmainJar=${project(':launcher').jar.archiveName}",
|
|
"-Bclasspath=${launcherClasspath.join(":")}",
|
|
'-appclass', "${project(':launcher').launcherClassName}",
|
|
'-srcdir', "$launcherLib"
|
|
] + srcfiles + extraArgs
|
|
}
|
|
|
|
// Add configuration for running Node application
|
|
doLast {
|
|
def nodeClasspath = []
|
|
def libRelPath = "../lib/"
|
|
|
|
project(':node').configurations.runtime.forEach({ file ->
|
|
nodeClasspath.add(file.getName())
|
|
})
|
|
|
|
nodeClasspath.add(project(':node').jar.archivePath.getName())
|
|
|
|
new File("${launcherBinDir}/runtime.properties").text = [
|
|
"libpath=${libRelPath}",
|
|
"classpath=${nodeClasspath.join(':')}",
|
|
"plugins=./drivers:./cordapps"].join("\n")
|
|
}
|
|
}
|
|
|
|
task buildNode(type: Copy, dependsOn: [buildLauncher, project(':docs').tasks['makeDocs']]) {
|
|
description 'Build stand-alone Corda Node distribution'
|
|
|
|
into(outputDir)
|
|
|
|
from(buildLauncher.launcherBinDir) {
|
|
into("launcher")
|
|
}
|
|
|
|
from(project(':node').configurations.runtime) {
|
|
into("lib")
|
|
}
|
|
|
|
from(project(':node').jar.archivePath) {
|
|
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()
|
|
new File("${outputDir}/drivers").mkdirs()
|
|
println ("Stand-alone Corda Node application available at:")
|
|
println ("${outputDir}")
|
|
}
|
|
}
|
|
|