blob: ad09589c7d3392982e580e3818ffa153e92bfe30 [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 28
buildToolsVersion "28.0.3"
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 28
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'
if (project.hasProperty('cobaltGradleDir')) {
// Resolve relative to the current dir at config time by getting a canonical File.
buildStagingDirectory new File(cobaltGradleDir, 'externalNativeBuild').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 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:leanback-v17:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
}