8. Gradle
Tasks
Block of code that defines part of a build
Create a new task
task(showText, dependsOn: âprojectB:compileâ) << ,
println âIâm executing after the compile task"
}
Configure an existing Task
task(copy, type: Copy) {
from(file('srcDir'))
into(buildDir)
}
12. Gradle
Custom task class
class CopyResources extends DefaultTask {
public CopyResources() {
description = 'copies the resources to the build directory'
}
@TaskAction
def copyResources() {
project.resourceDirs.each { resourceDir ->
def fromLocation = project.file(resourceDir).path
def toLocation = project.buildDir.path
logger.info('from ' + fromLocation + ' to ' + toLocation)
project.copy {
from fromLocation
into toLocation
}
}
}
}
13. Gradle
Convention properties
Properties exposed by plugins
Simple or complex properties
Have a default value (convention)
Can be overridden
Example:
srcDirs = ['src/main/flex'] ï convention = [âsrc/main/actionscriptâ]
htmlWrapper.title = âMy html wrapper page titleâ ï default = project name
19. Gradle
Ant support
Ant project import
Support for Ivy repositories
Run Ant tasks with Gradle
Example
ant.java(jar: project.flexHome + '/lib/mxmlc.jar',
dir: project.flexHome + '/frameworks',
fork: true,
resultproperty: âantResultPropertyâ,
outputproperty: âantOutputPropertyâ) ,
arg(value: â-keep-as3-metadata+=Autowired,RemoteClassâ)
}
println ant.properties*âantOutputPropertyâ+
26. GradleFx
Project type
Defines to which type of archive the sources will be compiled to
Convention property ï type
Possible values ï âswcâ, âswfâ or âairâ
Example
type = âswcâ
27. GradleFx
Basic conventions
sources ï src/main/actionscript (srcDirs property)
resources ï src/main/resources (resourceDirs property)
test sources ï src/test/actionscript (testDirs property)
test resources ï src/test/resources (testResourceDirs property)
mxml main class ï Main.mxml in src/main/actionscript/ (mainClass property)
build directory ï build (project.buildDir property)
28. GradleFx
Some advanced properties
Compiler options
additionalCompilerOptions property
One item per compiler option
additionalCompilerOptions = [
'-use-network=true',
'-locale=en_US',
'-keep-as3-metadata+=Autowired,RemoteClassâ
]
JVM options
jvmArguments property
jvmArguments = ['-Xmx1024m','-Xms512m']
30. GradleFx
AIR project required steps
Create AIR descriptor file
Convention
"/src/main/actionscript/$,project.name-.xmlâ
Custom value
air.applicationDescriptor: "/src/main/flex/airdescriptor.xmlâ
Certificate
Needed to sign the AIR package
PKCS12 format
Password required
Convention
"$,project.name-.p12â
Custom value
air.keystore: "certificate.p12â
air.storepass = "mypassword"
31. GradleFx
FlexUnit required steps
Specify FlexUnit home
Convention
FLEXUNIT_HOME environment variable
Custom value
flexUnit.home = 'c:/flexunit/4.1'
Specify Flash Player executable
Convention
FLASH_PLAYER_EXE environment variable
Custom value
flexunit.command = âc:/flashplayer/flashplayer_10.exeâ
Specify FlexUnit ant task jar name
Located in FlexUnit home directory
Custom value
flexUnit.antTasksJar = 'flexUnitTasks-4.1.0-8.jar'
35. GradleFx
Where to go next
GradleFx site: https://github.com/GradleFx/GradleFx
Source: https://github.com/GradleFx/GradleFx
Documentation: https://github.com/GradleFx/GradleFx/wiki
Examples: https://github.com/GradleFx/GradleFx-Examples
Help & Support: http://gradlefx.tenderapp.com/home
Bug tracker: https://github.com/GradleFx/GradleFx/issues
Changelog: https://github.com/GradleFx/GradleFx/blob/master/CHANGELOG.textile