mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-12-01 11:27:16 -05:00
126 lines
3.8 KiB
Groovy
126 lines
3.8 KiB
Groovy
apply plugin: 'com.android.application'
|
|
|
|
android {
|
|
compileSdkVersion 28
|
|
buildToolsVersion "28.0.3"
|
|
|
|
defaultConfig {
|
|
applicationId "org.scratchjr.android"
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
|
|
flavorDimensions 'scratchjrversion'
|
|
productFlavors {
|
|
free {
|
|
dimension = 'scratchjrversion'
|
|
applicationId "org.scratchjr.androidfree"
|
|
minSdkVersion 21
|
|
targetSdkVersion 29
|
|
versionCode 22
|
|
versionName "1.2.11"
|
|
}
|
|
}
|
|
|
|
// The camera-view dependency contains Java 8 bytecode,
|
|
// we need to support java 8 to dex.
|
|
// See https://developer.android.com/studio/write/java8-support.html for details.
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
|
implementation 'com.google.firebase:firebase-core:17.2.0'
|
|
implementation 'com.google.firebase:firebase-analytics:17.2.0'
|
|
implementation 'com.google.android.gms:play-services-location:17.0.0'
|
|
|
|
implementation 'androidx.appcompat:appcompat:1.3.0'
|
|
def camerax_version = "1.0.0-rc05"
|
|
// CameraX core library using camera2 implementation
|
|
implementation "androidx.camera:camera-camera2:$camerax_version"
|
|
// CameraX Lifecycle Library
|
|
implementation "androidx.camera:camera-lifecycle:$camerax_version"
|
|
// CameraX View class
|
|
implementation "androidx.camera:camera-view:1.0.0-alpha25"
|
|
}
|
|
|
|
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"
|
|
}
|
|
|
|
task generateWebpackBundle(type: Exec) {
|
|
workingDir '../../../bin'
|
|
commandLine './bundle-compile.sh'
|
|
}
|
|
|
|
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 {
|
|
preBuild.dependsOn generateWebpackBundle
|
|
processFreeDebugGoogleServices.dependsOn switchToFreeGA
|
|
processFreeReleaseGoogleServices.dependsOn switchToFreeGA
|
|
|
|
generateFreeReleaseResources.dependsOn switchToFree
|
|
generateFreeDebugResources.dependsOn switchToFree
|
|
generateFreeReleaseResources.dependsOn generateScratchJrPNGs
|
|
generateFreeDebugResources.dependsOn generateScratchJrPNGs
|
|
generateScratchJrPNGs.mustRunAfter switchToFree
|
|
}
|
|
|
|
clean.dependsOn('cleanScratchJrResources')
|
|
|
|
apply plugin: 'com.google.gms.google-services'
|