2017-06-21 17:52:30 +00:00
|
|
|
def tryInt = { string ->
|
|
|
|
if (string == null) {
|
|
|
|
return string
|
|
|
|
}
|
|
|
|
if (string.isInteger()) {
|
|
|
|
return string as Integer
|
|
|
|
}
|
|
|
|
return string
|
|
|
|
}
|
|
|
|
|
2015-10-21 22:07:55 +00:00
|
|
|
allprojects {
|
|
|
|
// Expose the per-object-directory configuration to all projects.
|
|
|
|
ext {
|
|
|
|
mozconfig = gradle.mozconfig
|
|
|
|
topsrcdir = gradle.mozconfig.topsrcdir
|
|
|
|
topobjdir = gradle.mozconfig.topobjdir
|
2017-06-21 17:52:30 +00:00
|
|
|
|
|
|
|
compileSdkVersion = tryInt(mozconfig.substs.ANDROID_COMPILE_SDK_VERSION)
|
|
|
|
targetSdkVersion = tryInt(mozconfig.substs.ANDROID_TARGET_SDK)
|
|
|
|
minSdkVersion = tryInt(mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION)
|
|
|
|
manifestPlaceholders = [
|
|
|
|
ANDROID_PACKAGE_NAME: mozconfig.substs.ANDROID_PACKAGE_NAME,
|
|
|
|
ANDROID_TARGET_SDK: mozconfig.substs.ANDROID_TARGET_SDK,
|
|
|
|
MOZ_ANDROID_MIN_SDK_VERSION: mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION,
|
|
|
|
MOZ_ANDROID_SHARED_ID: "${mozconfig.substs.ANDROID_PACKAGE_NAME}.sharedID",
|
|
|
|
]
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
2017-07-26 18:28:07 +00:00
|
|
|
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
|
2016-03-17 18:04:08 +00:00
|
|
|
maven {
|
2017-07-26 18:28:07 +00:00
|
|
|
url repository
|
2016-03-17 18:04:08 +00:00
|
|
|
}
|
2016-02-11 03:29:27 +00:00
|
|
|
}
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildDir "${topobjdir}/gradle/build"
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
2017-07-26 18:28:07 +00:00
|
|
|
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
|
2016-03-17 18:04:08 +00:00
|
|
|
maven {
|
2017-07-26 18:28:07 +00:00
|
|
|
url repository
|
2016-03-17 18:04:08 +00:00
|
|
|
}
|
2016-02-11 03:29:27 +00:00
|
|
|
}
|
2017-10-05 22:00:53 +00:00
|
|
|
// For in tree plugins.
|
2016-03-02 04:12:04 +00:00
|
|
|
maven {
|
|
|
|
url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
|
|
|
|
}
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
|
2018-05-02 17:49:57 +00:00
|
|
|
ext.kotlin_version = '1.2.41'
|
2018-07-13 14:16:37 +00:00
|
|
|
ext.support_library_version = '26.1.0'
|
2018-07-24 10:44:24 +00:00
|
|
|
ext.jacoco_version = '0.8.1'
|
2018-02-22 23:39:11 +00:00
|
|
|
|
2018-03-21 17:50:11 +00:00
|
|
|
if (gradle.mozconfig.substs.MOZ_ANDROID_GOOGLE_PLAY_SERVICES) {
|
2018-07-13 12:40:03 +00:00
|
|
|
ext.google_play_services_version = '15.0.1'
|
2018-03-21 17:50:11 +00:00
|
|
|
}
|
|
|
|
|
2015-10-21 22:07:55 +00:00
|
|
|
dependencies {
|
2018-09-04 20:33:00 +00:00
|
|
|
classpath 'com.android.tools.build:gradle:3.1.4'
|
2017-10-26 18:00:36 +00:00
|
|
|
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
|
2018-02-22 23:39:11 +00:00
|
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-19 20:49:45 +00:00
|
|
|
if ('multi' == System.env.AB_CD) {
|
|
|
|
// Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale. This
|
|
|
|
// causes the
|
|
|
|
//
|
|
|
|
// |mach build| > |mach gradle| > |make gradle-targets| > AndroidManifest.xml > strings.xml > multi/brand.dtd
|
|
|
|
//
|
|
|
|
// dependency chain to fail, since multi isn't a real locale. To avoid
|
|
|
|
// this, if Gradle is invoked with AB_CD=multi, we don't invoke Make at all.
|
|
|
|
task generateCodeAndResources()
|
2017-11-06 13:23:47 +00:00
|
|
|
} else if (System.env.IS_LANGUAGE_REPACK == '1') {
|
|
|
|
// Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
|
|
|
|
// and code generation themselves.
|
|
|
|
task generateCodeAndResources()
|
2017-10-19 20:49:45 +00:00
|
|
|
} else {
|
|
|
|
task generateCodeAndResources(type:Exec) {
|
|
|
|
workingDir "${topobjdir}"
|
2015-10-21 22:07:55 +00:00
|
|
|
|
2017-10-19 20:49:45 +00:00
|
|
|
commandLine mozconfig.substs.GMAKE
|
|
|
|
args '-C'
|
|
|
|
args "${topobjdir}/mobile/android/base"
|
|
|
|
args 'gradle-targets'
|
2015-10-21 22:07:55 +00:00
|
|
|
|
2017-10-19 20:49:45 +00:00
|
|
|
// Only show the output if something went wrong.
|
|
|
|
ignoreExitValue = true
|
|
|
|
standardOutput = new ByteArrayOutputStream()
|
|
|
|
errorOutput = standardOutput
|
|
|
|
doLast {
|
|
|
|
if (execResult.exitValue != 0) {
|
|
|
|
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
|
|
|
|
}
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
2018-05-01 04:22:54 +00:00
|
|
|
subprojects { project ->
|
|
|
|
if (project.name != 'thirdparty') {
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
// Add compiler args for all code except third-party code.
|
|
|
|
options.compilerArgs += [
|
|
|
|
// Turn on all warnings, except...
|
|
|
|
"-Xlint:all",
|
|
|
|
// Deprecation, because we do use deprecated API for compatibility.
|
|
|
|
"-Xlint:-deprecation",
|
|
|
|
// Serial, because we don't use Java serialization.
|
|
|
|
"-Xlint:-serial",
|
2018-08-23 13:12:20 +00:00
|
|
|
// Classfile, because javac has a bug with MethodParameters attributes
|
|
|
|
// with Java 7. https://bugs.openjdk.java.net/browse/JDK-8190452
|
|
|
|
"-Xlint:-classfile",
|
2018-05-01 04:22:54 +00:00
|
|
|
// Turn all remaining warnings into errors,
|
|
|
|
// unless marked by @SuppressWarnings.
|
|
|
|
"-Werror"]
|
|
|
|
}
|
2018-07-13 12:40:03 +00:00
|
|
|
if (project.name == 'app') {
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
// Turn off classfile warnings because upon updating to play services 15.0.0
|
|
|
|
// a warning is being thrown from play-services-base which fails the build
|
|
|
|
// (com/google/android/gms/common/api/GoogleApiClient.class):
|
|
|
|
// warning: Cannot find annotation method 'value()' in type 'GuardedBy':
|
|
|
|
// class file for javax.annotation.concurrent.GuardedBy not found
|
|
|
|
options.compilerArgs += ["-Xlint:-classfile"]
|
|
|
|
}
|
|
|
|
}
|
2018-05-01 04:22:54 +00:00
|
|
|
}
|
|
|
|
|
2015-10-21 22:07:55 +00:00
|
|
|
if (!hasProperty('android')) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
android.applicationVariants.all {
|
|
|
|
preBuild.dependsOn rootProject.generateCodeAndResources
|
|
|
|
}
|
|
|
|
android.libraryVariants.all {
|
|
|
|
preBuild.dependsOn rootProject.generateCodeAndResources
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
apply plugin: 'idea'
|
|
|
|
|
|
|
|
idea {
|
|
|
|
project {
|
2018-08-22 19:15:42 +00:00
|
|
|
languageLevel = '1.8'
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
2015-10-20 22:30:44 +00:00
|
|
|
|
|
|
|
module {
|
|
|
|
// Object directories take a huge amount of time for IntelliJ to index.
|
|
|
|
// Exclude them. Convention is that object directories start with obj.
|
|
|
|
// IntelliJ is clever and will not exclude the parts of the object
|
2015-12-02 22:57:12 +00:00
|
|
|
// directory that are referenced, if there are any. In practice,
|
|
|
|
// indexing the entirety of the tree is taking too long, so exclude all
|
|
|
|
// but mobile/.
|
2015-10-20 22:30:44 +00:00
|
|
|
def topsrcdirURI = file(topsrcdir).toURI()
|
|
|
|
excludeDirs += files(file(topsrcdir)
|
|
|
|
.listFiles({it.isDirectory()} as FileFilter)
|
|
|
|
.collect({topsrcdirURI.relativize(it.toURI()).toString()}) // Relative paths.
|
2015-12-02 22:57:12 +00:00
|
|
|
.findAll({!it.equals('mobile/')}))
|
2015-10-20 22:30:44 +00:00
|
|
|
|
|
|
|
// If topobjdir is below topsrcdir, hide only some portions of that tree.
|
|
|
|
def topobjdirURI = file(topobjdir).toURI()
|
|
|
|
if (!topsrcdirURI.relativize(topobjdirURI).isAbsolute()) {
|
|
|
|
excludeDirs -= file(topobjdir)
|
|
|
|
excludeDirs += files(file(topobjdir).listFiles())
|
|
|
|
excludeDirs -= file("${topobjdir}/gradle")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
|
|
|
|
excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust")
|
|
|
|
}
|
|
|
|
}
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
task wrapper(type: Wrapper) {
|
|
|
|
}
|