2017-06-21 20:52:30 +03:00
|
|
|
def tryInt = { string ->
|
|
|
|
if (string == null) {
|
|
|
|
return string
|
|
|
|
}
|
|
|
|
if (string.isInteger()) {
|
|
|
|
return string as Integer
|
|
|
|
}
|
|
|
|
return string
|
|
|
|
}
|
|
|
|
|
2015-10-22 01:07:55 +03: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 20:52:30 +03:00
|
|
|
|
2019-01-28 21:32:11 +03:00
|
|
|
compileSdkVersion = 28
|
2017-06-21 20:52:30 +03:00
|
|
|
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-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
2017-07-26 21:28:07 +03:00
|
|
|
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
|
2016-03-17 21:04:08 +03:00
|
|
|
maven {
|
2017-07-26 21:28:07 +03:00
|
|
|
url repository
|
2016-03-17 21:04:08 +03:00
|
|
|
}
|
2016-02-11 06:29:27 +03:00
|
|
|
}
|
2018-12-15 00:34:06 +03:00
|
|
|
// For in tree dependencies.
|
|
|
|
// TODO: remove this once
|
|
|
|
// https://issuetracker.google.com/issues/120951637 is resolved. See
|
|
|
|
// also Bug 1514374.
|
|
|
|
maven {
|
|
|
|
url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
|
|
|
|
}
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
2018-12-15 00:37:37 +03:00
|
|
|
|
|
|
|
task downloadDependencies() {
|
|
|
|
description 'Download all dependencies to the Gradle cache'
|
|
|
|
doLast {
|
|
|
|
configurations.each { configuration ->
|
|
|
|
if (configuration.canBeResolved) {
|
|
|
|
configuration.allDependencies.each { dependency ->
|
|
|
|
try {
|
|
|
|
configuration.files(dependency)
|
|
|
|
} catch(e) {
|
|
|
|
println("Could not resolve ${configuration.name} -> ${dependency.name}")
|
|
|
|
println(" > ${e.message}")
|
|
|
|
if (e.cause) {
|
|
|
|
println(" >> ${e.cause}")
|
|
|
|
if (e.cause.cause) {
|
|
|
|
println(" >> ${e.cause.cause}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
println("")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
buildDir "${topobjdir}/gradle/build"
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
2017-07-26 21:28:07 +03:00
|
|
|
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
|
2016-03-17 21:04:08 +03:00
|
|
|
maven {
|
2017-07-26 21:28:07 +03:00
|
|
|
url repository
|
2016-03-17 21:04:08 +03:00
|
|
|
}
|
2016-02-11 06:29:27 +03:00
|
|
|
}
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
|
2018-05-02 20:49:57 +03:00
|
|
|
ext.kotlin_version = '1.2.41'
|
2018-07-13 17:16:37 +03:00
|
|
|
ext.support_library_version = '26.1.0'
|
2018-07-24 13:44:24 +03:00
|
|
|
ext.jacoco_version = '0.8.1'
|
2018-02-23 02:39:11 +03:00
|
|
|
|
2018-03-21 20:50:11 +03:00
|
|
|
if (gradle.mozconfig.substs.MOZ_ANDROID_GOOGLE_PLAY_SERVICES) {
|
2018-07-13 15:40:03 +03:00
|
|
|
ext.google_play_services_version = '15.0.1'
|
2018-03-21 20:50:11 +03:00
|
|
|
}
|
|
|
|
|
2015-10-22 01:07:55 +03:00
|
|
|
dependencies {
|
2019-01-23 17:48:12 +03:00
|
|
|
classpath 'org.mozilla.apilint:apilint:0.1.7'
|
2018-09-04 23:33:00 +03:00
|
|
|
classpath 'com.android.tools.build:gradle:3.1.4'
|
2017-10-26 21:00:36 +03:00
|
|
|
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
|
2018-12-19 02:54:08 +03:00
|
|
|
classpath 'org.apache.commons:commons-exec:1.3'
|
2018-02-23 02:39:11 +03:00
|
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 02:54:08 +03:00
|
|
|
// A stream that processes bytes line by line, prepending a tag before sending
|
|
|
|
// each line to Gradle's logging.
|
|
|
|
class TaggedLogOutputStream extends org.apache.commons.exec.LogOutputStream {
|
|
|
|
String tag
|
|
|
|
Logger logger
|
|
|
|
|
|
|
|
TaggedLogOutputStream(tag, logger) {
|
|
|
|
this.tag = tag
|
|
|
|
this.logger = logger
|
|
|
|
}
|
|
|
|
|
|
|
|
void processLine(String line, int level) {
|
|
|
|
logger.lifecycle("${this.tag} ${line}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ext.geckoBinariesOnlyIf = { task ->
|
|
|
|
// Never for official builds.
|
|
|
|
if (mozconfig.substs.MOZILLA_OFFICIAL) {
|
|
|
|
rootProject.logger.lifecycle("Skipping task ${task.path} because: MOZILLA_OFFICIAL")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-10-19 23:49:45 +03:00
|
|
|
// Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale. This
|
|
|
|
// causes the
|
|
|
|
//
|
2018-12-19 02:54:08 +03:00
|
|
|
// |mach build| > |mach gradle| >
|
|
|
|
// |mach build mobile/android/base/generated_android_code_and_resources| >
|
|
|
|
// AndroidManifest.xml > strings.xml > multi/brand.dtd
|
2017-10-19 23:49:45 +03:00
|
|
|
//
|
|
|
|
// 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.
|
2018-12-19 02:54:08 +03:00
|
|
|
if ('multi' == System.env.AB_CD) {
|
|
|
|
rootProject.logger.lifecycle("Skipping task ${task.path} because: AB_CD=multi")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-11-06 16:23:47 +03:00
|
|
|
// Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
|
|
|
|
// and code generation themselves.
|
2018-12-19 02:54:08 +03:00
|
|
|
if ('1' == System.env.IS_LANGUAGE_REPACK) {
|
|
|
|
rootProject.logger.lifecycle("Skipping task ${task.path} because: IS_LANGUAGE_REPACK")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
rootProject.logger.lifecycle("Executing task ${task.path}")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
task machBuildGeneratedAndroidCodeAndResources(type: Exec) {
|
|
|
|
onlyIf rootProject.ext.geckoBinariesOnlyIf
|
|
|
|
|
|
|
|
workingDir "${topsrcdir}"
|
|
|
|
|
|
|
|
commandLine mozconfig.substs.PYTHON
|
|
|
|
args "${topsrcdir}/mach"
|
|
|
|
args 'build'
|
|
|
|
args 'mobile/android/base/generated_android_code_and_resources'
|
|
|
|
|
|
|
|
// Add `-v` if we're running under `--info` (or `--debug`).
|
|
|
|
if (project.logger.isEnabled(LogLevel.INFO)) {
|
|
|
|
args '-v'
|
2018-11-28 22:47:48 +03:00
|
|
|
}
|
2018-12-19 02:54:08 +03:00
|
|
|
|
|
|
|
// `path` is like `:machBuildGeneratedAndroidCodeAndResources`.
|
|
|
|
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
|
|
|
errorOutput = standardOutput
|
2018-11-28 22:47:48 +03:00
|
|
|
}
|
|
|
|
|
2018-12-19 02:01:16 +03:00
|
|
|
// Why |mach build mobile/android/base/...| and |mach build faster|? |mach
|
|
|
|
// build faster| generates dependentlibs.list, which in turn depends on compiled
|
|
|
|
// code. That causes a circular dependency between Java compilation/JNI wrapper
|
|
|
|
// generation/native code compilation. So we have the special target for
|
|
|
|
// Android-specific generated code, and the |mach build faster| target for all
|
|
|
|
// the stuff that goes into the omnijar.
|
|
|
|
task machBuildFaster(type: Exec) {
|
|
|
|
onlyIf rootProject.ext.geckoBinariesOnlyIf
|
|
|
|
|
|
|
|
workingDir "${topsrcdir}"
|
|
|
|
|
|
|
|
commandLine mozconfig.substs.PYTHON
|
|
|
|
args "${topsrcdir}/mach"
|
|
|
|
args 'build'
|
|
|
|
args 'faster'
|
|
|
|
|
|
|
|
// Add `-v` if we're running under `--info` (or `--debug`).
|
|
|
|
if (project.logger.isEnabled(LogLevel.INFO)) {
|
|
|
|
args '-v'
|
|
|
|
}
|
|
|
|
|
|
|
|
// `path` is like `:machBuildFaster`.
|
|
|
|
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
|
|
|
errorOutput = standardOutput
|
|
|
|
}
|
|
|
|
|
|
|
|
def createMachStagePackageTask(name) {
|
|
|
|
return task(name, type: Exec) {
|
|
|
|
onlyIf rootProject.ext.geckoBinariesOnlyIf
|
|
|
|
|
|
|
|
dependsOn rootProject.machBuildFaster
|
|
|
|
|
|
|
|
// We'd prefer to take these from the :omnijar project directly, but
|
|
|
|
// it's awkward to reach across projects at evaluation time, so we
|
|
|
|
// duplicate the list here.
|
|
|
|
inputs.dir "${topsrcdir}/mobile/android/chrome"
|
|
|
|
inputs.dir "${topsrcdir}/mobile/android/components"
|
|
|
|
inputs.dir "${topsrcdir}/mobile/android/locales"
|
|
|
|
inputs.dir "${topsrcdir}/mobile/android/modules"
|
|
|
|
inputs.dir "${topsrcdir}/mobile/android/themes"
|
|
|
|
inputs.dir "${topsrcdir}/toolkit"
|
|
|
|
|
|
|
|
workingDir "${topobjdir}"
|
|
|
|
|
|
|
|
// We'd prefer this to be a `mach` invocation, but `mach build
|
|
|
|
// mobile/android/installer/stage-package` doesn't work as expected.
|
|
|
|
commandLine mozconfig.substs.GMAKE
|
|
|
|
args '-C'
|
|
|
|
args "${topobjdir}/mobile/android/installer"
|
|
|
|
args 'stage-package'
|
|
|
|
|
|
|
|
outputs.file "${topobjdir}/dist/fennec/assets/${mozconfig.substs.ANDROID_CPU_ARCH}/libxul.so"
|
|
|
|
outputs.file "${topobjdir}/dist/fennec/lib/${mozconfig.substs.ANDROID_CPU_ARCH}/libmozglue.so"
|
|
|
|
|
|
|
|
// `path` is like `:machStagePackage`.
|
|
|
|
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
|
|
|
errorOutput = standardOutput
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
createMachStagePackageTask("machStagePackageForFennec").with {
|
|
|
|
outputs.file "${topobjdir}/dist/fennec/assets/omni.ja"
|
|
|
|
}
|
|
|
|
|
|
|
|
createMachStagePackageTask("machStagePackageForGeckoview").with {
|
|
|
|
args 'MOZ_GECKOVIEW_JAR=1'
|
|
|
|
outputs.file "${topobjdir}/dist/geckoview/assets/omni.ja"
|
|
|
|
// Avoid races between stage-package invocations.
|
|
|
|
mustRunAfter tasks["machStagePackageForFennec"]
|
|
|
|
}
|
|
|
|
|
2015-10-22 01:07:55 +03:00
|
|
|
afterEvaluate {
|
2018-05-01 07:22:54 +03: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 16:12:20 +03: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 07:22:54 +03:00
|
|
|
// Turn all remaining warnings into errors,
|
|
|
|
// unless marked by @SuppressWarnings.
|
|
|
|
"-Werror"]
|
|
|
|
}
|
2018-07-13 15:40:03 +03: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 07:22:54 +03:00
|
|
|
}
|
|
|
|
|
2015-10-22 01:07:55 +03:00
|
|
|
if (!hasProperty('android')) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
android.applicationVariants.all {
|
2018-12-19 02:54:08 +03:00
|
|
|
preBuild.dependsOn rootProject.machBuildGeneratedAndroidCodeAndResources
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
android.libraryVariants.all {
|
2018-12-19 02:54:08 +03:00
|
|
|
preBuild.dependsOn rootProject.machBuildGeneratedAndroidCodeAndResources
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
apply plugin: 'idea'
|
|
|
|
|
|
|
|
idea {
|
|
|
|
project {
|
2018-08-22 22:15:42 +03:00
|
|
|
languageLevel = '1.8'
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
2015-10-21 01:30:44 +03: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-03 01:57:12 +03: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-21 01:30:44 +03: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-03 01:57:12 +03:00
|
|
|
.findAll({!it.equals('mobile/')}))
|
2015-10-21 01:30:44 +03: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-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
task wrapper(type: Wrapper) {
|
|
|
|
}
|