blob: 231fbb9c67400910e0833163a97901abe7f10c63 [file] [log] [blame]
// Copyright 2016 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
apply plugin: 'com.android.application'
final DEFAULT_COBALT_TARGET = 'cobalt'
final String[] SUPPORTED_ABIS = [ 'x86', 'armeabi-v7a', 'arm64-v8a' ]
ext {
// Provide defaults if these properties aren't specified on the command line.
buildAbi = project.hasProperty('cobaltBuildAbi') ? cobaltBuildAbi : SUPPORTED_ABIS
cobaltTarget = project.hasProperty('cobaltTarget') ? cobaltTarget : DEFAULT_COBALT_TARGET
cobaltProductDir =
project.hasProperty('cobaltProductDir') ? new File(cobaltProductDir).canonicalPath : ''
cobaltContentDir =
project.hasProperty('cobaltContentDir') ? new File(cobaltContentDir).canonicalPath : ''
buildIdFile = rootProject.file('build.id')
buildId = buildIdFile.exists() ? buildIdFile.text.trim() : '0'
}
println "TARGET: ${cobaltTarget}"
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
signingConfigs {
// A signing config that matches what is implicitly used for the "debug" build type.
debugConfig {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file("${System.getProperty('user.home')}/.android/debug.keystore")
storePassword 'android'
}
}
defaultConfig {
applicationId "dev.cobalt.coat"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "${buildId}"
manifestPlaceholders = [applicationName: "CoAT: ${cobaltTarget}"]
externalNativeBuild {
cmake {
arguments "-DCOBALT_TARGET=${cobaltTarget}"
arguments "-DCOBALT_PRODUCT_DIR=${cobaltProductDir}"
arguments "-DCOBALT_CONTENT_DIR=${cobaltContentDir}"
arguments "-DCOBALT_PLATFORM_DEPLOY=${project.hasProperty('cobaltDeployApk')}"
}
}
}
splits {
abi {
enable true
reset()
include buildAbi
}
}
buildTypes {
debug {
debuggable true
jniDebuggable true
externalNativeBuild {
cmake.arguments "-DCOBALT_CONFIG=debug"
}
signingConfig signingConfigs.debugConfig
}
devel {
debuggable true
jniDebuggable true
externalNativeBuild {
cmake.arguments "-DCOBALT_CONFIG=devel"
}
signingConfig signingConfigs.debugConfig
}
qa {
debuggable true
jniDebuggable true
externalNativeBuild {
cmake.arguments "-DCOBALT_CONFIG=qa"
}
signingConfig signingConfigs.debugConfig
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
externalNativeBuild {
cmake.arguments "-DCOBALT_CONFIG=gold"
}
signingConfig signingConfigs.debugConfig
}
}
sourceSets {
// The source is split into two parts:
// "main" is the code that should go into any Cobalt-based app for Android TV.
// "app" is the specialization needed to make "the blue app" out of the main code.
// The Android Gradle plugin includes "main" by default, so we just need to add "app".
main {
manifest.srcFile "src/app/AndroidManifest.xml"
java.srcDir "src/app/java"
res.srcDir "src/app/res"
assets.srcDir "src/app/assets"
}
// Add the directories symlinked by the CMake "cobalt_content" custom command.
debug {
assets.srcDir "${buildDir}/intermediates/cmake/debug/cobalt_content"
}
devel {
assets.srcDir "${buildDir}/intermediates/cmake/devel/cobalt_content"
}
qa {
assets.srcDir "${buildDir}/intermediates/cmake/qa/cobalt_content"
}
release {
assets.srcDir "${buildDir}/intermediates/cmake/release/cobalt_content"
}
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
// Move the staging directory to be a sibling of the build directory, which we moved
// in the top-level build.gradle to be in a common top-level 'build' directory. Get
// the canonical file at config time so that it's still right at build time.
buildStagingDirectory new File("${buildDir}.cxx").canonicalFile
}
}
}
// When running in the platform deploy action, make tasks that depend on the appropriate Android
// assemble tasks, then the move the assembled "app" apk to the desired path for deployment.
if (project.hasProperty('cobaltDeployApk')) {
android.applicationVariants.all { variant ->
task "assembleCobalt_${variant.name}"(dependsOn: "assemble${variant.name.capitalize()}") {
def assembledApk = variant.outputs[0].outputFile
def deployApk = new File(cobaltDeployApk).canonicalFile
doLast {
assembledApk.renameTo(deployApk)
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
}