Bug 1509459 - Get the flexbox highlighter state if the highlighter is ready in the...
[gecko.git] / build.gradle
blobc05c0951905ff5933aba6805552f5726e210c0d6
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     }
49     ext.kotlin_version = '1.2.41'
50     ext.support_library_version = '26.1.0'
51     ext.jacoco_version = '0.8.1'
53     if (gradle.mozconfig.substs.MOZ_ANDROID_GOOGLE_PLAY_SERVICES) {
54         ext.google_play_services_version = '15.0.1'
55     }
57     dependencies {
58         classpath 'org.mozilla.apilint:apilint:0.1.4'
59         classpath 'com.android.tools.build:gradle:3.1.4'
60         classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
61         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
62     }
65 if ('multi' == System.env.AB_CD) {
66     // Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale.  This
67     // causes the
68     //
69     // |mach build| > |mach gradle| > |make gradle-targets| > AndroidManifest.xml > strings.xml > multi/brand.dtd
70     //
71     // dependency chain to fail, since multi isn't a real locale.  To avoid
72     // this, if Gradle is invoked with AB_CD=multi, we don't invoke Make at all.
73     task generateCodeAndResources()
74 } else if (System.env.IS_LANGUAGE_REPACK == '1') {
75     // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
76     // and code generation themselves.
77     task generateCodeAndResources()
78 } else {
79     task generateCodeAndResources(type:Exec) {
80         workingDir "${topobjdir}"
82         commandLine mozconfig.substs.GMAKE
83         args '-C'
84         args "${topobjdir}/mobile/android/base"
85         args 'gradle-targets'
87         // Only show the output if something went wrong.
88         ignoreExitValue = true
89         standardOutput = new ByteArrayOutputStream()
90         errorOutput = standardOutput
91         doLast {
92             if (execResult.exitValue != 0) {
93                 throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
94             }
95         }
96     }
99 afterEvaluate {
100     subprojects { project ->
101         if (project.name != 'thirdparty') {
102             tasks.withType(JavaCompile) {
103                 // Add compiler args for all code except third-party code.
104                 options.compilerArgs += [
105                     // Turn on all warnings, except...
106                     "-Xlint:all",
107                     // Deprecation, because we do use deprecated API for compatibility.
108                     "-Xlint:-deprecation",
109                     // Serial, because we don't use Java serialization.
110                     "-Xlint:-serial",
111                     // Classfile, because javac has a bug with MethodParameters attributes
112                     // with Java 7. https://bugs.openjdk.java.net/browse/JDK-8190452
113                     "-Xlint:-classfile",
114                     // Turn all remaining warnings into errors,
115                     // unless marked by @SuppressWarnings.
116                     "-Werror"]
117             }
118             if (project.name == 'app') {
119                 tasks.withType(JavaCompile) {
120                     // Turn off classfile warnings because upon updating to play services 15.0.0
121                     // a warning is being thrown from play-services-base which fails the build
122                     // (com/google/android/gms/common/api/GoogleApiClient.class):
123                     // warning: Cannot find annotation method 'value()' in type 'GuardedBy':
124                     // class file for javax.annotation.concurrent.GuardedBy not found
125                     options.compilerArgs += ["-Xlint:-classfile"]
126                 }
127             }
128         }
130         if (!hasProperty('android')) {
131             return
132         }
133         android.applicationVariants.all {
134             preBuild.dependsOn rootProject.generateCodeAndResources
135         }
136         android.libraryVariants.all {
137             preBuild.dependsOn rootProject.generateCodeAndResources
138         }
139     }
142 apply plugin: 'idea'
144 idea {
145     project {
146         languageLevel = '1.8'
147     }
149     module {
150         // Object directories take a huge amount of time for IntelliJ to index.
151         // Exclude them.  Convention is that object directories start with obj.
152         // IntelliJ is clever and will not exclude the parts of the object
153         // directory that are referenced, if there are any.  In practice,
154         // indexing the entirety of the tree is taking too long, so exclude all
155         // but mobile/.
156         def topsrcdirURI = file(topsrcdir).toURI()
157         excludeDirs += files(file(topsrcdir)
158             .listFiles({it.isDirectory()} as FileFilter)
159             .collect({topsrcdirURI.relativize(it.toURI()).toString()}) // Relative paths.
160             .findAll({!it.equals('mobile/')}))
162         // If topobjdir is below topsrcdir, hide only some portions of that tree.
163         def topobjdirURI = file(topobjdir).toURI()
164         if (!topsrcdirURI.relativize(topobjdirURI).isAbsolute()) {
165             excludeDirs -= file(topobjdir)
166             excludeDirs += files(file(topobjdir).listFiles())
167             excludeDirs -= file("${topobjdir}/gradle")
168         }
170         if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
171             excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust")
172         }
173     }
176 task wrapper(type: Wrapper) {