Commit 22f0579f authored by Drahomír Karchňák's avatar Drahomír Karchňák

#755 Added separated windows desktop builds for debug and release.

parent 1b02f57a
import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask
import groovy.io.FileType
/*
......@@ -148,66 +149,85 @@ def runItest(String iTestName) {
* Windows Desktop Version *
***************************/
//TODO - Separated debug and release builds
launch4j {
mainClassName = 'cz.nic.tablexia.desktop.DesktopLauncher'
icon = '../../assets/icons/desktop_icon_128.png.ico'
jar = '../libs/' + tablexiaAppName + '-release-' + tablexiaVersionName + '.jar'
outputDir = 'bin'
bundledJrePath = '../jre'
}
def download(String remoteUrl, String localUrl) {
new File("$localUrl").withOutputStream { out ->
new URL(remoteUrl).withInputStream { from -> out << from; }
}
}
task releaseExe(dependsOn: releaseJar, type: edu.sc.seis.launch4j.tasks.Launch4jLibraryTask) {
outfile = 'Tablexia.exe'
task handleJreTask() {
def jreFileName = '/jre.tar.gz'
doFirst {
def jreFileName = '/jre.tar.gz'
//TODO - Don't download JRE on every build??
//TODO - Building without internet connection (Providing JRE manually)
//Download JRE
download(project.property('TABLEXIA_JRE_DOWNLOAD_MIRROR'), project.buildDir.absolutePath + jreFileName)
//TODO - Don't download JRE on every build??
//TODO - Building without internet connection (Providing JRE manually)
//Download JRE
download(project.property('TABLEXIA_JRE_DOWNLOAD_MIRROR'), project.buildDir.absolutePath + jreFileName)
//Byte buffer to store stdout
def stdout = new ByteArrayOutputStream()
//Byte buffer to store stdout
def stdout = new ByteArrayOutputStream()
//Extract JRE to desktop/build/
exec {
commandLine 'tar', '-xf', project.buildDir.absolutePath + jreFileName, '-C', project.buildDir.absolutePath
standardOutput = stdout
}
//Extract JRE to desktop/build/
exec {
commandLine 'tar', '-xf', project.buildDir.absolutePath + jreFileName, '-C', project.buildDir.absolutePath
standardOutput = stdout
}
//print output of previous exec command
def output = stdout.toString().trim()
if(!output.isEmpty()) println output
}
//print output of previous exec command
def output = stdout.toString().trim()
if(!output.isEmpty()) println output
/**
* Task to create an exe file from jar
*/
class exeTask extends Launch4jLibraryTask {
@Input
String buildTypeInput = "debug" //Default value
@Override
def run() {
setMainClassName('cz.nic.tablexia.desktop.DesktopLauncher')
setOutputDir('bin')
setBundledJrePath('../jre')
setIcon('../../assets/icons/desktop_icon_' + buildTypeInput + '_128.png.ico')
setJar('../libs/' + project.tablexiaAppName + '-' + buildTypeInput + '-' + project.tablexiaVersionName + '.jar')
setOutfile('Tablexia.exe') //installer_script.nsi expects the file to be named like this.
return super.run()
}
}
doLast {
println "Create temporary folder for installer files"
/**
* This task takes /bin/Tablexia.exe and creates an installer file
*/
class SetupExeTask extends exeTask {
def log(String message) {
logger.lifecycle(':' + project.name + ':' + name + ' ' + message)
}
@TaskAction
def run() {
super.run();
log("Creating temporary folder for installer files")
def installerDir = new File(project.buildDir.absolutePath + '/installer')
if(installerDir.exists()) installerDir.mkdir()
println "Copying jre/ folder to temporary installer folder"
copy {
log("Copying jre/ folder to temporary installer folder")
project.copy {
from project.buildDir.absolutePath + '/jre'
into installerDir.absolutePath + '/jre'
}
println "Copying bin/ folder to temporary installer folder"
copy {
log("Copying bin/ folder to temporary installer folder")
project.copy {
from project.buildDir.absolutePath + '/bin'
into installerDir.absolutePath + '/bin'
}
println "Copying icon folder to temporary installer folder"
copy {
from project.projectDir.absolutePath + '/assets/icons/desktop_icon_128.png.ico'
log("Copying icon folder to temporary installer folder")
project.copy {
from project.projectDir.absolutePath + '/assets/icons/desktop_icon_' + buildTypeInput + '_128.png.ico'
into installerDir.absolutePath
rename '.*', 'logo.ico'
}
......@@ -215,7 +235,7 @@ task releaseExe(dependsOn: releaseJar, type: edu.sc.seis.launch4j.tasks.Launch4j
def stdout = new ByteArrayOutputStream()
//Launch makensis
exec {
project.exec {
commandLine 'makensis', 'installer_script.nsi'
standardOutput = stdout
}
......@@ -224,32 +244,49 @@ task releaseExe(dependsOn: releaseJar, type: edu.sc.seis.launch4j.tasks.Launch4j
def output = stdout.toString().trim()
if(!output.isEmpty()) println output
println "Creating outputs folder"
log("Creating outputs folder")
def outputsFile = new File(project.buildDir.absolutePath + '/outputs/')
if(!outputsFile.exists()) outputsFile.mkdir();
println "Moving built .exe installer to outputs folder"
copy {
log("Moving built .exe installer to outputs folder.")
project.copy {
from project.buildDir.absolutePath + '/bin/TablexiaSetup.exe'
into new File(outputsFile, tablexiaAppName + '-release-' + tablexiaVersionName + '-Setup.exe')
into outputsFile
rename '.*', project.tablexiaAppName + '-' + getBuildTypeInput() + '-' + project.tablexiaVersionName + '-Setup.exe'
}
println "Deleting temporary installer folder"
log("Deleting temporary installer folder")
installerDir.deleteDir()
}
}
/**
* Debug and Release implementation of the task above
* buildTypeInput is used to name our .exe setup file
*/
task releaseExe(dependsOn: releaseJar, type: SetupExeTask) {
setBuildTypeInput('release')
}
task debugExe(dependsOn: debugJar, type: SetupExeTask) {
setBuildTypeInput('debug')
}
debugJar.dependsOn classes
debugJar.dependsOn(':util:checksum:runChecksum')
debugExe.dependsOn handleJreTask
debugExe.dependsOn classes
releaseJar.dependsOn classes
releaseJar.dependsOn(':util:checksum:runChecksum')
releaseExe.dependsOn handleJreTask
releaseExe.dependsOn classes
releaseExe.dependsOn(':util:checksum:runChecksum')
iTestJar.dependsOn classes
iTestJar.dependsOn iTestClasses
iTestJar.dependsOn(':util:checksum:runChecksum')
assemble.dependsOn([debugJar, releaseJar, releaseExe, iTestJar])
assemble.dependsOn([handleJreTask, debugJar, debugExe, releaseJar, releaseExe, iTestJar])
jar.enabled = false
eclipse {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment