From 78ff26e5292f03eeb27bff0be1e185c52f116358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Guti=C3=A9rrez?= Date: Tue, 4 Jun 2019 08:17:45 +0200 Subject: [PATCH] Improve the installerBuild task to produce the installers (#467) * Improve the installerBuild task to produce the installers - Now the Gradle task will automate the generation of all the installer if the installBuilderHome variable is set --- .../opendatakit/aggregate/gradle/Util.groovy | 18 ++++++++++++++++++ gradle.properties.example | 3 +++ installer.gradle | 19 ++++++++++++++++++- installer/project/buildWar.xml | 2 ++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/opendatakit/aggregate/gradle/Util.groovy b/buildSrc/src/main/groovy/org/opendatakit/aggregate/gradle/Util.groovy index fc6b3a168d..013d7d5ac6 100644 --- a/buildSrc/src/main/groovy/org/opendatakit/aggregate/gradle/Util.groovy +++ b/buildSrc/src/main/groovy/org/opendatakit/aggregate/gradle/Util.groovy @@ -46,4 +46,22 @@ class Util { return obj.getProperty(key) return defaultValue } + + static void run(String... command) { + def proc = command.execute() + def b = new StringBuffer() + proc.consumeProcessErrorStream(b) + + println proc.text + println b.toString() + } + + static void runInWorkingDir(wd, String... command) { + def proc = command.execute(null, new File(wd.toString())) + def b = new StringBuffer() + proc.consumeProcessErrorStream(b) + + println proc.text + println b.toString() + } } diff --git a/gradle.properties.example b/gradle.properties.example index 84fdaaa4e4..7a3a2a5b59 100644 --- a/gradle.properties.example +++ b/gradle.properties.example @@ -2,3 +2,6 @@ #packerZip=https://releases.hashicorp.com/packer/1.3.4/packer_1.3.4_linux_amd64.zip #packerZip=https://releases.hashicorp.com/packer/1.3.4/packer_1.3.4_windows_amd64.zip #packerZip=https://releases.hashicorp.com/packer/1.3.4/packer_1.3.4_darwin_amd64.zip + +#Uncomment and set the path to the installBuilder installation directory +#installBuilderHome=/opt/installbuilder-18.10.0 diff --git a/installer.gradle b/installer.gradle index f6880f9a22..5fa93c9452 100644 --- a/installer.gradle +++ b/installer.gradle @@ -1,7 +1,8 @@ -import static org.opendatakit.aggregate.gradle.Util.setXmlValue +import static org.opendatakit.aggregate.gradle.Util.* task installerClean() { delete 'build/installer' + delete 'build/installers' } task installerBuild(dependsOn: [installerClean], type: Copy) { @@ -24,5 +25,21 @@ task installerBuild(dependsOn: [installerClean], type: Copy) { doLast { setXmlValue("${buildDir}/installer/buildWar.xml", "version", version) file("${buildDir}/installer/files/${archivesBaseName}-${version}.war").renameTo(file("build/installer/files/ODKAggregate.war")) + + if (installBuilderHome != null) { + run("mkdir", "${buildDir}/installers") + setXmlValue("${buildDir}/installer/buildWar.xml", "outputDirectory", "${buildDir}/installers") + + [["linux-x64", "Linux-x64.run"], + ["linux", "Linux.run"], + ["windows", "Windows.exe"], + ["osx", "macOS.app"] + ].forEach({ pair -> + setXmlValue("${buildDir}/installer/buildWar.xml", "installerFilename", "ODK-Aggregate-${version}-${pair[1]}") + run("${installBuilderHome}/bin/builder", "build", "${buildDir}/installer/buildWar.xml", "${pair[0]}") + runInWorkingDir("${buildDir}/installers", "zip", "-r", "ODK-Aggregate-${version}-${pair[1]}.zip", "ODK-Aggregate-${version}-${pair[1]}") + runInWorkingDir("${buildDir}/installers", "rm", "-r", "ODK-Aggregate-${version}-${pair[1]}") + }) + } } } diff --git a/installer/project/buildWar.xml b/installer/project/buildWar.xml index 31f35a76b1..61c41bd24c 100644 --- a/installer/project/buildWar.xml +++ b/installer/project/buildWar.xml @@ -34,5 +34,7 @@ + ${product_shortname}-${product_version}-${platform_name}-installer.${platform_exec_suffix} + /tmp