Skip to content

Instantly share code, notes, and snippets.

@pablovilas
Created June 20, 2016 14:32
Show Gist options
  • Save pablovilas/ac5f037990eb1686c08d4f659792d11a to your computer and use it in GitHub Desktop.
Save pablovilas/ac5f037990eb1686c08d4f659792d11a to your computer and use it in GitHub Desktop.
Fxlauncher build.gradle deploy to Amazon S3
/**
* FXLauncher build targets
*
* - buildApp: Assembles the application into build/libs
* - deployApp: Transfers application to appDeployTarget via scp
* - installer: Generates native installer
*/
group 'no.tornado'
version '1.0'
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'no.tornado:fxlauncher:1.0.11'
compile 'org.controlsfx:controlsfx:8.40.10'
}
// Installer Filename without suffix
def appFilename = 'FxlDemo'
// The JavaFX Application class name
def appMainClass = 'no.tornado.FxlDemo'
// Optional override to specify where the cached files are stored. Default is current working directory
def cacheDir = 'USERLIB/FxlDemo'
// Optional parameters to the application, will be embedded in the launcher and can be overriden on the command line
def appParameters = '--myOption=myValue --myOtherOption=myOtherValue'
// The Application vendor used by javapackager
def appVendor = 'AcmeInc'
// The Application version used by javapackager
def appVersion = '2.0'
// Base URL where you will host the application artifacts
def appUrl = 'https://s3-us-west-1.amazonaws.com/your.bucket.name/'
// S3 target for application artifacts hosted at the above url
def appDeployTarget = 's3://your.bucket.name'
jar.archiveName = "fxldemo.jar"
task buildApp(dependsOn: ['copyDependencies', 'generateAppManifest', 'embedAppManifest'])
task copyDependencies {
dependsOn jar
configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact ->
project.copy {
from artifact.file
into 'build/libs'
rename { "${artifact.name}.${artifact.extension}" }
}
}
}
task generateAppManifest(type: JavaExec) {
main = 'fxlauncher.CreateManifest'
classpath = sourceSets.main.runtimeClasspath
args = [appUrl, appMainClass, 'build/libs', '--cache-dir=' + cacheDir, appParameters]
}
task embedAppManifest(type: Exec) {
mustRunAfter 'generateAppManifest'
workingDir 'build/libs'
commandLine 'jar', 'uf', 'fxlauncher.jar', 'app.xml'
}
task installer(type: Exec, dependsOn: 'buildApp') {
commandLine 'javapackager', '-deploy', '-native', '-outdir', 'installer', '-outfile', appFilename, '-srcdir', 'build/libs', '-srcfiles', 'fxlauncher.jar', '-appclass', 'fxlauncher.Launcher', '-name', "${rootProject.name}", '-title', "${rootProject.name}", '-vendor', "$appVendor", "-Bidentifier", "${rootProject.group}.${appFilename}", '-Bidentifier=' + project.group + '.' + appFilename, '-BappVersion=' + appVersion
}
task deployApp(type: Exec, dependsOn: 'embedAppManifest') {
// You need to have installed AWS command line interface: https://aws.amazon.com/cli/
commandLine 'aws', 'configure', 'set', 'aws_access_key_id', 'your_access_key_id'
commandLine 'aws', 'configure', 'set', 'aws_secret_access_key', 'your_secret_access_key'
commandLine 'aws', 's3', 'cp', 'build/libs', appDeployTarget, '--acl', 'public-read', '--recursive', '--region', 'us-west-1'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment