Last active
February 25, 2021 08:50
-
-
Save CAMOBAP/d02ae7589bd53517a2da60a9a79ea55f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class b10Extension { | |
String sdk | |
String authorp12 | |
String storepass | |
String cskpass | |
String deviceHost | |
String devicePass | |
String apk2bar | |
} | |
class blackberry10 implements Plugin<Project> { | |
void apply(Project project) { | |
def hasAppPlugin = project.plugins.hasPlugin com.android.build.gradle.AppPlugin | |
if (!hasAppPlugin) { | |
throw new IllegalStateException("The 'android' plugin is required.") | |
} | |
def isWin = org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS) | |
def shellPostfix = isWin ? '.bat' : '' | |
project.extensions.create("bb10", b10Extension) | |
project.afterEvaluate { | |
new File("$project.buildDir/bb10").mkdirs(); | |
def task = project.tasks.create(name: "genDebugTokenBar", type: Exec) { | |
group 'Blackberry 10 support' | |
description 'Update debugtoken.bar' | |
workingDir "$project.buildDir" | |
commandLine "$project.bb10.sdk/blackberry-debugtokenrequest${shellPostfix}", | |
'-keystore', project.bb10.authorp12, | |
'-storepass', project.bb10.storepass, | |
'-devicepinlist', '../../bb10/device_PINs.txt', | |
"$project.buildDir/bb10/debugtoken.bar" | |
} | |
project.tasks.create(name: "deployDebugTokenBar", type: Exec) { | |
group 'Blackberry 10 support' | |
description "Deploy debugtoken to ${project.bb10.deviceHost} host" | |
workingDir "$project.buildDir" | |
commandLine "$project.bb10.sdk/blackberry-deploy${shellPostfix}", | |
'-installDebugToken', "$project.buildDir/bb10/debugtoken.bar", | |
'-device', project.bb10.deviceHost, | |
'-password', project.bb10.devicePass | |
} | |
project.android.productFlavors.all { flavor -> | |
def fname = capitalize(flavor.name) | |
project.tasks.create(name: "pack${fname}DebugBar", type: Exec, dependsOn: "assemble${fname}Debug") { | |
group 'Blackberry 10 support' | |
description "Repack debug ${fname}.apk to blackberry application file" | |
workingDir "$project.buildDir" | |
commandLine "$project.bb10.sdk/${project.bb10.apk2bar}${shellPostfix}", "$project.buildDir/outputs/apk/PanicGuard-${flavor.name}-debug-unaligned.apk", | |
"$project.buildDir/../../bb10/android.cfg", | |
"$System.env.ANDROID_HOME", | |
'-d', "$project.buildDir/bb10/debugtoken.bar", | |
'-t', "$project.buildDir/bb10" | |
} | |
project.tasks.create(name: "pack${fname}UnalignedReleaseBar", type: Exec, dependsOn: "assemble${fname}Release") { | |
group 'Blackberry 10 support' | |
description "Repack release ${fname}.apk to blackberry application file" | |
workingDir "$project.buildDir" | |
commandLine "$project.bb10.sdk/${project.bb10.apk2bar}${shellPostfix}", "$project.buildDir/outputs/apk/PanicGuard-${flavor.name}-release.apk", | |
"$project.buildDir/../../bb10/android.cfg", | |
"$System.env.ANDROID_HOME", | |
'-t', "$project.buildDir/bb10" | |
} | |
project.tasks.create(name: "pack${fname}ReleaseBar", type: Exec, dependsOn: "pack${fname}UnalignedReleaseBar") { | |
group 'Blackberry 10 support' | |
description "Repack ${flavor.name}.apk to ${flavor.name}.bar file" | |
workingDir "$project.buildDir" | |
commandLine "$project.bb10.sdk/blackberry-signer${shellPostfix}", | |
'-keystore', project.bb10.authorp12, | |
'-storepass', project.bb10.storepass, | |
"$project.buildDir/bb10/PanicGuard-${flavor.name}-release.bar", | |
'RDK', 'AUTHOR' | |
} | |
project.tasks.create(name: "deploy${fname}DebugBar", type: Exec, dependsOn: "deployDebugTokenBar") { | |
group 'Blackberry 10 support' | |
description "Deploy debugtoken to ${project.bb10.deviceHost} host" | |
workingDir "$project.buildDir" | |
commandLine "$project.bb10.sdk/blackberry-deploy${shellPostfix}", | |
'-installApp', | |
'-device', project.bb10.deviceHost, | |
'-password', project.bb10.devicePass, | |
"$project.buildDir/bb10/PanicGuard-${flavor.name}-debug-unaligned.bar" | |
} | |
project.tasks.create(name: "deploy${fname}ReleaseBar", type: Exec) { | |
group 'Blackberry 10 support' | |
description "Deploy release version of ${fname} to ${project.bb10.deviceHost} host" | |
workingDir "$project.buildDir" | |
commandLine "$project.bb10.sdk/blackberry-deploy${shellPostfix}", | |
'-installApp', | |
'-device', project.bb10.deviceHost, | |
'-password', project.bb10.devicePass, | |
"$project.buildDir/bb10/PanicGuard-${flavor.name}-release.bar" | |
} | |
} | |
} | |
} | |
def capitalize(s) { s[0].toUpperCase() + s[1..-1].toLowerCase() } | |
} |
This file contains hidden or 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
apply plugin: 'com.android.application' | |
apply plugin: blackberry10 | |
android { | |
... | |
} | |
bb10 { | |
sdk 'D:/blackberry/2.0.2/bin' | |
authorp12 "../../bb10/author.p12" | |
storepass System.getenv('BB10_STORE_PASS') | |
cskpass System.getenv('BB10_CSK_PASS') | |
deviceHost "169.254.0.1" | |
devicePass "xxx" | |
// for 1_6 it should be apk2bar | |
apk2bar "blackberry-apkpackager" | |
} | |
dependencies { | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment