Bug 1449132 [wpt PR 10194] - [css-grid] Fix resolution of percentage paddings and...
[gecko.git] / build.gradle
blob09b3286300a9a973408b20c5086f7bda661c629a
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.1.51'
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 {
103         if (!hasProperty('android')) {
104             return
105         }
106         android.applicationVariants.all {
107             preBuild.dependsOn rootProject.generateCodeAndResources
108         }
109         android.libraryVariants.all {
110             preBuild.dependsOn rootProject.generateCodeAndResources
111         }
112     }
115 apply plugin: 'idea'
117 idea {
118     project {
119         languageLevel = '1.7'
120     }
122     module {
123         // Object directories take a huge amount of time for IntelliJ to index.
124         // Exclude them.  Convention is that object directories start with obj.
125         // IntelliJ is clever and will not exclude the parts of the object
126         // directory that are referenced, if there are any.  In practice,
127         // indexing the entirety of the tree is taking too long, so exclude all
128         // but mobile/.
129         def topsrcdirURI = file(topsrcdir).toURI()
130         excludeDirs += files(file(topsrcdir)
131             .listFiles({it.isDirectory()} as FileFilter)
132             .collect({topsrcdirURI.relativize(it.toURI()).toString()}) // Relative paths.
133             .findAll({!it.equals('mobile/')}))
135         // If topobjdir is below topsrcdir, hide only some portions of that tree.
136         def topobjdirURI = file(topobjdir).toURI()
137         if (!topsrcdirURI.relativize(topobjdirURI).isAbsolute()) {
138             excludeDirs -= file(topobjdir)
139             excludeDirs += files(file(topobjdir).listFiles())
140             excludeDirs -= file("${topobjdir}/gradle")
141         }
143         if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
144             excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust")
145         }
146     }
149 task wrapper(type: Wrapper) {