зеркало из https://github.com/mozilla/glean.git
210 строки
6.9 KiB
Groovy
210 строки
6.9 KiB
Groovy
/* 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/. */
|
|
|
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
// This is based off:
|
|
// https://github.com/mozilla/application-services/blob/84e077d1534dc287bbd472da658ce22eea5af032/build.gradle
|
|
|
|
buildscript {
|
|
// Define the version of the used dependencies in a single place, to ease
|
|
// changing them. Please note that, for using in Android-Components, the
|
|
// versions below must match the ones in that repository.
|
|
ext.versions = [
|
|
android_gradle_plugin: '7.0.0',
|
|
android_maven_publish_plugin: '3.6.2',
|
|
coroutines: '1.5.0',
|
|
jna: '5.8.0',
|
|
junit: '4.12',
|
|
mockito: '3.11.2', // This is different than a-c, but we're fine, it's only tests.
|
|
mockwebserver: '4.9.1', // This is different than a-c, but we're fine, it's only tests.
|
|
kotlin: '1.5.20',
|
|
robolectric: '4.5.1', // This is different than a-c, but we're fine, it's only tests.
|
|
rust_android_plugin: '0.9.0',
|
|
|
|
// Android X dependencies
|
|
androidx_annotation: '1.1.0',
|
|
androidx_appcompat: '1.2.0',
|
|
androidx_browser: '1.2.0',
|
|
androidx_core: '1.3.0',
|
|
androidx_espresso: '3.3.0',
|
|
androidx_junit: '1.1.2',
|
|
androidx_lifecycle_extensions: '2.2.0',
|
|
androidx_test: '1.3.0',
|
|
androidx_work: '2.4.0',
|
|
androidx_uiautomator: '2.2.0',
|
|
]
|
|
|
|
ext.build = [
|
|
ndkVersion: "21.3.6528147", // Keep it in sync in TC Dockerfile.
|
|
compileSdkVersion: 29,
|
|
targetSdkVersion: 28,
|
|
minSdkVersion: 21, // So that we can publish for aarch64.
|
|
]
|
|
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
maven {
|
|
url "https://plugins.gradle.org/m2/"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath "com.android.tools.build:gradle:$versions.android_gradle_plugin"
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
|
|
|
|
// Publish.
|
|
classpath "digital.wup:android-maven-publish:$versions.android_maven_publish_plugin"
|
|
|
|
classpath "org.mozilla.rust-android-gradle:plugin:$versions.rust_android_plugin"
|
|
|
|
// Yes, this is unusual. We want to access some host-specific
|
|
// computation at build time.
|
|
classpath "net.java.dev.jna:jna:$versions.jna"
|
|
|
|
// NOTE: Do not place your application dependencies here; they belong
|
|
// in the individual module build.gradle files
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id("io.gitlab.arturbosch.detekt").version("1.18.1")
|
|
}
|
|
|
|
allprojects {
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
maven {
|
|
url "https://maven.mozilla.org/maven2"
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
// application-services has hooks to download external dependencies here. This
|
|
// has been removed since `glean-core` doesn't have any external dependencies for now.
|
|
|
|
Properties localProperties = null
|
|
if (file('local.properties').canRead()) {
|
|
localProperties = new Properties()
|
|
localProperties.load(file('local.properties').newDataInputStream())
|
|
logger.lifecycle('Local configuration: loaded local.properties')
|
|
}
|
|
|
|
// Default to debug builds, but force release builds on CI
|
|
ext.cargoProfile = "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.cargoProfile = "release"
|
|
ext.extraCargoBuildArguments = ["--locked"]
|
|
}
|
|
|
|
// 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':
|
|
case 'darwin-x86-64':
|
|
case 'darwin-aarch64':
|
|
ext.nativeRustTarget = 'darwin'
|
|
break
|
|
case 'linux-x86-64':
|
|
ext.nativeRustTarget = 'linux-x86-64'
|
|
break
|
|
case 'win32-x86-64':
|
|
ext.nativeRustTarget = 'win32-x86-64-gnu'
|
|
break
|
|
}
|
|
ext.rustTargets += ext.nativeRustTarget
|
|
|
|
subprojects {
|
|
apply plugin: 'digital.wup.android-maven-publish'
|
|
|
|
// Enable Kotlin warnings as errors for all modules
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
|
// TODO: Re-enable when we fixed all those warnings.
|
|
//kotlinOptions.allWarningsAsErrors = true
|
|
kotlinOptions {
|
|
// FIXME: Currently required for `toUByteArray` in the ping uploader.
|
|
// Should probably be handled with an annotation.
|
|
freeCompilerArgs += [
|
|
"-Xuse-experimental=kotlin.ExperimentalUnsignedTypes",
|
|
]
|
|
}
|
|
}
|
|
|
|
// 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"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
detekt {
|
|
input = files("${projectDir}/glean-core", "${projectDir}/samples/android", "buildSrc")
|
|
failFast = false
|
|
config = files("${projectDir}/.detekt.yml")
|
|
buildUponDefaultConfig = true
|
|
reports {
|
|
xml.enabled = false
|
|
}
|
|
}
|
|
|
|
tasks.withType(io.gitlab.arturbosch.detekt.Detekt) {
|
|
exclude(".*test.*,.*/resources/.*,.*/tmp/.*,.*/build/.*")
|
|
}
|
|
|
|
configurations {
|
|
ktlint
|
|
}
|
|
|
|
dependencies {
|
|
ktlint "com.github.shyiko:ktlint:0.31.0"
|
|
}
|
|
|
|
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"
|
|
}
|
|
|
|
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"
|
|
}
|