2015-10-22 01:07:55 +03:00
|
|
|
import java.util.regex.Pattern
|
|
|
|
|
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
|
|
|
|
|
|
|
compileSdkVersion = tryInt(mozconfig.substs.ANDROID_COMPILE_SDK_VERSION)
|
|
|
|
buildToolsVersion = tryInt(mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION)
|
|
|
|
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 {
|
2016-03-17 21:04:08 +03:00
|
|
|
if (gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY) {
|
|
|
|
maven {
|
|
|
|
url gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY
|
|
|
|
}
|
2016-02-11 06:29:27 +03:00
|
|
|
}
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildDir "${topobjdir}/gradle/build"
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
2016-03-17 21:04:08 +03:00
|
|
|
if (gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY) {
|
|
|
|
maven {
|
|
|
|
url gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORY
|
|
|
|
}
|
2016-02-11 06:29:27 +03:00
|
|
|
}
|
2016-03-25 23:53:58 +03:00
|
|
|
// For android-sdk-manager SNAPSHOT releases.
|
2016-03-02 07:12:04 +03:00
|
|
|
maven {
|
|
|
|
url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
|
|
|
|
}
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2016-09-23 00:31:01 +03:00
|
|
|
classpath 'com.android.tools.build:gradle:2.1.3'
|
2016-02-11 23:44:53 +03:00
|
|
|
classpath('com.stanfy.spoon:spoon-gradle-plugin:1.0.4') {
|
2015-10-22 01:07:55 +03:00
|
|
|
// Without these, we get errors linting.
|
|
|
|
exclude module: 'guava'
|
|
|
|
}
|
2016-03-02 07:12:04 +03:00
|
|
|
// Provided in tree.
|
|
|
|
classpath 'com.jakewharton.sdkmanager:gradle-plugin:1.5.0-SNAPSHOT'
|
2016-11-19 05:28:58 +03:00
|
|
|
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.1'
|
2015-10-22 01:07:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task generateCodeAndResources(type:Exec) {
|
|
|
|
workingDir "${topobjdir}"
|
|
|
|
|
|
|
|
commandLine mozconfig.substs.GMAKE
|
|
|
|
args '-C'
|
|
|
|
args "${topobjdir}/mobile/android/base"
|
|
|
|
args 'gradle-targets'
|
|
|
|
|
|
|
|
// Only show the output if something went wrong.
|
|
|
|
ignoreExitValue = true
|
|
|
|
standardOutput = new ByteArrayOutputStream()
|
|
|
|
errorOutput = standardOutput
|
|
|
|
doLast {
|
|
|
|
if (execResult.exitValue != 0) {
|
|
|
|
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Skip unit test for all build variants, unless if it was specifically requested by user.
|
|
|
|
// The enabled property for the unit test tasks is reset based on the command line task names just before the task execution.
|
|
|
|
// I bet there is a easier/cleaner way to do this, but this gets the job done for now.
|
|
|
|
Pattern pattern = Pattern.compile('.*test(.+UnitTest)?.*')
|
|
|
|
boolean startTasksIncludeTest = gradle.startParameter.taskNames.any {
|
|
|
|
taskName ->
|
|
|
|
taskName.matches(pattern)
|
|
|
|
}
|
|
|
|
gradle.taskGraph.beforeTask {
|
|
|
|
Task task ->
|
|
|
|
if (task.name.matches(pattern)) {
|
|
|
|
task.enabled = startTasksIncludeTest
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
subprojects {
|
|
|
|
if (!hasProperty('android')) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
android.applicationVariants.all {
|
|
|
|
preBuild.dependsOn rootProject.generateCodeAndResources
|
|
|
|
}
|
|
|
|
android.libraryVariants.all {
|
|
|
|
preBuild.dependsOn rootProject.generateCodeAndResources
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
apply plugin: 'idea'
|
|
|
|
|
|
|
|
idea {
|
|
|
|
project {
|
|
|
|
languageLevel = '1.7'
|
|
|
|
}
|
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) {
|
|
|
|
}
|