Bug 1460771 [wpt PR 10958] - Compute correct sticky box constraints within scrollable...
[gecko.git] / build.gradle
blobdcb8fbd1cb85b1d29922ebb4316a7525b1f3be43
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 = '23.4.0'
56     if (gradle.mozconfig.substs.MOZ_ANDROID_GOOGLE_PLAY_SERVICES) {
57         ext.google_play_services_version = '8.4.0'
58     }
60     dependencies {
61         classpath 'com.android.tools.build:gradle:3.0.1'
62         classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
63         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
64     }
67 if ('multi' == System.env.AB_CD) {
68     // Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale.  This
69     // causes the
70     //
71     // |mach build| > |mach gradle| > |make gradle-targets| > AndroidManifest.xml > strings.xml > multi/brand.dtd
72     //
73     // dependency chain to fail, since multi isn't a real locale.  To avoid
74     // this, if Gradle is invoked with AB_CD=multi, we don't invoke Make at all.
75     task generateCodeAndResources()
76 } else if (System.env.IS_LANGUAGE_REPACK == '1') {
77     // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
78     // and code generation themselves.
79     task generateCodeAndResources()
80 } else {
81     task generateCodeAndResources(type:Exec) {
82         workingDir "${topobjdir}"
84         commandLine mozconfig.substs.GMAKE
85         args '-C'
86         args "${topobjdir}/mobile/android/base"
87         args 'gradle-targets'
89         // Only show the output if something went wrong.
90         ignoreExitValue = true
91         standardOutput = new ByteArrayOutputStream()
92         errorOutput = standardOutput
93         doLast {
94             if (execResult.exitValue != 0) {
95                 throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
96             }
97         }
98     }
101 afterEvaluate {
102     subprojects { project ->
103         if (project.name != 'thirdparty') {
104             tasks.withType(JavaCompile) {
105                 // Add compiler args for all code except third-party code.
106                 options.compilerArgs += [
107                     // Turn on all warnings, except...
108                     "-Xlint:all",
109                     // Deprecation, because we do use deprecated API for compatibility.
110                     "-Xlint:-deprecation",
111                     // Serial, because we don't use Java serialization.
112                     "-Xlint:-serial",
113                     // Turn all remaining warnings into errors,
114                     // unless marked by @SuppressWarnings.
115                     "-Werror"]
116             }
117         }
119         if (!hasProperty('android')) {
120             return
121         }
122         android.applicationVariants.all {
123             preBuild.dependsOn rootProject.generateCodeAndResources
124         }
125         android.libraryVariants.all {
126             preBuild.dependsOn rootProject.generateCodeAndResources
127         }
128     }
131 apply plugin: 'idea'
133 idea {
134     project {
135         languageLevel = '1.7'
136     }
138     module {
139         // Object directories take a huge amount of time for IntelliJ to index.
140         // Exclude them.  Convention is that object directories start with obj.
141         // IntelliJ is clever and will not exclude the parts of the object
142         // directory that are referenced, if there are any.  In practice,
143         // indexing the entirety of the tree is taking too long, so exclude all
144         // but mobile/.
145         def topsrcdirURI = file(topsrcdir).toURI()
146         excludeDirs += files(file(topsrcdir)
147             .listFiles({it.isDirectory()} as FileFilter)
148             .collect({topsrcdirURI.relativize(it.toURI()).toString()}) // Relative paths.
149             .findAll({!it.equals('mobile/')}))
151         // If topobjdir is below topsrcdir, hide only some portions of that tree.
152         def topobjdirURI = file(topobjdir).toURI()
153         if (!topsrcdirURI.relativize(topobjdirURI).isAbsolute()) {
154             excludeDirs -= file(topobjdir)
155             excludeDirs += files(file(topobjdir).listFiles())
156             excludeDirs -= file("${topobjdir}/gradle")
157         }
159         if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
160             excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust")
161         }
162     }
165 task wrapper(type: Wrapper) {