mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-25 08:38:30 -05:00
99 lines
2.8 KiB
Groovy
99 lines
2.8 KiB
Groovy
apply plugin: 'com.android.application'
|
|
apply plugin: 'com.google.gms.google-services'
|
|
|
|
android {
|
|
compileSdkVersion 23
|
|
buildToolsVersion "21.1.2"
|
|
|
|
defaultConfig {
|
|
applicationId "org.scratchjr.android"
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
|
|
productFlavors {
|
|
free {
|
|
applicationId "org.scratchjr.androidfree"
|
|
minSdkVersion 17
|
|
targetSdkVersion 23
|
|
versionCode 20
|
|
versionName "1.1"
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
|
compile 'com.android.support:appcompat-v7:23.1.1'
|
|
compile 'com.google.android.gms:play-services-analytics:8.3.0'
|
|
}
|
|
|
|
def appModuleRootFolder = '.'
|
|
def srcDir = 'src'
|
|
def googleServicesJson = 'google-services.json'
|
|
def commonHome = '../../..'
|
|
def html5Assets = 'src/main/assets/HTML5'
|
|
|
|
task switchToFree(type: Copy) {
|
|
def buildType = 'free'
|
|
from "${commonHome}/editions/${buildType}/src"
|
|
into html5Assets
|
|
}
|
|
|
|
task switchToFreeGA(type: Copy) {
|
|
def buildType = 'free'
|
|
from "${commonHome}/editions/${buildType}/android-resources"
|
|
include "$googleServicesJson"
|
|
into "$appModuleRootFolder"
|
|
}
|
|
|
|
class GenerateScratchJrPNGsTask extends DefaultTask {
|
|
File commonHome = project.file("../../..")
|
|
File binDir = project.file("${commonHome}/bin")
|
|
|
|
@OutputDirectory
|
|
File generatedAssets = project.file("src/main/assets")
|
|
File generatedHtml5Assets = project.file("${generatedAssets}/HTML5")
|
|
File pngLibrary = project.file("${generatedHtml5Assets}/pnglibrary")
|
|
File svgLibrary = project.file("${generatedHtml5Assets}/svglibrary")
|
|
|
|
@TaskAction
|
|
def go() {
|
|
pngLibrary.mkdirs()
|
|
ant.exec(executable: "${binDir}/convert-svg-to-png.py",
|
|
failOnError: true)
|
|
{
|
|
arg(value: "-i ${svgLibrary}/")
|
|
arg(value: "-o ${pngLibrary}/")
|
|
}
|
|
}
|
|
}
|
|
class CleanScratchJrResourcesTask extends DefaultTask {
|
|
File generatedAssets = project.file('src/main/assets')
|
|
|
|
@TaskAction
|
|
def go() {
|
|
generatedAssets.deleteDir()
|
|
}
|
|
}
|
|
|
|
task generateScratchJrPNGs(type: GenerateScratchJrPNGsTask)
|
|
task cleanScratchJrResources(type: CleanScratchJrResourcesTask)
|
|
|
|
afterEvaluate {
|
|
processFreeDebugGoogleServices.dependsOn switchToFreeGA
|
|
processFreeReleaseGoogleServices.dependsOn switchToFreeGA
|
|
prepareFreeDebugDependencies.dependsOn switchToFree
|
|
prepareFreeReleaseDependencies.dependsOn switchToFree
|
|
|
|
generateFreeReleaseResources.dependsOn generateScratchJrPNGs
|
|
generateFreeDebugResources.dependsOn generateScratchJrPNGs
|
|
generateScratchJrPNGs.mustRunAfter switchToFree
|
|
}
|
|
|
|
clean.dependsOn('cleanScratchJrResources')
|