2021-08-10 07:49:08 +00:00
|
|
|
import org.tomlj.Toml
|
|
|
|
import org.tomlj.TomlParseResult
|
|
|
|
import org.tomlj.TomlTable
|
|
|
|
|
2023-12-08 17:46:36 +00:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
|
|
|
|
maven {
|
|
|
|
url repository
|
|
|
|
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
|
|
|
|
allowInsecureProtocol = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-07 21:19:43 +00:00
|
|
|
ext {
|
|
|
|
detekt_plugin = Versions.detekt
|
|
|
|
python_envs_plugin = Versions.python_envs_plugin
|
|
|
|
ksp_plugin = Versions.ksp_plugin
|
2023-12-15 09:19:16 +00:00
|
|
|
|
|
|
|
// Used in mobile/android/fenix/app/build.gradle
|
|
|
|
protobuf_plugin = FenixVersions.protobuf_plugin
|
2023-12-07 21:19:43 +00:00
|
|
|
}
|
2023-12-08 17:46:36 +00:00
|
|
|
|
|
|
|
dependencies {
|
2024-06-11 03:07:38 +00:00
|
|
|
classpath 'org.mozilla.apilint:apilint:0.5.3'
|
2024-07-22 14:12:27 +00:00
|
|
|
classpath ComponentsDependencies.tools_androidgradle
|
2023-12-08 17:46:36 +00:00
|
|
|
classpath 'org.apache.commons:commons-exec:1.3'
|
2024-03-04 01:45:22 +00:00
|
|
|
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.25.0'
|
2023-12-08 17:46:36 +00:00
|
|
|
classpath 'org.tomlj:tomlj:1.1.0'
|
2024-03-20 21:40:21 +00:00
|
|
|
classpath ComponentsDependencies.tools_kotlingradle
|
2023-12-15 09:19:16 +00:00
|
|
|
|
|
|
|
// Used in mobile/android/fenix/app/build.gradle
|
2024-03-20 21:40:21 +00:00
|
|
|
classpath ComponentsDependencies.androidx_safeargs
|
2024-08-27 12:40:46 +00:00
|
|
|
classpath ComponentsDependencies.osslicenses_plugin
|
2024-08-22 13:08:38 +00:00
|
|
|
classpath ComponentsDependencies.tools_benchmarkgradle
|
2023-12-15 09:19:16 +00:00
|
|
|
classpath "org.mozilla.telemetry:glean-gradle-plugin:${Versions.mozilla_glean}"
|
|
|
|
classpath "${ApplicationServicesConfig.groupId}:tooling-nimbus-gradle:${ApplicationServicesConfig.version}"
|
2023-12-08 17:46:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-07 21:19:43 +00:00
|
|
|
plugins {
|
|
|
|
id("io.gitlab.arturbosch.detekt").version("$detekt_plugin")
|
|
|
|
id("com.google.devtools.ksp").version("$ksp_plugin")
|
|
|
|
}
|
|
|
|
|
2017-06-21 17:52:30 +00:00
|
|
|
def tryInt = { string ->
|
|
|
|
if (string == null) {
|
|
|
|
return string
|
|
|
|
}
|
|
|
|
if (string.isInteger()) {
|
|
|
|
return string as Integer
|
|
|
|
}
|
|
|
|
return string
|
|
|
|
}
|
|
|
|
|
2021-08-10 07:49:08 +00:00
|
|
|
// Parses the Cargo.lock and returns the version for the given package name.
|
|
|
|
def getRustVersionFor(packageName) {
|
|
|
|
String version = null;
|
|
|
|
TomlParseResult result = Toml.parse(file("Cargo.lock").getText());
|
|
|
|
for (object in result.getArray("package").toList()) {
|
|
|
|
def table = (TomlTable) object
|
|
|
|
if (table.getString("name") == packageName) {
|
|
|
|
if (version != null) {
|
|
|
|
throw new StopExecutionException("Multiple versions for '${packageName}' found." +
|
|
|
|
" Ensure '${packageName}' is only included once.")
|
|
|
|
}
|
|
|
|
version = table.getString("version")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return version
|
|
|
|
}
|
|
|
|
|
2024-04-30 08:17:13 +00:00
|
|
|
def now() {
|
|
|
|
Instant now = Instant.now();
|
|
|
|
return now.getEpochSecond() + now.getNano() / 1_000_000_000L;
|
|
|
|
}
|
|
|
|
|
2015-10-21 22:07:55 +00:00
|
|
|
allprojects {
|
2024-04-30 08:17:13 +00:00
|
|
|
def shouldPrintBuildStatus =
|
|
|
|
System.getenv("MACH") && !System.getenv("NO_BUILDSTATUS_MESSAGES")
|
|
|
|
|
|
|
|
if (shouldPrintBuildStatus) {
|
|
|
|
// Adding new line before each line to make sure they're dumped as a separate line.
|
|
|
|
// Add profile marker to the start of the project evaluation
|
|
|
|
project.beforeEvaluate {
|
2024-04-30 08:17:13 +00:00
|
|
|
println "\nBUILDSTATUS ${now()} START_gradle:evaluate-project ${project.name}"
|
2024-04-30 08:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add profile marker to the end of the project evaluation
|
|
|
|
project.afterEvaluate {
|
2024-04-30 08:17:13 +00:00
|
|
|
println "\nBUILDSTATUS ${now()} END_gradle:evaluate-project ${project.name}"
|
2024-04-30 08:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.configureEach { task ->
|
|
|
|
// Add profile marker to the start of the gradle task
|
|
|
|
task.doFirst {
|
2024-04-30 08:17:13 +00:00
|
|
|
println "\nBUILDSTATUS ${now()} START_gradle-task ${project.name}:${task.name}"
|
2024-04-30 08:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add profile marker to the end of the gradle task
|
|
|
|
task.doLast {
|
2024-04-30 08:17:13 +00:00
|
|
|
println "\nBUILDSTATUS ${now()} END_gradle-task ${project.name}:${task.name}"
|
2024-04-30 08:17:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-21 22:07:55 +00:00
|
|
|
// Expose the per-object-directory configuration to all projects.
|
|
|
|
ext {
|
|
|
|
mozconfig = gradle.mozconfig
|
|
|
|
topsrcdir = gradle.mozconfig.topsrcdir
|
|
|
|
topobjdir = gradle.mozconfig.topobjdir
|
2017-06-21 17:52:30 +00:00
|
|
|
|
2024-03-20 21:40:21 +00:00
|
|
|
gleanVersion = Versions.mozilla_glean
|
2021-08-10 07:49:08 +00:00
|
|
|
if (gleanVersion != getRustVersionFor("glean")) {
|
|
|
|
throw new StopExecutionException("Mismatched Glean version, expected: ${gleanVersion}," +
|
|
|
|
" found ${getRustVersionFor("glean")}")
|
|
|
|
}
|
|
|
|
|
2022-01-11 19:16:02 +00:00
|
|
|
artifactSuffix = getArtifactSuffix()
|
|
|
|
versionName = getVersionName()
|
|
|
|
versionCode = computeVersionCode()
|
|
|
|
versionNumber = getVersionNumber()
|
|
|
|
buildId = getBuildId()
|
|
|
|
|
2020-04-04 03:15:56 +00:00
|
|
|
buildToolsVersion = mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION
|
2024-08-08 08:02:32 +00:00
|
|
|
compileSdkVersion = tryInt(mozconfig.substs.ANDROID_COMPILE_SDK)
|
2017-06-21 17:52:30 +00:00
|
|
|
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,
|
|
|
|
]
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
2017-07-26 18:28:07 +00:00
|
|
|
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
|
2016-03-17 18:04:08 +00:00
|
|
|
maven {
|
2017-07-26 18:28:07 +00:00
|
|
|
url repository
|
2022-01-11 19:16:01 +00:00
|
|
|
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
|
|
|
|
allowInsecureProtocol = true
|
|
|
|
}
|
2016-03-17 18:04:08 +00:00
|
|
|
}
|
2016-02-11 03:29:27 +00:00
|
|
|
}
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
2018-12-14 21:37:37 +00:00
|
|
|
|
Bug 1490144 - Add Java and Kotlin code indexing using semanticdb compiler plugins r=nalexander,asuth,emilio,geckoview-reviewers,owlish
When the Mozsearch plugin is enabled and when we compile the android
target, this uses the semanticdb-javac and semanticdb-kotlinc compiler
plugins to generate semanticdb files during the compilation process.
In order to index all files, all files need to be compiled at least
once, so this adds a `mach android compile-all` command to ensure that,
otherwise some examples and AndroidTests were not necessarily compiled.
Note that the AndroidTests do not have a release configuration so will
not be indexed when we build in release mode. The existing searchfox
mozconfigs are all set to debug so this should not be an issue.
To build the android-gradle-dependencies toolchain, all dependencies
must be accessible from the root build.gradle, so this also adds a flag
--download-all-gradle-dependencies to ignore conditional dependency
uses in gradle code.
Differential Revision: https://phabricator.services.mozilla.com/D192925
2023-11-16 16:27:24 +00:00
|
|
|
// Use the semanticdb-javac and semanticdb-kotlinc plugins to generate semanticdb files for Searchfox
|
|
|
|
if (mozconfig.substs.ENABLE_MOZSEARCH_PLUGIN || mozconfig.substs.DOWNLOAD_ALL_GRADLE_DEPENDENCIES) {
|
|
|
|
def targetRoot = new File(topobjdir, "mozsearch_java_index")
|
2024-08-23 23:52:04 +00:00
|
|
|
def semanticdbJavacVersion = "com.sourcegraph:semanticdb-javac:0.10.3"
|
2024-02-28 09:31:10 +00:00
|
|
|
def semanticdbKotlincVersion = "com.sourcegraph:semanticdb-kotlinc:0.4.0"
|
Bug 1490144 - Add Java and Kotlin code indexing using semanticdb compiler plugins r=nalexander,asuth,emilio,geckoview-reviewers,owlish
When the Mozsearch plugin is enabled and when we compile the android
target, this uses the semanticdb-javac and semanticdb-kotlinc compiler
plugins to generate semanticdb files during the compilation process.
In order to index all files, all files need to be compiled at least
once, so this adds a `mach android compile-all` command to ensure that,
otherwise some examples and AndroidTests were not necessarily compiled.
Note that the AndroidTests do not have a release configuration so will
not be indexed when we build in release mode. The existing searchfox
mozconfigs are all set to debug so this should not be an issue.
To build the android-gradle-dependencies toolchain, all dependencies
must be accessible from the root build.gradle, so this also adds a flag
--download-all-gradle-dependencies to ignore conditional dependency
uses in gradle code.
Differential Revision: https://phabricator.services.mozilla.com/D192925
2023-11-16 16:27:24 +00:00
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
def addDependencyToConfigurationIfExists = { configurationName, dependency ->
|
|
|
|
def configuration = configurations.findByName(configurationName)
|
|
|
|
if (configuration != null) {
|
|
|
|
dependencies.add(configurationName, dependency)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addDependencyToConfigurationIfExists("compileOnly", semanticdbJavacVersion)
|
|
|
|
addDependencyToConfigurationIfExists("testCompileOnly", semanticdbJavacVersion)
|
|
|
|
addDependencyToConfigurationIfExists("androidTestCompileOnly", semanticdbJavacVersion)
|
|
|
|
addDependencyToConfigurationIfExists("kotlinCompilerPluginClasspath", semanticdbKotlincVersion)
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
options.compilerArgs += [
|
|
|
|
"-Xplugin:semanticdb -sourceroot:${topsrcdir} -targetroot:${targetRoot}",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
|
|
|
|
compilerOptions.freeCompilerArgs.addAll([
|
|
|
|
"-P", "plugin:semanticdb-kotlinc:sourceroot=${topsrcdir}",
|
|
|
|
"-P", "plugin:semanticdb-kotlinc:targetroot=${targetRoot}",
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-14 21:37:37 +00:00
|
|
|
task downloadDependencies() {
|
|
|
|
description 'Download all dependencies to the Gradle cache'
|
|
|
|
doLast {
|
|
|
|
configurations.each { configuration ->
|
|
|
|
if (configuration.canBeResolved) {
|
|
|
|
configuration.allDependencies.each { dependency ->
|
|
|
|
try {
|
|
|
|
configuration.files(dependency)
|
|
|
|
} catch(e) {
|
|
|
|
println("Could not resolve ${configuration.name} -> ${dependency.name}")
|
|
|
|
println(" > ${e.message}")
|
|
|
|
if (e.cause) {
|
|
|
|
println(" >> ${e.cause}")
|
|
|
|
if (e.cause.cause) {
|
|
|
|
println(" >> ${e.cause.cause}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
println("")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
buildDir "${topobjdir}/gradle/build"
|
|
|
|
|
2018-12-18 23:54:08 +00:00
|
|
|
// A stream that processes bytes line by line, prepending a tag before sending
|
|
|
|
// each line to Gradle's logging.
|
|
|
|
class TaggedLogOutputStream extends org.apache.commons.exec.LogOutputStream {
|
|
|
|
String tag
|
|
|
|
Logger logger
|
|
|
|
|
|
|
|
TaggedLogOutputStream(tag, logger) {
|
|
|
|
this.tag = tag
|
|
|
|
this.logger = logger
|
|
|
|
}
|
|
|
|
|
|
|
|
void processLine(String line, int level) {
|
|
|
|
logger.lifecycle("${this.tag} ${line}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ext.geckoBinariesOnlyIf = { task ->
|
2019-05-09 20:39:10 +00:00
|
|
|
// Never when Gradle was invoked within `mach build`.
|
|
|
|
if ('1' == System.env.GRADLE_INVOKED_WITHIN_MACH_BUILD) {
|
|
|
|
rootProject.logger.lifecycle("Skipping task ${task.path} because: within `mach build`")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-12-18 23:54:08 +00:00
|
|
|
// Never for official builds.
|
|
|
|
if (mozconfig.substs.MOZILLA_OFFICIAL) {
|
|
|
|
rootProject.logger.lifecycle("Skipping task ${task.path} because: MOZILLA_OFFICIAL")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-11-03 21:36:26 +00:00
|
|
|
// Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale, and
|
|
|
|
// `MOZ_CHROME_MULTILOCALE`. To avoid failures, if Gradle is invoked with
|
|
|
|
// either, we don't invoke Make at all; this allows a multi-locale omnijar
|
|
|
|
// to be consumed without modification.
|
|
|
|
if ('multi' == System.env.AB_CD || System.env.MOZ_CHROME_MULTILOCALE) {
|
2018-12-18 23:54:08 +00:00
|
|
|
rootProject.logger.lifecycle("Skipping task ${task.path} because: AB_CD=multi")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-11-06 13:23:47 +00:00
|
|
|
// Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
|
|
|
|
// and code generation themselves.
|
2018-12-18 23:54:08 +00:00
|
|
|
if ('1' == System.env.IS_LANGUAGE_REPACK) {
|
|
|
|
rootProject.logger.lifecycle("Skipping task ${task.path} because: IS_LANGUAGE_REPACK")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
rootProject.logger.lifecycle("Executing task ${task.path}")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-01-11 19:16:02 +00:00
|
|
|
// Non-official versions are like "61.0a1", where "a1" is the milestone.
|
|
|
|
// This simply strips that off, leaving "61.0" in this example.
|
|
|
|
def getAppVersionWithoutMilestone() {
|
|
|
|
return project.ext.mozconfig.substs.MOZ_APP_VERSION.replaceFirst(/a[0-9]/, "")
|
|
|
|
}
|
|
|
|
|
|
|
|
// This converts MOZ_APP_VERSION into an integer
|
|
|
|
// version code.
|
|
|
|
//
|
|
|
|
// We take something like 58.1.2a1 and come out with 5800102
|
|
|
|
// This gives us 3 digits for the major number, and 2 digits
|
|
|
|
// each for the minor and build number. Beta and Release
|
|
|
|
//
|
|
|
|
// This must be synchronized with _compute_gecko_version(...) in /taskcluster/gecko_taskgraph/transforms/task.py
|
|
|
|
def computeVersionCode() {
|
|
|
|
String appVersion = getAppVersionWithoutMilestone()
|
|
|
|
|
|
|
|
// Split on the dot delimiter, e.g. 58.1.1a1 -> ["58, "1", "1a1"]
|
|
|
|
String[] parts = appVersion.split('\\.')
|
|
|
|
|
|
|
|
assert parts.size() == 2 || parts.size() == 3
|
|
|
|
|
|
|
|
// Major
|
|
|
|
int code = Integer.parseInt(parts[0]) * 100000
|
|
|
|
|
|
|
|
// Minor
|
|
|
|
code += Integer.parseInt(parts[1]) * 100
|
|
|
|
|
|
|
|
// Build
|
|
|
|
if (parts.size() == 3) {
|
|
|
|
code += Integer.parseInt(parts[2])
|
|
|
|
}
|
|
|
|
|
|
|
|
return code;
|
|
|
|
}
|
|
|
|
|
|
|
|
def getVersionName() {
|
|
|
|
return "${mozconfig.substs.MOZ_APP_VERSION}-${mozconfig.substs.MOZ_UPDATE_CHANNEL}"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mimic Python: open(os.path.join(buildconfig.topobjdir, 'buildid.h')).readline().split()[2]
|
|
|
|
def getBuildId() {
|
|
|
|
return file("${topobjdir}/buildid.h").getText('utf-8').split()[2]
|
|
|
|
}
|
|
|
|
|
|
|
|
def getVersionNumber() {
|
|
|
|
def appVersion = getAppVersionWithoutMilestone()
|
|
|
|
def parts = appVersion.split('\\.')
|
|
|
|
def version = parts[0] + "." + parts[1] + "." + getBuildId()
|
|
|
|
def substs = project.ext.mozconfig.substs
|
|
|
|
if (!substs.MOZILLA_OFFICIAL && !substs.MOZ_ANDROID_FAT_AAR_ARCHITECTURES) {
|
|
|
|
// Use -SNAPSHOT versions locally to enable the local GeckoView substitution flow.
|
|
|
|
version += "-SNAPSHOT"
|
|
|
|
}
|
|
|
|
return version
|
|
|
|
}
|
|
|
|
|
|
|
|
def getArtifactSuffix() {
|
|
|
|
def substs = project.ext.mozconfig.substs
|
|
|
|
|
|
|
|
def suffix = ""
|
|
|
|
// Release artifacts don't specify the channel, for the sake of simplicity.
|
|
|
|
if (substs.MOZ_UPDATE_CHANNEL != 'release') {
|
|
|
|
suffix += "-${mozconfig.substs.MOZ_UPDATE_CHANNEL}"
|
|
|
|
}
|
|
|
|
|
|
|
|
return suffix
|
|
|
|
}
|
|
|
|
|
2019-05-09 20:38:48 +00:00
|
|
|
class MachExec extends Exec {
|
|
|
|
def MachExec() {
|
|
|
|
// Bug 1543982: When invoking `mach build` recursively, the outer `mach
|
|
|
|
// build` itself modifies the environment, causing configure to run
|
|
|
|
// again. This tries to restore the environment that the outer `mach
|
|
|
|
// build` was invoked in. See the comment in
|
|
|
|
// $topsrcdir/settings.gradle.
|
|
|
|
project.ext.mozconfig.mozconfig.env.unmodified.each { k, v -> environment.remove(k) }
|
|
|
|
environment project.ext.mozconfig.orig_mozconfig.env.unmodified
|
2021-09-29 17:54:57 +00:00
|
|
|
environment 'MOZCONFIG', project.ext.mozconfig.substs.MOZCONFIG
|
2019-05-09 20:38:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task machBuildFaster(type: MachExec) {
|
2018-12-18 23:01:16 +00:00
|
|
|
onlyIf rootProject.ext.geckoBinariesOnlyIf
|
|
|
|
|
|
|
|
workingDir "${topsrcdir}"
|
|
|
|
|
2020-05-05 16:02:02 +00:00
|
|
|
commandLine mozconfig.substs.PYTHON3
|
2018-12-18 23:01:16 +00:00
|
|
|
args "${topsrcdir}/mach"
|
|
|
|
args 'build'
|
|
|
|
args 'faster'
|
|
|
|
|
|
|
|
// Add `-v` if we're running under `--info` (or `--debug`).
|
|
|
|
if (project.logger.isEnabled(LogLevel.INFO)) {
|
|
|
|
args '-v'
|
|
|
|
}
|
|
|
|
|
|
|
|
// `path` is like `:machBuildFaster`.
|
|
|
|
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
|
|
|
errorOutput = standardOutput
|
|
|
|
}
|
|
|
|
|
2020-08-24 18:13:49 +00:00
|
|
|
task machStagePackage(type: MachExec) {
|
|
|
|
onlyIf rootProject.ext.geckoBinariesOnlyIf
|
2018-12-18 23:01:16 +00:00
|
|
|
|
2020-08-24 18:13:49 +00:00
|
|
|
dependsOn rootProject.machBuildFaster
|
2018-12-18 23:01:16 +00:00
|
|
|
|
2020-08-24 18:13:49 +00:00
|
|
|
workingDir "${topobjdir}"
|
2018-12-18 23:01:16 +00:00
|
|
|
|
2020-08-24 18:13:49 +00:00
|
|
|
// We'd prefer this to be a `mach` invocation, but `mach build
|
|
|
|
// mobile/android/installer/stage-package` doesn't work as expected.
|
|
|
|
commandLine mozconfig.substs.GMAKE
|
|
|
|
args '-C'
|
|
|
|
args "${topobjdir}/mobile/android/installer"
|
|
|
|
args 'stage-package'
|
2018-12-18 23:01:16 +00:00
|
|
|
|
2020-08-24 18:13:49 +00:00
|
|
|
outputs.file "${topobjdir}/dist/geckoview/assets/omni.ja"
|
2018-12-18 23:01:16 +00:00
|
|
|
|
2020-08-24 18:13:49 +00:00
|
|
|
outputs.file "${topobjdir}/dist/geckoview/assets/${mozconfig.substs.ANDROID_CPU_ARCH}/libxul.so"
|
|
|
|
outputs.file "${topobjdir}/dist/geckoview/lib/${mozconfig.substs.ANDROID_CPU_ARCH}/libmozglue.so"
|
2019-08-14 20:38:42 +00:00
|
|
|
|
2020-08-24 18:13:49 +00:00
|
|
|
// Force running `stage-package`.
|
|
|
|
outputs.upToDateWhen { false }
|
2018-12-18 23:01:16 +00:00
|
|
|
|
2020-08-24 18:13:49 +00:00
|
|
|
// `path` is like `:machStagePackage`.
|
|
|
|
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
|
|
|
errorOutput = standardOutput
|
2018-12-18 23:01:16 +00:00
|
|
|
}
|
|
|
|
|
2015-10-21 22:07:55 +00:00
|
|
|
afterEvaluate {
|
2018-05-01 04:22:54 +00:00
|
|
|
subprojects { project ->
|
2019-10-04 20:55:11 +00:00
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
// Add compiler args for all code except third-party code.
|
|
|
|
options.compilerArgs += [
|
|
|
|
// Turn on all warnings, except...
|
|
|
|
"-Xlint:all",
|
|
|
|
// Deprecation, because we do use deprecated API for compatibility.
|
|
|
|
"-Xlint:-deprecation",
|
|
|
|
// Serial, because we don't use Java serialization.
|
|
|
|
"-Xlint:-serial",
|
|
|
|
// Classfile, because javac has a bug with MethodParameters attributes
|
|
|
|
// with Java 7. https://bugs.openjdk.java.net/browse/JDK-8190452
|
2023-12-15 09:19:16 +00:00
|
|
|
"-Xlint:-classfile"]
|
2023-12-19 22:12:01 +00:00
|
|
|
|
|
|
|
// In GeckoView java projects only, turn all remaining warnings
|
|
|
|
// into errors unless marked by @SuppressWarnings.
|
|
|
|
def projectName = project.getName()
|
|
|
|
if (projectName.startsWith('geckoview')
|
|
|
|
|| projectName == 'annotations'
|
|
|
|
|| projectName == 'exoplayer2'
|
|
|
|
|| projectName == 'messaging_example'
|
|
|
|
|| projectName == 'port_messaging_example'
|
|
|
|
|| projectName == 'test_runner'
|
|
|
|
) {
|
|
|
|
options.compilerArgs += [
|
|
|
|
"-Werror"
|
|
|
|
]
|
|
|
|
}
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
2023-12-19 22:12:01 +00:00
|
|
|
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
apply plugin: 'idea'
|
|
|
|
|
|
|
|
idea {
|
|
|
|
project {
|
2018-08-22 19:15:42 +00:00
|
|
|
languageLevel = '1.8'
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
2015-10-20 22:30:44 +00: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-02 22:57:12 +00: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-20 22:30:44 +00: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-02 22:57:12 +00:00
|
|
|
.findAll({!it.equals('mobile/')}))
|
2015-10-20 22:30:44 +00: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")
|
|
|
|
}
|
|
|
|
}
|
2015-10-21 22:07:55 +00:00
|
|
|
}
|
2021-10-11 18:11:55 +00:00
|
|
|
|
2024-01-31 20:43:13 +00:00
|
|
|
subprojects { project ->
|
|
|
|
// Perform spotless lint in GeckoView projects only.
|
|
|
|
def projectName = project.getName()
|
|
|
|
if (projectName.startsWith('geckoview')
|
|
|
|
|| projectName == 'annotations'
|
|
|
|
|| projectName == 'exoplayer2'
|
|
|
|
|| projectName == 'messaging_example'
|
|
|
|
|| projectName == 'port_messaging_example'
|
|
|
|
|| projectName == 'test_runner'
|
|
|
|
) {
|
|
|
|
apply plugin: "com.diffplug.spotless"
|
|
|
|
|
|
|
|
spotless {
|
|
|
|
java {
|
|
|
|
target project.fileTree(project.projectDir) {
|
|
|
|
include '**/*.java'
|
|
|
|
exclude '**/thirdparty/**'
|
|
|
|
}
|
|
|
|
googleJavaFormat('1.17.0')
|
2021-10-11 18:11:55 +00:00
|
|
|
}
|
2024-01-31 20:43:13 +00:00
|
|
|
kotlin {
|
|
|
|
target project.fileTree(project.projectDir) {
|
|
|
|
include '**/*.kt'
|
|
|
|
exclude '**/thirdparty/**'
|
|
|
|
}
|
|
|
|
ktlint('0.49.1')
|
2022-11-18 00:55:03 +00:00
|
|
|
}
|
|
|
|
}
|
2024-07-26 15:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
|
|
|
// Our vendored copy of exoplayer2 hits build failures when targeting Java 17.
|
|
|
|
// Given our intent to remove it in the near future, just leave it alone here.
|
|
|
|
if (it.hasProperty('android') && projectName != 'exoplayer2') {
|
|
|
|
kotlin {
|
|
|
|
jvmToolchain(config.jvmTargetCompatibility)
|
2024-02-14 02:15:55 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-11 18:11:55 +00:00
|
|
|
}
|
2023-12-07 21:19:43 +00:00
|
|
|
|
|
|
|
project.configurations.configureEach {
|
|
|
|
resolutionStrategy.capabilitiesResolution.withCapability("org.mozilla.telemetry:glean-native") {
|
|
|
|
def toBeSelected = candidates.find {
|
|
|
|
it.id instanceof ProjectComponentIdentifier && it.id.projectName.contains('geckoview')
|
|
|
|
}
|
|
|
|
if (toBeSelected != null) {
|
|
|
|
select(toBeSelected)
|
|
|
|
}
|
|
|
|
because 'use GeckoView Glean instead of standalone Glean'
|
|
|
|
}
|
|
|
|
}
|
2021-10-11 18:11:55 +00:00
|
|
|
}
|