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
@@ -212,23 +212,6 @@ allprojects {
|
|||||||
|
|
||||||
buildDir "${topobjdir}/gradle/build"
|
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
|
import org.gradle.api.services.BuildServiceParameters
|
||||||
abstract class MozconfigService implements BuildService<MozconfigService.Params>, AutoCloseable {
|
abstract class MozconfigService implements BuildService<MozconfigService.Params>, AutoCloseable {
|
||||||
interface Params extends BuildServiceParameters {
|
interface Params extends BuildServiceParameters {
|
||||||
@@ -378,9 +361,8 @@ task machBuildFaster(type: MachExec) {
|
|||||||
args '-v'
|
args '-v'
|
||||||
}
|
}
|
||||||
|
|
||||||
// `path` is like `:machBuildFaster`.
|
standardOutput = System.out
|
||||||
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
errorOutput = System.err
|
||||||
errorOutput = standardOutput
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task machStagePackage(type: MachExec) {
|
task machStagePackage(type: MachExec) {
|
||||||
@@ -408,9 +390,8 @@ task machStagePackage(type: MachExec) {
|
|||||||
// Force running `stage-package`.
|
// Force running `stage-package`.
|
||||||
outputs.upToDateWhen { false }
|
outputs.upToDateWhen { false }
|
||||||
|
|
||||||
// `path` is like `:machStagePackage`.
|
standardOutput = System.out
|
||||||
standardOutput = new TaggedLogOutputStream("${path}>", logger)
|
errorOutput = System.err
|
||||||
errorOutput = standardOutput
|
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ org.gradle.configureondemand=true
|
|||||||
# Be careful when changing org.gradle.jvmargs below. It will clobber
|
# Be careful when changing org.gradle.jvmargs below. It will clobber
|
||||||
# any defaults set by Gradle: https://github.com/gradle/gradle/issues/19750
|
# any defaults set by Gradle: https://github.com/gradle/gradle/issues/19750
|
||||||
org.gradle.jvmargs=-Xmx8g -Xms2g -XX:MaxMetaspaceSize=6g
|
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.useAndroidX=true
|
||||||
android.nonTransitiveRClass=false
|
android.nonTransitiveRClass=false
|
||||||
android.nonFinalResIds=false
|
android.nonFinalResIds=false
|
||||||
|
|||||||
@@ -47,11 +47,15 @@ tasks.register("syncWebcompatExtension", Sync) {
|
|||||||
// webcompat adopted #include directives in Bug 1936031, which are only
|
// webcompat adopted #include directives in Bug 1936031, which are only
|
||||||
// processed for Desktop builds. The filter below pre-processes the files
|
// processed for Desktop builds. The filter below pre-processes the files
|
||||||
// that include these directives.
|
// 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([
|
filesMatching([
|
||||||
'**/run.js',
|
'**/run.js',
|
||||||
]) {
|
]) {
|
||||||
filter(ReplaceTokens, beginToken: '', endToken: '', tokens: [
|
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.
|
* Generates a "Components" enum listing all published components.
|
||||||
*/
|
*/
|
||||||
tasks.register("generateComponentEnum") {
|
tasks.register("generateComponentEnum") {
|
||||||
|
def buildConfigCache = buildConfig
|
||||||
doLast {
|
doLast {
|
||||||
generatedSrcDir.mkdirs()
|
generatedSrcDir.mkdirs()
|
||||||
|
|
||||||
@@ -113,7 +114,7 @@ tasks.register("generateComponentEnum") {
|
|||||||
file << "\n"
|
file << "\n"
|
||||||
file << "enum class Component {" << "\n"
|
file << "enum class Component {" << "\n"
|
||||||
|
|
||||||
file << buildConfig.projects.findAll { project ->
|
file << buildConfigCache.projects.findAll { project ->
|
||||||
project.value.publish
|
project.value.publish
|
||||||
}.collect { project ->
|
}.collect { project ->
|
||||||
" " + project.key.replace("-", "_").toUpperCase(Locale.US)
|
" " + project.key.replace("-", "_").toUpperCase(Locale.US)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ subprojects {
|
|||||||
if (it.startsWith('w: ') || it.startsWith('e: ')) {
|
if (it.startsWith('w: ') || it.startsWith('e: ')) {
|
||||||
def matches = (it =~ /([ew]): (.+):(\d+):(\d+) (.*)/)
|
def matches = (it =~ /([ew]): (.+):(\d+):(\d+) (.*)/)
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
logger.quiet "kotlinc message format has changed!"
|
task.logger.quiet "kotlinc message format has changed!"
|
||||||
if (it.startsWith('w: ')) {
|
if (it.startsWith('w: ')) {
|
||||||
// For warnings, don't continue because we don't want to throw an
|
// 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
|
// exception. For errors, we want the exception so that the new error
|
||||||
@@ -137,7 +137,7 @@ subprojects {
|
|||||||
def (_, type, file, line, column, message) = matches[0]
|
def (_, type, file, line, column, message) = matches[0]
|
||||||
type = (type == 'w') ? 'warning' : 'error'
|
type = (type == 'w') ? 'warning' : 'error'
|
||||||
// Use logger.lifecycle, which does not go through stderr again.
|
// 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
|
} as StandardOutputListener
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,14 @@
|
|||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
org.gradle.jvmargs=-Xmx7g -Xms2g -XX:MaxMetaspaceSize=6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC
|
org.gradle.jvmargs=-Xmx7g -Xms2g -XX:MaxMetaspaceSize=6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC
|
||||||
org.gradle.configureondemand=true
|
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.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# 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
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
|||||||
@@ -552,15 +552,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'
|
def generatedLocaleListFilename = 'LocalesList.kt'
|
||||||
|
|
||||||
tasks.register('generateLocaleList') {
|
def enabledLocales = project.provider { getEnabledLocales() }
|
||||||
doLast {
|
|
||||||
def dir = file(generatedLocaleListDir)
|
|
||||||
dir.mkdir()
|
|
||||||
def localeList = file(new File(dir, generatedLocaleListFilename))
|
|
||||||
|
|
||||||
|
tasks.register('generateLocaleList') {
|
||||||
|
def localeList = file(new File(generatedLocaleListDir, generatedLocaleListFilename))
|
||||||
|
doLast {
|
||||||
|
generatedLocaleListDir.mkdir()
|
||||||
localeList.delete()
|
localeList.delete()
|
||||||
localeList.createNewFile()
|
localeList.createNewFile()
|
||||||
localeList << "package org.mozilla.focus.generated" << "\n" << "\n"
|
localeList << "package org.mozilla.focus.generated" << "\n" << "\n"
|
||||||
@@ -578,7 +578,7 @@ tasks.register('generateLocaleList') {
|
|||||||
localeList << " " << "listOf("
|
localeList << " " << "listOf("
|
||||||
localeList << "\n"
|
localeList << "\n"
|
||||||
localeList << " "
|
localeList << " "
|
||||||
localeList << getEnabledLocales().join(",\n" + " ")
|
localeList << enabledLocales.get().join(",\n" + " ")
|
||||||
localeList << ",\n"
|
localeList << ",\n"
|
||||||
localeList << " )," << "\n"
|
localeList << " )," << "\n"
|
||||||
localeList << " )" << "\n"
|
localeList << " )" << "\n"
|
||||||
@@ -593,7 +593,7 @@ tasks.configureEach { task ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
clean.doLast {
|
clean.doLast {
|
||||||
file(generatedLocaleListDir).deleteDir()
|
generatedLocaleListDir.deleteDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.hasProperty("coverage")) {
|
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.jvmargs=-Xmx7g -Xms2g -XX:MaxMetaspaceSize=6g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC
|
||||||
org.gradle.configureondemand=true
|
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.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# 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
|
# 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 {
|
configurations {
|
||||||
api {
|
api {
|
||||||
outgoing {
|
outgoing {
|
||||||
@@ -193,7 +195,7 @@ configurations {
|
|||||||
}
|
}
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
// Implicit capability
|
// Implicit capability
|
||||||
capability("org.mozilla.geckoview:${getArtifactId()}:${project.ext.versionNumber}")
|
capability("org.mozilla.geckoview:${getArtifactId()}:${projectVersion}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,8 +206,7 @@ configurations {
|
|||||||
runtimeOnly {
|
runtimeOnly {
|
||||||
outgoing {
|
outgoing {
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
// Implicit capability
|
capability("org.mozilla.geckoview:geckoview:${projectVersion}")
|
||||||
capability("org.mozilla.geckoview:geckoview:${project.ext.versionNumber}")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,6 +251,16 @@ android.libraryVariants.all { variant ->
|
|||||||
// https://code.tutsplus.com/tutorials/creating-and-publishing-an-android-library--cms-24582,
|
// https://code.tutsplus.com/tutorials/creating-and-publishing-an-android-library--cms-24582,
|
||||||
// and amended from numerous Stackoverflow posts.
|
// and amended from numerous Stackoverflow posts.
|
||||||
def name = variant.name
|
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) {
|
def javadoc = task "javadoc${name.capitalize()}"(type: Javadoc) {
|
||||||
failOnError = false
|
failOnError = false
|
||||||
description = "Generate Javadoc for build variant $name"
|
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
|
// 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
|
// 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.
|
// parameter to all lints that can be used here to force running the task every time.
|
||||||
|
|
||||||
outputs.upToDateWhen {
|
outputs.upToDateWhen {
|
||||||
!project.hasProperty('android-lint')
|
!androidLintProperty.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
classpath = files(variant.javaCompileProvider.get().classpath.files)
|
classpath = classpathFilesProviderFiles.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
def results = []
|
def results = []
|
||||||
@@ -288,6 +300,9 @@ android.libraryVariants.all { variant ->
|
|||||||
logging.addStandardErrorListener(listener)
|
logging.addStandardErrorListener(listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def reportsDir = file("$buildDir/reports")
|
||||||
|
def reportsJsonFile = file("$buildDir/reports/javadoc-results-${name}.json")
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
logging.removeStandardErrorListener(listener)
|
logging.removeStandardErrorListener(listener)
|
||||||
|
|
||||||
@@ -295,8 +310,8 @@ android.libraryVariants.all { variant ->
|
|||||||
// `android-javadoc` linter to fail in the face of Javadoc warnings.
|
// `android-javadoc` linter to fail in the face of Javadoc warnings.
|
||||||
def resultsJson = JsonOutput.toJson(results)
|
def resultsJson = JsonOutput.toJson(results)
|
||||||
|
|
||||||
file("$buildDir/reports").mkdirs()
|
reportsDir.mkdirs()
|
||||||
file("$buildDir/reports/javadoc-results-${name}.json").write(resultsJson)
|
reportsJsonFile.write(resultsJson)
|
||||||
}
|
}
|
||||||
|
|
||||||
source = variant.sourceSets.collect({ it.java.srcDirs })
|
source = variant.sourceSets.collect({ it.java.srcDirs })
|
||||||
@@ -473,6 +488,13 @@ afterEvaluate {
|
|||||||
apply from: "${topsrcdir}/mobile/android/gradle/debug_level.gradle"
|
apply from: "${topsrcdir}/mobile/android/gradle/debug_level.gradle"
|
||||||
android.libraryVariants.all configureVariantDebugLevel
|
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
|
// 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
|
// be somewhere where the Android plugin is available so that we can fish the
|
||||||
// path to "android.jar".
|
// path to "android.jar".
|
||||||
@@ -494,14 +516,14 @@ task("generateSDKBindings", type: JavaExec) {
|
|||||||
doFirst {
|
doFirst {
|
||||||
// We only want to generate bindings for the main framework JAR,
|
// We only want to generate bindings for the main framework JAR,
|
||||||
// but not any of the additional android.test libraries.
|
// but not any of the additional android.test libraries.
|
||||||
args android.bootClasspath.findAll { it.getName().startsWith('android.jar') }
|
args androidBootClasspath.get()
|
||||||
args 29
|
args 29
|
||||||
args "${topobjdir}/widget/android/bindings"
|
args bindingsDir
|
||||||
|
|
||||||
// From -Pgenerate_sdk_bindings_args=... on command line; missing in
|
// From -Pgenerate_sdk_bindings_args=... on command line; missing in
|
||||||
// `android-gradle-dependencies` toolchain task.
|
// `android-gradle-dependencies` toolchain task.
|
||||||
if (project.hasProperty('generate_sdk_bindings_args')) {
|
if (generateSdkBindingsArgsProvider.get()) {
|
||||||
args project.generate_sdk_bindings_args.split(';')
|
args generateSdkBindingsArgsProvider.get().split(';')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user