From b2bc41132199075d935f1d69c63c015c8294f4c7 Mon Sep 17 00:00:00 2001 From: Stefano Franz Date: Fri, 18 May 2018 18:08:42 +0100 Subject: [PATCH] fix build issue on windows --- node/dist/build.gradle | 196 ++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 99 deletions(-) diff --git a/node/dist/build.gradle b/node/dist/build.gradle index 920e5c3e00..af0cda99c7 100644 --- a/node/dist/build.gradle +++ b/node/dist/build.gradle @@ -46,114 +46,112 @@ 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) { + println("Detected *nix system, enabling distribution creation") + 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') + def relativeDir + if (isLinux) + relativeDir = "launcher" + else + relativeDir = "launcher.app/Contents" - if (!isLinux && !isMac) - throw new GradleException("Preparing distribution package is currently only supported on Linux/Mac") + 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}" + ] - def relativeDir - if (isLinux) - relativeDir = "launcher" - else - relativeDir = "launcher.app/Contents" + ext { + launcherBinDir = "${tmpDir}/bundles/$relativeDir" + } - 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}" - ] + workingDir project.projectDir - ext { - launcherBinDir = "${tmpDir}/bundles/$relativeDir" + 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") + } } - workingDir project.projectDir + task buildNode(type: Copy, dependsOn: [buildLauncher, project(':docs').tasks['makeDocs'], project(':node').tasks['jar']]) { + description 'Build stand-alone Corda Node distribution' - doFirst { - def launcherLib = copyLauncherLibs.destinationDir - def srcfiles = [] - def launcherClasspath = [] + into(outputDir) - fileTree(launcherLib).forEach({ file -> - srcfiles.add("-srcfiles") - srcfiles.add(file.name) - launcherClasspath.add(file.name) - }) + from(buildLauncher.launcherBinDir) { + into("launcher") + } - 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") + 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}") + } } +}else{ + println("Not running on *nix, disabling distribution generation") } - -task buildNode(type: Copy, dependsOn: [buildLauncher, project(':docs').tasks['makeDocs'], project(':node').tasks['jar']]) { - 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}") - } -} -