Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
Improve the installerBuild task to produce the installers (#467)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ggalmazor authored Jun 4, 2019
1 parent be11e5b commit 78ff26e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
3 changes: 3 additions & 0 deletions gradle.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 18 additions & 1 deletion installer.gradle
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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]}")
})
}
}
}
2 changes: 2 additions & 0 deletions installer/project/buildWar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@
</customLanguageFileList>
<finalPageActionList>
</finalPageActionList>
<installerFilename>${product_shortname}-${product_version}-${platform_name}-installer.${platform_exec_suffix}</installerFilename>
<outputDirectory>/tmp</outputDirectory>
</project>

0 comments on commit 78ff26e

Please sign in to comment.