2019-05-13 19:31:46 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2019-03-19 15:56:20 +03:00
|
|
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
2019-05-13 19:31:46 +03:00
|
|
|
// This is based off:
|
|
|
|
// https://github.com/mozilla/application-services/blob/84e077d1534dc287bbd472da658ce22eea5af032/build.gradle
|
2019-03-19 15:56:20 +03:00
|
|
|
|
|
|
|
buildscript {
|
2019-05-14 20:01:16 +03:00
|
|
|
ext.kotlin_version = '1.3.31'
|
2019-05-15 17:39:41 +03:00
|
|
|
ext.android_components_version = '0.52.0'
|
2019-05-13 17:23:47 +03:00
|
|
|
ext.jna_version = '5.2.0'
|
2019-03-19 15:56:20 +03:00
|
|
|
|
|
|
|
ext.build = [
|
2019-05-15 17:39:41 +03:00
|
|
|
compileSdkVersion: 28,
|
|
|
|
targetSdkVersion: 28,
|
2019-03-19 15:56:20 +03:00
|
|
|
minSdkVersion: 21, // So that we can publish for aarch64.
|
|
|
|
]
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
google()
|
|
|
|
jcenter()
|
|
|
|
maven {
|
|
|
|
url "https://plugins.gradle.org/m2/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dependencies {
|
2019-05-09 13:01:10 +03:00
|
|
|
classpath 'com.android.tools.build:gradle:3.3.2'
|
2019-03-19 15:56:20 +03:00
|
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
|
|
|
|
|
|
// Publish.
|
|
|
|
classpath 'digital.wup:android-maven-publish:3.6.2'
|
|
|
|
|
2019-05-13 17:23:47 +03:00
|
|
|
classpath 'gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.8.1'
|
2019-03-19 15:56:20 +03:00
|
|
|
|
|
|
|
// Yes, this is unusual. We want to access some host-specific
|
|
|
|
// computation at build time.
|
2019-05-13 17:23:47 +03:00
|
|
|
classpath "net.java.dev.jna:jna:$jna_version"
|
2019-03-19 15:56:20 +03:00
|
|
|
|
2019-05-28 19:01:27 +03:00
|
|
|
// Docs generation
|
|
|
|
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.17"
|
|
|
|
|
2019-03-19 15:56:20 +03:00
|
|
|
// NOTE: Do not place your application dependencies here; they belong
|
|
|
|
// in the individual module build.gradle files
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-13 17:23:47 +03:00
|
|
|
plugins {
|
|
|
|
id("io.gitlab.arturbosch.detekt").version("1.0.0-RC14")
|
|
|
|
}
|
|
|
|
|
2019-03-19 15:56:20 +03:00
|
|
|
allprojects {
|
|
|
|
repositories {
|
|
|
|
google()
|
|
|
|
jcenter()
|
2019-05-13 17:23:47 +03:00
|
|
|
maven {
|
|
|
|
url "https://maven.mozilla.org/maven2"
|
2019-03-19 15:56:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task clean(type: Delete) {
|
|
|
|
delete rootProject.buildDir
|
|
|
|
}
|
|
|
|
|
|
|
|
// Avoid Gradle namespace collision. This is here, rather than in `buildscript
|
|
|
|
// { ... }`, to avoid issues with importing.
|
|
|
|
import com.sun.jna.Platform as DefaultPlatform
|
|
|
|
|
2019-05-13 19:31:46 +03:00
|
|
|
// application-services has hooks to download external dependencies here. This
|
|
|
|
// has been removed since `glean-core` doesn't have any external dependencies for now.
|
2019-05-13 17:23:47 +03:00
|
|
|
|
|
|
|
Properties localProperties = null
|
|
|
|
if (file('local.properties').canRead()) {
|
|
|
|
localProperties = new Properties()
|
|
|
|
localProperties.load(file('local.properties').newDataInputStream())
|
|
|
|
logger.lifecycle('Local configuration: loaded local.properties')
|
|
|
|
}
|
|
|
|
|
|
|
|
// For non-megazord builds, don't do a release build unless we explicitly want
|
|
|
|
// it (e.g. in CI, or if specified in local.properties). This avoids some cases
|
|
|
|
// where two builds of some crates are required when they wouldn't otherwise be,
|
|
|
|
// as well as improving build times for local development.
|
|
|
|
ext.nonMegazordProfile = "debug"
|
|
|
|
// Additionally, we require `--locked` in CI, but not for local builds.
|
|
|
|
// Unlike the above, this can't be overridden by `local.properties` (mainly
|
|
|
|
// because doing so seems pointless, not for any security reason)
|
|
|
|
ext.extraCargoBuildArguments = []
|
|
|
|
|
|
|
|
if (System.getenv("CI")) {
|
|
|
|
// Note: CI can still override this (and does for PRs), this
|
|
|
|
// is just the default
|
|
|
|
ext.nonMegazordProfile = "release"
|
|
|
|
ext.extraCargoBuildArguments = ["--locked"]
|
|
|
|
}
|
|
|
|
|
|
|
|
if (localProperties != null) {
|
|
|
|
String localNonMegazordProfile = localProperties.getProperty(
|
|
|
|
"application-services.nonmegazord-profile")
|
|
|
|
if (localNonMegazordProfile != null) {
|
|
|
|
ext.nonMegazordProfile = localNonMegazordProfile
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The Cargo targets to invoke. The mapping from short name to target
|
|
|
|
// triple is defined by the `rust-android-gradle` plugin.
|
|
|
|
// They can be overwritten in `local.properties` by the `rust.targets`
|
|
|
|
// attribute.
|
|
|
|
ext.rustTargets = [
|
|
|
|
'arm',
|
|
|
|
'arm64',
|
|
|
|
'x86_64',
|
|
|
|
'x86',
|
|
|
|
]
|
|
|
|
|
|
|
|
// Generate libs for our current platform so we can run unit tests.
|
|
|
|
switch (DefaultPlatform.RESOURCE_PREFIX) {
|
|
|
|
case 'darwin':
|
|
|
|
ext.rustTargets += 'darwin'
|
|
|
|
break
|
|
|
|
case 'linux-x86-64':
|
|
|
|
ext.rustTargets += 'linux-x86-64'
|
|
|
|
break
|
|
|
|
case 'win32-x86-64':
|
|
|
|
ext.rustTargets += 'win32-x86-64-msvc'
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
subprojects {
|
|
|
|
apply plugin: 'digital.wup.android-maven-publish'
|
|
|
|
|
|
|
|
// This allows to invoke Gradle like `./gradlew publishToRootProjectBuildDir` (equivalent to
|
|
|
|
// `./gradlew publish`) and also `./gradlew publishToProjectBuildDir`.
|
|
|
|
publishing {
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = "rootProjectBuildDir"
|
|
|
|
url "file://${project.rootProject.buildDir}/maven"
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = "projectBuildDir"
|
|
|
|
url "file://${project.buildDir}/maven"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-19 15:56:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Configure some environment variables, per toolchain, that will apply during
|
|
|
|
// the Cargo build. We assume that the `libs/` directory has been populated
|
|
|
|
// before invoking Gradle (or Cargo).
|
|
|
|
ext.cargoExec = { spec, toolchain ->
|
2019-05-13 17:23:47 +03:00
|
|
|
// Intentionally empty. Removing this block breaks build.
|
|
|
|
}
|
|
|
|
|
|
|
|
detekt {
|
|
|
|
// The version number is duplicated, please refer to plugins block for more details
|
|
|
|
toolVersion = "1.0.0-RC14"
|
|
|
|
input = files("${projectDir}/glean-core", "${projectDir}/samples/android", "buildSrc")
|
|
|
|
filters = ".*test.*,.*/resources/.*,.*/tmp/.*,.*/build/.*"
|
|
|
|
failFast = false
|
2019-05-14 17:54:33 +03:00
|
|
|
config = files("${projectDir}/.detekt.yml")
|
|
|
|
buildUponDefaultConfig = true
|
2019-05-13 17:23:47 +03:00
|
|
|
reports {
|
|
|
|
xml.enabled = false
|
|
|
|
}
|
2019-03-19 15:56:20 +03:00
|
|
|
}
|
|
|
|
|
2019-05-13 17:23:47 +03:00
|
|
|
configurations {
|
|
|
|
ktlint
|
|
|
|
}
|
2019-03-19 15:56:20 +03:00
|
|
|
|
2019-05-13 17:23:47 +03:00
|
|
|
dependencies {
|
|
|
|
ktlint "com.github.shyiko:ktlint:0.31.0"
|
|
|
|
}
|
2019-03-19 15:56:20 +03:00
|
|
|
|
2019-05-13 17:23:47 +03:00
|
|
|
task ktlint(type: JavaExec, group: "verification") {
|
|
|
|
description = "Check Kotlin code style."
|
|
|
|
classpath = configurations.ktlint
|
|
|
|
main = "com.github.shyiko.ktlint.Main"
|
|
|
|
args "${projectDir}/glean-core/**/*.kt", "${projectDir}/samples/android/**/*.kt", "buildSrc/**/*.kt", "!**/build"
|
|
|
|
}
|
2019-03-19 15:56:20 +03:00
|
|
|
|
2019-05-13 17:23:47 +03:00
|
|
|
task ktlintFormat(type: JavaExec, group: "formatting") {
|
|
|
|
description = "Fix Kotlin code style deviations."
|
|
|
|
classpath = configurations.ktlint
|
|
|
|
main = "com.github.shyiko.ktlint.Main"
|
|
|
|
args "-F", "${projectDir}/components/**/*.kt", "${projectDir}/gradle-plugin/**/*.kt", "buildSrc/**/*.kt", "!**/build"
|
2019-03-19 15:56:20 +03:00
|
|
|
}
|