Bug 1924520 - Enable gradle configuration cache to improve build speed. r=firefox-build-system-reviewers,geckoview-reviewers,android-reviewers,webcompat-reviewers,nalexander,twisniewski,owlish,ohall,willdurand
Differential Revision: https://phabricator.services.mozilla.com/D232874
This commit is contained in:
27
build.gradle
27
build.gradle
@@ -210,23 +210,6 @@ allprojects {
|
||||
|
||||
buildDir "${topobjdir}/gradle/build"
|
||||
|
||||
// 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}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
import org.gradle.api.services.BuildServiceParameters
|
||||
abstract class MozconfigService implements BuildService<MozconfigService.Params>, AutoCloseable {
|
||||
interface Params extends BuildServiceParameters {
|
||||
@@ -376,9 +359,8 @@ task machBuildFaster(type: MachExec) {
|
||||
args '-v'
|
||||
}
|
||||
|
||||
// `path` is like `:machBuildFaster`.
|
||||
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
||||
errorOutput = standardOutput
|
||||
standardOutput = System.out
|
||||
errorOutput = System.err
|
||||
}
|
||||
|
||||
task machStagePackage(type: MachExec) {
|
||||
@@ -406,9 +388,8 @@ task machStagePackage(type: MachExec) {
|
||||
// Force running `stage-package`.
|
||||
outputs.upToDateWhen { false }
|
||||
|
||||
// `path` is like `:machStagePackage`.
|
||||
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
||||
errorOutput = standardOutput
|
||||
standardOutput = System.out
|
||||
errorOutput = System.err
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
|
||||
@@ -8,6 +8,14 @@ org.gradle.configureondemand=true
|
||||
# Be careful when changing org.gradle.jvmargs below. It will clobber
|
||||
# any defaults set by Gradle: https://github.com/gradle/gradle/issues/19750
|
||||
org.gradle.jvmargs=-Xmx8g -Xms2g -XX:MaxMetaspaceSize=6g
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
|
||||
# Bug 1946302: Currently task of type `com.google.android.gms.oss.licenses.plugin.LicensesTask` fails as
|
||||
# notCompatibleWithConfigurationCache. Issue tracked in https://github.com/google/play-services-plugins/issues/246
|
||||
# Solution provided here: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api/-task/not-compatible-with-configuration-cache.html
|
||||
org.gradle.configuration-cache.problems=warn
|
||||
|
||||
android.useAndroidX=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
|
||||
@@ -47,11 +47,15 @@ tasks.register("syncWebcompatExtension", Sync) {
|
||||
// webcompat adopted #include directives in Bug 1936031, which are only
|
||||
// processed for Desktop builds. The filter below pre-processes the files
|
||||
// that include these directives.
|
||||
|
||||
// configuration-cache doesn't allow calling file() from a groovy closure,
|
||||
// in this case filesMatching callback, so we call file before the closure.
|
||||
def interventionsJson = file("$topsrcdir/browser/extensions/webcompat/data/interventions.json")
|
||||
filesMatching([
|
||||
'**/run.js',
|
||||
]) {
|
||||
filter(ReplaceTokens, beginToken: '', endToken: '', tokens: [
|
||||
'#include data/interventions.json': file("$topsrcdir/browser/extensions/webcompat/data/interventions.json").text.trim(),
|
||||
'#include data/interventions.json': interventionsJson.text.trim(),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ preBuild.finalizedBy("generateComponentEnum")
|
||||
* Generates a "Components" enum listing all published components.
|
||||
*/
|
||||
tasks.register("generateComponentEnum") {
|
||||
def buildConfigCache = buildConfig
|
||||
doLast {
|
||||
generatedSrcDir.mkdirs()
|
||||
|
||||
@@ -113,7 +114,7 @@ tasks.register("generateComponentEnum") {
|
||||
file << "\n"
|
||||
file << "enum class Component {" << "\n"
|
||||
|
||||
file << buildConfig.projects.findAll { project ->
|
||||
file << buildConfigCache.projects.findAll { project ->
|
||||
project.value.publish
|
||||
}.collect { project ->
|
||||
" " + project.key.replace("-", "_").toUpperCase(Locale.US)
|
||||
|
||||
@@ -124,7 +124,7 @@ subprojects {
|
||||
if (it.startsWith('w: ') || it.startsWith('e: ')) {
|
||||
def matches = (it =~ /([ew]): (.+):(\d+):(\d+) (.*)/)
|
||||
if (!matches) {
|
||||
logger.quiet "kotlinc message format has changed!"
|
||||
task.logger.quiet "kotlinc message format has changed!"
|
||||
if (it.startsWith('w: ')) {
|
||||
// For warnings, don't continue because we don't want to throw an
|
||||
// exception. For errors, we want the exception so that the new error
|
||||
@@ -135,7 +135,7 @@ subprojects {
|
||||
def (_, type, file, line, column, message) = matches[0]
|
||||
type = (type == 'w') ? 'warning' : 'error'
|
||||
// Use logger.lifecycle, which does not go through stderr again.
|
||||
logger.lifecycle "$file:$line:$column: $type: $message"
|
||||
task.logger.lifecycle "$file:$line:$column: $type: $message"
|
||||
}
|
||||
} as StandardOutputListener
|
||||
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx7g -Xms2g -XX:MaxMetaspaceSize=6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC
|
||||
org.gradle.configureondemand=true
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
|
||||
# Bug 1946302: Currently task of type `com.google.android.gms.oss.licenses.plugin.LicensesTask` fails as
|
||||
# notCompatibleWithConfigurationCache. Issue tracked in https://github.com/google/play-services-plugins/issues/246
|
||||
# Solution provided here: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api/-task/not-compatible-with-configuration-cache.html
|
||||
org.gradle.configuration-cache.problems=warn
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
|
||||
@@ -555,15 +555,15 @@ android.applicationVariants.configureEach { variant ->
|
||||
}
|
||||
}
|
||||
|
||||
def generatedLocaleListDir = 'src/main/java/org/mozilla/focus/generated'
|
||||
def generatedLocaleListDir = file('src/main/java/org/mozilla/focus/generated')
|
||||
def generatedLocaleListFilename = 'LocalesList.kt'
|
||||
|
||||
tasks.register('generateLocaleList') {
|
||||
doLast {
|
||||
def dir = file(generatedLocaleListDir)
|
||||
dir.mkdir()
|
||||
def localeList = file(new File(dir, generatedLocaleListFilename))
|
||||
def enabledLocales = project.provider { getEnabledLocales() }
|
||||
|
||||
tasks.register('generateLocaleList') {
|
||||
def localeList = file(new File(generatedLocaleListDir, generatedLocaleListFilename))
|
||||
doLast {
|
||||
generatedLocaleListDir.mkdir()
|
||||
localeList.delete()
|
||||
localeList.createNewFile()
|
||||
localeList << "package org.mozilla.focus.generated" << "\n" << "\n"
|
||||
@@ -581,7 +581,7 @@ tasks.register('generateLocaleList') {
|
||||
localeList << " " << "listOf("
|
||||
localeList << "\n"
|
||||
localeList << " "
|
||||
localeList << getEnabledLocales().join(",\n" + " ")
|
||||
localeList << enabledLocales.get().join(",\n" + " ")
|
||||
localeList << ",\n"
|
||||
localeList << " )," << "\n"
|
||||
localeList << " )" << "\n"
|
||||
@@ -596,7 +596,7 @@ tasks.configureEach { task ->
|
||||
}
|
||||
|
||||
clean.doLast {
|
||||
file(generatedLocaleListDir).deleteDir()
|
||||
generatedLocaleListDir.deleteDir()
|
||||
}
|
||||
|
||||
if (project.hasProperty("coverage")) {
|
||||
|
||||
@@ -17,6 +17,13 @@ android.useAndroidX=true
|
||||
org.gradle.jvmargs=-Xmx7g -Xms2g -XX:MaxMetaspaceSize=6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC
|
||||
org.gradle.configureondemand=true
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
|
||||
# Bug 1946302: Currently task of type `com.google.android.gms.oss.licenses.plugin.LicensesTask` fails as
|
||||
# notCompatibleWithConfigurationCache. Issue tracked in https://github.com/google/play-services-plugins/issues/246
|
||||
# Solution provided here: https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.api/-task/not-compatible-with-configuration-cache.html
|
||||
org.gradle.configuration-cache.problems=warn
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
|
||||
@@ -184,6 +184,8 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
|
||||
}
|
||||
}
|
||||
|
||||
def projectVersion = project.ext.gleanVersion
|
||||
|
||||
configurations {
|
||||
api {
|
||||
outgoing {
|
||||
@@ -193,7 +195,7 @@ configurations {
|
||||
}
|
||||
afterEvaluate {
|
||||
// Implicit capability
|
||||
capability("org.mozilla.geckoview:${getArtifactId()}:${project.ext.versionNumber}")
|
||||
capability("org.mozilla.geckoview:${getArtifactId()}:${projectVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,8 +206,7 @@ configurations {
|
||||
runtimeOnly {
|
||||
outgoing {
|
||||
afterEvaluate {
|
||||
// Implicit capability
|
||||
capability("org.mozilla.geckoview:geckoview:${project.ext.versionNumber}")
|
||||
capability("org.mozilla.geckoview:geckoview:${projectVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,6 +251,16 @@ android.libraryVariants.all { variant ->
|
||||
// https://code.tutsplus.com/tutorials/creating-and-publishing-an-android-library--cms-24582,
|
||||
// and amended from numerous Stackoverflow posts.
|
||||
def name = variant.name
|
||||
def classpathFilesProvider = variant.javaCompileProvider.flatMap { compileTask ->
|
||||
project.provider { compileTask.classpath.files }
|
||||
}
|
||||
|
||||
def classpathFilesProviderFiles = project.provider {
|
||||
files(classpathFilesProvider.get())
|
||||
}
|
||||
|
||||
def androidLintProperty = project.provider { project.hasProperty('android-lint') }
|
||||
|
||||
def javadoc = task "javadoc${name.capitalize()}"(type: Javadoc) {
|
||||
failOnError = false
|
||||
description = "Generate Javadoc for build variant $name"
|
||||
@@ -259,12 +270,13 @@ android.libraryVariants.all { variant ->
|
||||
// this is a problem for the javadoc lint, which needs to read the output of the task
|
||||
// to determine if there are warnings or errors. To force that we pass a -Pandroid-lint
|
||||
// parameter to all lints that can be used here to force running the task every time.
|
||||
|
||||
outputs.upToDateWhen {
|
||||
!project.hasProperty('android-lint')
|
||||
!androidLintProperty.get()
|
||||
}
|
||||
|
||||
doFirst {
|
||||
classpath = files(variant.javaCompileProvider.get().classpath.files)
|
||||
classpath = classpathFilesProviderFiles.get()
|
||||
}
|
||||
|
||||
def results = []
|
||||
@@ -288,6 +300,9 @@ android.libraryVariants.all { variant ->
|
||||
logging.addStandardErrorListener(listener)
|
||||
}
|
||||
|
||||
def reportsDir = file("$buildDir/reports")
|
||||
def reportsJsonFile = file("$buildDir/reports/javadoc-results-${name}.json")
|
||||
|
||||
doLast {
|
||||
logging.removeStandardErrorListener(listener)
|
||||
|
||||
@@ -295,8 +310,8 @@ android.libraryVariants.all { variant ->
|
||||
// `android-javadoc` linter to fail in the face of Javadoc warnings.
|
||||
def resultsJson = JsonOutput.toJson(results)
|
||||
|
||||
file("$buildDir/reports").mkdirs()
|
||||
file("$buildDir/reports/javadoc-results-${name}.json").write(resultsJson)
|
||||
reportsDir.mkdirs()
|
||||
reportsJsonFile.write(resultsJson)
|
||||
}
|
||||
|
||||
source = variant.sourceSets.collect({ it.java.srcDirs })
|
||||
@@ -473,6 +488,13 @@ afterEvaluate {
|
||||
apply from: "${topsrcdir}/mobile/android/gradle/debug_level.gradle"
|
||||
android.libraryVariants.all configureVariantDebugLevel
|
||||
|
||||
def androidBootClasspath = provider {
|
||||
android.bootClasspath.findAll { it.name.startsWith('android.jar') }
|
||||
}
|
||||
|
||||
def bindingsDir = "${topobjdir}/widget/android/bindings"
|
||||
|
||||
def generateSdkBindingsArgsProvider = project.provider { project.hasProperty('generate_sdk_bindings_args') ? project.generate_sdk_bindings_args : false }
|
||||
// There's nothing specific to the :geckoview project here -- this just needs to
|
||||
// be somewhere where the Android plugin is available so that we can fish the
|
||||
// path to "android.jar".
|
||||
@@ -494,14 +516,14 @@ task("generateSDKBindings", type: JavaExec) {
|
||||
doFirst {
|
||||
// We only want to generate bindings for the main framework JAR,
|
||||
// but not any of the additional android.test libraries.
|
||||
args android.bootClasspath.findAll { it.getName().startsWith('android.jar') }
|
||||
args androidBootClasspath.get()
|
||||
args 29
|
||||
args "${topobjdir}/widget/android/bindings"
|
||||
args bindingsDir
|
||||
|
||||
// From -Pgenerate_sdk_bindings_args=... on command line; missing in
|
||||
// `android-gradle-dependencies` toolchain task.
|
||||
if (project.hasProperty('generate_sdk_bindings_args')) {
|
||||
args project.generate_sdk_bindings_args.split(';')
|
||||
if (generateSdkBindingsArgsProvider.get()) {
|
||||
args generateSdkBindingsArgsProvider.get().split(';')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user