Created
May 15, 2015 19:01
-
-
Save gleba/76700670bb14d0b29469 to your computer and use it in GitHub Desktop.
gradlefx-groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenLocal() | |
mavenCentral() | |
} | |
dependencies { | |
classpath group: 'org.gradlefx', name: 'gradlefx', version: '1.2.0' | |
classpath 'com.android.tools.build:gradle:0.4' | |
} | |
} | |
apply plugin: 'gradlefx' | |
jvmArguments = [ | |
'-Dfile.encoding=UTF-8', | |
'-Djava.awt.headless=true', | |
'-Duser.language=en', | |
'-Duser.region=en', | |
'-Xmx512m' | |
] | |
repositories { | |
ivy { | |
name 'Apache' | |
artifactPattern 'http://archive.apache.org/dist/flex/[revision]/binaries/[module]-[revision]-bin.[ext]' | |
} | |
ivy { | |
name 'Adobe Air SDK' //для windows заменить mac на win | |
artifactPattern 'http://download.macromedia.com/air/mac/download/[revision]/[module].[ext]' | |
} | |
sdkAutoInstall { | |
showPrompts = false | |
} | |
mavenCentral() | |
} | |
//flexHome = "/Users/flexis/.BuildServer/plugins/air14-flex13" | |
flexHome = "/Users/soul/sdk/air16-flex14.1" | |
type = 'mobile' | |
frameworkLinkage = 'merged' | |
srcDirs = ['sources/', 'resources/'] | |
resourceDirs = ['resources/','extension/bin/'] | |
mainClass = 'ProtoArm' | |
def String outputName = 'bigSicret' | |
def String varsFile = "vars" | |
def String sdkVersion = "16.0" | |
def String swfVersion = "27" | |
playerVersion = sdkVersion | |
output = outputName | |
dependencies { | |
// flexSDK group: 'org.apache', name: 'apache-flex-sdk', version: '4.13.0', ext: 'tar.gz' | |
// airSDK group: 'com.adobe', name: 'AdobeAIRSDK', version: "$sdkVersion", ext: 'tbz2' //для windows заменить на zip | |
merged files('libraries/gfx.swc') | |
merged files('libraries/mvcExpress-release_v2_0_rc3.swc') | |
merged files('libraries/greensock.swc') | |
merged files('libraries/corelib-20070830.swc') | |
merged files('libraries/gestouch-0.3.1.swc') | |
merged files('extension/bin/NativeDialogs.ane') | |
merged files('extension/bin/YotaDecide.ane') | |
} | |
//task yota << { | |
// println("@@@@yotaphone@@!!!@@!") | |
// yotaphone = true | |
//// compileAndroid.mustRunAfter yota | |
//} | |
gradle.taskGraph.whenReady { copyresources -> | |
additionalCompilerOptions = [ | |
"-load-config=$projectDir/resources/flex-config-auto.xml", | |
"-define=CONFIG::debug,false", | |
"-define=CONFIG::yota,${project.hasProperty('yota')}", | |
"-keep-as3-metadata+=Inject", | |
"-keep-as3-metadata+=PostConstruct", | |
"+sdkFramework=$flexHome/frameworks", | |
"+projectDir=$projectDir", | |
"+sdkVersion=$sdkVersion", | |
"+swfVersion=$swfVersion" | |
] | |
println additionalCompilerOptions | |
println "::additionalCompilerOptions: flexHome is $flexHome" | |
} | |
import java.text.SimpleDateFormat; | |
task updateProperties(dependsOn: 'compileFlex') { | |
doLast { | |
def gitMessage = new ByteArrayOutputStream() | |
// exec { | |
// workingDir project.projectDir | |
// commandLine "git", "log", "-1", "--pretty=%B" | |
// standardOutput = gitMessage; | |
// } | |
// println gitMessage; | |
def buildNumber = "0.2.2" | |
def f | |
def contents | |
if (project.hasProperty("teamcity")) { | |
buildNumber = teamcity["build.number"] | |
teamcity.each { key, val -> | |
println "##teamcity-property name='${key}' value='${val}'" | |
} | |
} | |
f = new File("$projectDir/build/Gradle-Appdescriptor.xml") | |
contents = f.getText('UTF-8') | |
contents = contents.replaceAll('versionString', buildNumber) | |
contents = contents.replaceAll('sdkVersion', sdkVersion) | |
f.write(contents) | |
def df | |
df = new SimpleDateFormat("HH:mm dd.MM.yyyy") //you can change it | |
df.setTimeZone(TimeZone.getTimeZone("GMT+4")); | |
if (project.hasProperty('public')) { | |
outputName = "$outputName-Public" | |
varsFile = "vars-public" | |
} | |
f = new File("$projectDir/build/${varsFile}.js") | |
contents = f.getText('UTF-8') | |
contents = contents.replaceAll('buildNumber', buildNumber) | |
contents = contents.replaceAll('buildDateTime', df.format(new Date())) | |
contents = contents.replaceAll('gitMessage', "")//gitMessage.toString().trim() ) | |
f.write(contents) | |
if (project.hasProperty('yota')) { | |
println("yota parameter set Appdescriptor to portrait") | |
f = new File("$projectDir/build/Gradle-Appdescriptor.xml") | |
contents = f.getText('UTF-8') | |
contents = contents.replaceAll('landscape', 'portrait') | |
f.write(contents) | |
} | |
} | |
} | |
task compileIOS(dependsOn: "updateProperties") { | |
doLast { | |
exec { | |
commandLine "java", "-jar", | |
"$flexHome/lib/adt.jar", | |
"-package", "-target", "ipa-app-store", | |
"-storetype", "PKCS12", | |
"-keystore", "$projectDir/keys/ios-qwe123.p12", | |
"-storepass", "qwe123", | |
"-provisioning-profile", "$projectDir/keys/wildcard_inhouse.mobileprovision", | |
"$projectDir/build/${outputName}.ipa", | |
"$projectDir/build/Gradle-Appdescriptor.xml", | |
"-C", "$projectDir/build", "bigSicret.swf", "icons", "photos", "content", "fonts", | |
"Default-LandscapeLeft.png", "[email protected]", "Default-LandscapeRight.png", "[email protected]" | |
workingDir project.projectDir | |
def stdOut = new ByteArrayOutputStream() | |
standardOutput = stdOut | |
println stdOut.toString() | |
} | |
} | |
} | |
task compileAndroid(dependsOn: 'updateProperties', type:Exec) { | |
workingDir project.projectDir | |
commandLine "java", "-jar", | |
"$flexHome/lib/adt.jar", | |
"-package", "-target", "apk-debug", | |
"-storetype", "pkcs12", | |
"-keystore", "$projectDir/keys/android-qwe123.p12", | |
"-storepass", "qwe123", | |
"$projectDir/build/${outputName}.apk", | |
"$projectDir/build/Gradle-Appdescriptor.xml", | |
"-C", "$projectDir/build", "bigSicret.swf", "icons", "photos", "content", "fonts", | |
"Default-LandscapeLeft.png", "[email protected]", "Default-LandscapeRight.png", "[email protected]", | |
"-extdir","$projectDir/ane/" | |
println("::compileAndroid: \n" + commandLine) | |
standardOutput = new ByteArrayOutputStream() | |
errorOutput = standardOutput | |
ignoreExitValue = true | |
doLast { | |
if (execResult.exitValue != 0) { | |
println("adt.jar failed: \n" + commandLine) | |
throw new GradleException("Error message: \n" + standardOutput.toString()) | |
} | |
} | |
} | |
configurations { | |
ftpAntTask | |
} | |
dependencies { | |
ftpAntTask("org.apache.ant:ant-commons-net:1.8.4") { | |
module("commons-net:commons-net:1.4.1") { | |
dependencies "oro:oro:2.0.8:jar" | |
} | |
} | |
} | |
repositories { | |
mavenCentral() | |
} | |
task ftp << { | |
ant { | |
taskdef(name: 'ftp', | |
classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP', | |
classpath: configurations.ftpAntTask.asPath) | |
ftp(server: "81.177.xxxx", userid: "xxxx", password: "xxx") { | |
fileset(file: "build/${outputName}.apk") | |
fileset(file: "build/${outputName}.ipa") | |
fileset(file: "build/${varsFile}.js") | |
} | |
} | |
} | |
task debugAndroid(dependsOn: 'compileAndroid', type:Exec) { | |
workingDir project.projectDir | |
commandLine "adb", "-d", | |
"install","$projectDir/build/${outputName}.apk" | |
// commandLine "java", "-jar", | |
// "$flexHome/lib/adt.jar", | |
// "-installApp", "-platform", "android", | |
// "-package", | |
// "$projectDir/build/${outputName}.apk" | |
standardOutput = new ByteArrayOutputStream() | |
errorOutput = standardOutput | |
ignoreExitValue = true | |
println("::debugAndroid: \n" + commandLine) | |
doLast { | |
if (execResult.exitValue != 0) { | |
println("debugAndroid failed: \n" + commandLine) | |
throw new GradleException("Error message: \n" + standardOutput.toString()) | |
} | |
} | |
} | |
defaultTasks 'clean', 'copyresources', 'compileFlex', 'updateProperties', 'compileAndroid', 'debugAndroid' | |
//defaultTasks 'clean', 'copyresources', 'compileFlex', 'compileIOS', 'compileAndroid', 'ftp' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment