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'
34. GradleFx
What’s to come?
IDEA and Eclipse project generation support
AS3Doc generation
Flex SDK maven artifact support?
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