Bug 1486801 - Clicking on the [...] should expand the markup container. r=jdescottes
[gecko.git] / build.gradle
blob825bdb4c3944e029414f4dfd0e47d9439631277b
1 def tryInt = { string ->
2     if (string == null) {
3         return string
4     }
5     if (string.isInteger()) {
6         return string as Integer
7     }
8     return string
11 allprojects {
12     // Expose the per-object-directory configuration to all projects.
13     ext {
14         mozconfig = gradle.mozconfig
15         topsrcdir = gradle.mozconfig.topsrcdir
16         topobjdir = gradle.mozconfig.topobjdir
18         compileSdkVersion = tryInt(mozconfig.substs.ANDROID_COMPILE_SDK_VERSION)
19         targetSdkVersion = tryInt(mozconfig.substs.ANDROID_TARGET_SDK)
20         minSdkVersion = tryInt(mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION)
21         manifestPlaceholders = [
22             ANDROID_PACKAGE_NAME: mozconfig.substs.ANDROID_PACKAGE_NAME,
23             ANDROID_TARGET_SDK: mozconfig.substs.ANDROID_TARGET_SDK,
24             MOZ_ANDROID_MIN_SDK_VERSION: mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION,
25             MOZ_ANDROID_SHARED_ID: "${mozconfig.substs.ANDROID_PACKAGE_NAME}.sharedID",
26         ]
27     }
29     repositories {
30         gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
31             maven {
32                 url repository
33             }
34         }
35     }
38 buildDir "${topobjdir}/gradle/build"
40 buildscript {
41     repositories {
42         gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
43             maven {
44                 url repository
45             }
46         }
47         // For in tree plugins.
48         maven {
49             url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
50         }
51     }
53     ext.kotlin_version = '1.2.41'
54     ext.support_library_version = '26.1.0'
55     ext.jacoco_version = '0.8.1'
57     if (gradle.mozconfig.substs.MOZ_ANDROID_GOOGLE_PLAY_SERVICES) {
58         ext.google_play_services_version = '15.0.1'
59     }
61     dependencies {
62         classpath 'com.android.tools.build:gradle:3.1.0'
63         classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
64         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
65     }
68 if ('multi' == System.env.AB_CD) {
69     // Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale.  This
70     // causes the
71     //
72     // |mach build| > |mach gradle| > |make gradle-targets| > AndroidManifest.xml > strings.xml > multi/brand.dtd
73     //
74     // dependency chain to fail, since multi isn't a real locale.  To avoid
75     // this, if Gradle is invoked with AB_CD=multi, we don't invoke Make at all.
76     task generateCodeAndResources()
77 } else if (System.env.IS_LANGUAGE_REPACK == '1') {
78     // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
79     // and code generation themselves.
80     task generateCodeAndResources()
81 } else {
82     task generateCodeAndResources(type:Exec) {
83         workingDir "${topobjdir}"
85         commandLine mozconfig.substs.GMAKE
86         args '-C'
87         args "${topobjdir}/mobile/android/base"
88         args 'gradle-targets'
90         // Only show the output if something went wrong.
91         ignoreExitValue = true
92         standardOutput = new ByteArrayOutputStream()
93         errorOutput = standardOutput
94         doLast {
95             if (execResult.exitValue != 0) {
96                 throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
97             }
98         }
99     }
102 afterEvaluate {
103     subprojects { project ->
104         if (project.name != 'thirdparty') {
105             tasks.withType(JavaCompile) {
106                 // Add compiler args for all code except third-party code.
107                 options.compilerArgs += [
108                     // Turn on all warnings, except...
109                     "-Xlint:all",
110                     // Deprecation, because we do use deprecated API for compatibility.
111                     "-Xlint:-deprecation",
112                     // Serial, because we don't use Java serialization.
113                     "-Xlint:-serial",
114                     // Classfile, because javac has a bug with MethodParameters attributes
115                     // with Java 7. https://bugs.openjdk.java.net/browse/JDK-8190452
116                     "-Xlint:-classfile",
117                     // Turn all remaining warnings into errors,
118                     // unless marked by @SuppressWarnings.
119                     "-Werror"]
120             }
121             if (project.name == 'app') {
122                 tasks.withType(JavaCompile) {
123                     // Turn off classfile warnings because upon updating to play services 15.0.0
124                     // a warning is being thrown from play-services-base which fails the build
125                     // (com/google/android/gms/common/api/GoogleApiClient.class):
126                     // warning: Cannot find annotation method 'value()' in type 'GuardedBy':
127                     // class file for javax.annotation.concurrent.GuardedBy not found
128                     options.compilerArgs += ["-Xlint:-classfile"]
129                 }
130             }
131         }
133         if (!hasProperty('android')) {
134             return
135         }
136         android.applicationVariants.all {
137             preBuild.dependsOn rootProject.generateCodeAndResources
138         }
139         android.libraryVariants.all {
140             preBuild.dependsOn rootProject.generateCodeAndResources
141         }
142     }
145 apply plugin: 'idea'
147 idea {
148     project {
149         languageLevel = '1.7'
150     }
152     module {
153         // Object directories take a huge amount of time for IntelliJ to index.
154         // Exclude them.  Convention is that object directories start with obj.
155         // IntelliJ is clever and will not exclude the parts of the object
156         // directory that are referenced, if there are any.  In practice,
157         // indexing the entirety of the tree is taking too long, so exclude all
158         // but mobile/.
159         def topsrcdirURI = file(topsrcdir).toURI()
160         excludeDirs += files(file(topsrcdir)
161             .listFiles({it.isDirectory()} as FileFilter)
162             .collect({topsrcdirURI.relativize(it.toURI()).toString()}) // Relative paths.
163             .findAll({!it.equals('mobile/')}))
165         // If topobjdir is below topsrcdir, hide only some portions of that tree.
166         def topobjdirURI = file(topobjdir).toURI()
167         if (!topsrcdirURI.relativize(topobjdirURI).isAbsolute()) {
168             excludeDirs -= file(topobjdir)
169             excludeDirs += files(file(topobjdir).listFiles())
170             excludeDirs -= file("${topobjdir}/gradle")
171         }
173         if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
174             excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust")
175         }
176     }
179 task wrapper(type: Wrapper) {