Backed out 2 changesets (bug 1924520) partial backout for as requested by Aaditya Dhingra. CLOSED TREE

Backed out changeset 17764af0218a (bug 1924520)
Backed out changeset 4447d8955f60 (bug 1924520)
This commit is contained in:
Cristian Tuns
2025-03-03 14:12:45 -05:00
parent 35cff17b41
commit 0b7c7fb4a9
15 changed files with 95 additions and 119 deletions

View File

@@ -134,7 +134,7 @@ ifeq ($(MOZ_BUILD_APP),mobile/android)
recurse_android-stage-package: stage-package
recurse_android-archive-geckoview:
GRADLE_INVOKED_WITHIN_MACH_BUILD=1 $(topsrcdir)/mach --log-no-times android archive-geckoview $(if $(MOZ_AUTOMATION),--no-configuration-cache)
GRADLE_INVOKED_WITHIN_MACH_BUILD=1 $(topsrcdir)/mach --log-no-times android archive-geckoview
endif
ifdef MOZ_WIDGET_TOOLKIT

View File

@@ -212,6 +212,23 @@ 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 {
@@ -361,8 +378,9 @@ task machBuildFaster(type: MachExec) {
args '-v'
}
standardOutput = System.out
errorOutput = System.err
// `path` is like `:machBuildFaster`.
standardOutput = new TaggedLogOutputStream("${path}>", logger)
errorOutput = standardOutput
}
task machStagePackage(type: MachExec) {
@@ -390,8 +408,9 @@ task machStagePackage(type: MachExec) {
// Force running `stage-package`.
outputs.upToDateWhen { false }
standardOutput = System.out
errorOutput = System.err
// `path` is like `:machStagePackage`.
standardOutput = new TaggedLogOutputStream("${path}>", logger)
errorOutput = standardOutput
}
afterEvaluate {

View File

@@ -8,14 +8,6 @@ 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

View File

@@ -117,36 +117,38 @@ subprojects {
testLogging.events = []
def out = services.get(StyledTextOutputFactory).create("an-ouput")
beforeSuite { descriptor ->
if (descriptor.getClassName() != null) {
println("\nSUITE: " + descriptor.getClassName())
out.style(Style.Header).println("\nSUITE: " + descriptor.getClassName())
}
}
beforeTest { descriptor ->
println(" TEST: " + descriptor.getName())
out.style(Style.Description).println(" TEST: " + descriptor.getName())
}
onOutput { descriptor, event ->
it.logger.lifecycle(" " + event.message.trim())
logger.lifecycle(" " + event.message.trim())
}
afterTest { descriptor, result ->
switch (result.getResultType()) {
case ResultType.SUCCESS:
println(" SUCCESS")
out.style(Style.Success).println(" SUCCESS")
break
case ResultType.FAILURE:
def testId = descriptor.getClassName() + "." + descriptor.getName()
println(" TEST-UNEXPECTED-FAIL | " + testId + " | " + result.getException())
out.style(Style.Failure).println(" TEST-UNEXPECTED-FAIL | " + testId + " | " + result.getException())
break
case ResultType.SKIPPED:
println(" SKIPPED")
out.style(Style.Info).println(" SKIPPED")
break
}
it.logger.lifecycle("")
logger.lifecycle("")
}
}

View File

@@ -47,15 +47,11 @@ 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': interventionsJson.text.trim(),
'#include data/interventions.json': file("$topsrcdir/browser/extensions/webcompat/data/interventions.json").text.trim(),
])
}
}

View File

@@ -100,7 +100,6 @@ preBuild.finalizedBy("generateComponentEnum")
* Generates a "Components" enum listing all published components.
*/
tasks.register("generateComponentEnum") {
def buildConfigCache = buildConfig
doLast {
generatedSrcDir.mkdirs()
@@ -114,7 +113,7 @@ tasks.register("generateComponentEnum") {
file << "\n"
file << "enum class Component {" << "\n"
file << buildConfigCache.projects.findAll { project ->
file << buildConfig.projects.findAll { project ->
project.value.publish
}.collect { project ->
" " + project.key.replace("-", "_").toUpperCase(Locale.US)

View File

@@ -36,6 +36,8 @@ apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: 'kotlinx-serialization'
import groovy.json.JsonOutput
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import static org.gradle.api.tasks.testing.TestResult.ResultType
@@ -829,18 +831,17 @@ if (project.hasProperty("coverage")) {
// Usage: "./gradlew printVariants
// -------------------------------------------------------------------------------------------------
tasks.register('printVariants') {
def variants = project.provider {
android.applicationVariants.collect { variant -> [
doLast {
def variants = android.applicationVariants.collect { variant -> [
apks: variant.outputs.collect { output -> [
abi: output.getFilter(FilterConfiguration.FilterType.ABI.name()),
fileName: output.outputFile.name
]},
build_type: variant.buildType.name,
name: variant.name,
]}}
doLast {
]}
// AndroidTest is a special case not included above
variants.get().add([
variants.add([
apks: [[
abi: 'noarch',
fileName: 'app-debug-androidTest.apk',
@@ -848,7 +849,7 @@ tasks.register('printVariants') {
build_type: 'androidTest',
name: 'androidTest',
])
println 'variants: ' + JsonOutput.toJson(variants.get())
println 'variants: ' + JsonOutput.toJson(variants)
}
}
@@ -861,36 +862,38 @@ afterEvaluate {
testLogging.events = []
def out = services.get(StyledTextOutputFactory).create("tests")
beforeSuite { descriptor ->
if (descriptor.getClassName() != null) {
println("\nSUITE: " + descriptor.getClassName())
out.style(Style.Header).println("\nSUITE: " + descriptor.getClassName())
}
}
beforeTest { descriptor ->
println(" TEST: " + descriptor.getName())
out.style(Style.Description).println(" TEST: " + descriptor.getName())
}
onOutput { descriptor, event ->
it.logger.lifecycle(" " + event.message.trim())
logger.lifecycle(" " + event.message.trim())
}
afterTest { descriptor, result ->
switch (result.getResultType()) {
case ResultType.SUCCESS:
println(" SUCCESS")
out.style(Style.Success).println(" SUCCESS")
break
case ResultType.FAILURE:
def testId = descriptor.getClassName() + "." + descriptor.getName()
println(" TEST-UNEXPECTED-FAIL | " + testId + " | " + result.getException())
out.style(Style.Failure).println(" TEST-UNEXPECTED-FAIL | " + testId + " | " + result.getException())
break
case ResultType.SKIPPED:
println(" SKIPPED")
out.style(Style.Info).println(" SKIPPED")
break
}
it.logger.lifecycle("")
logger.lifecycle("")
}
}
}

View File

@@ -126,7 +126,7 @@ subprojects {
if (it.startsWith('w: ') || it.startsWith('e: ')) {
def matches = (it =~ /([ew]): (.+):(\d+):(\d+) (.*)/)
if (!matches) {
task.logger.quiet "kotlinc message format has changed!"
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
@@ -137,7 +137,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.
task.logger.lifecycle "$file:$line:$column: $type: $message"
logger.lifecycle "$file:$line:$column: $type: $message"
}
} as StandardOutputListener

View File

@@ -12,14 +12,6 @@
# 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

View File

@@ -20,6 +20,8 @@ apply from: versionCodeGradle
import com.android.build.api.variant.FilterConfiguration
import groovy.json.JsonOutput
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import static org.gradle.api.tasks.testing.TestResult.ResultType
@@ -553,15 +555,15 @@ android.applicationVariants.configureEach { variant ->
}
}
def generatedLocaleListDir = file('src/main/java/org/mozilla/focus/generated')
def generatedLocaleListDir = 'src/main/java/org/mozilla/focus/generated'
def generatedLocaleListFilename = 'LocalesList.kt'
def enabledLocales = project.provider { getEnabledLocales() }
tasks.register('generateLocaleList') {
def localeList = file(new File(generatedLocaleListDir, generatedLocaleListFilename))
doLast {
generatedLocaleListDir.mkdir()
def dir = file(generatedLocaleListDir)
dir.mkdir()
def localeList = file(new File(dir, generatedLocaleListFilename))
localeList.delete()
localeList.createNewFile()
localeList << "package org.mozilla.focus.generated" << "\n" << "\n"
@@ -579,7 +581,7 @@ tasks.register('generateLocaleList') {
localeList << " " << "listOf("
localeList << "\n"
localeList << " "
localeList << enabledLocales.get().join(",\n" + " ")
localeList << getEnabledLocales().join(",\n" + " ")
localeList << ",\n"
localeList << " )," << "\n"
localeList << " )" << "\n"
@@ -594,7 +596,7 @@ tasks.configureEach { task ->
}
clean.doLast {
generatedLocaleListDir.deleteDir()
file(generatedLocaleListDir).deleteDir()
}
if (project.hasProperty("coverage")) {
@@ -641,17 +643,17 @@ if (project.hasProperty("coverage")) {
// Taskgraph Usage: "./gradlew printVariants
// -------------------------------------------------------------------------------------------------
tasks.register('printVariants') {
def variants = project.provider { android.applicationVariants.collect { variant -> [
doLast {
def variants = android.applicationVariants.collect { variant -> [
apks: variant.outputs.collect { output -> [
abi: output.getFilter(FilterConfiguration.FilterType.ABI.name()),
fileName: output.outputFile.name
]},
build_type: variant.buildType.name,
name: variant.name,
]}}
doLast {
]}
// AndroidTest is a special case not included above
variants.get().add([
variants.add([
apks: [[
abi: 'noarch',
fileName: 'app-debug-androidTest.apk',
@@ -659,7 +661,7 @@ tasks.register('printVariants') {
build_type: 'androidTest',
name: 'androidTest',
])
println 'variants: ' + JsonOutput.toJson(variants.get())
println 'variants: ' + JsonOutput.toJson(variants)
}
}
@@ -672,36 +674,38 @@ afterEvaluate {
testLogging.events = []
def out = services.get(StyledTextOutputFactory).create("tests")
beforeSuite { descriptor ->
if (descriptor.getClassName() != null) {
println("\nSUITE: " + descriptor.getClassName())
out.style(Style.Header).println("\nSUITE: " + descriptor.getClassName())
}
}
beforeTest { descriptor ->
println(" TEST: " + descriptor.getName())
out.style(Style.Description).println(" TEST: " + descriptor.getName())
}
onOutput { descriptor, event ->
it.logger.lifecycle(" " + event.message.trim())
logger.lifecycle(" " + event.message.trim())
}
afterTest { descriptor, result ->
switch (result.getResultType()) {
case ResultType.SUCCESS:
println(" SUCCESS")
out.style(Style.Success).println(" SUCCESS")
break
case ResultType.FAILURE:
def testId = descriptor.getClassName() + "." + descriptor.getName()
println(" TEST-UNEXPECTED-FAIL | " + testId + " | " + result.getException())
out.style(Style.Failure).println(" TEST-UNEXPECTED-FAIL | " + testId + " | " + result.getException())
break
case ResultType.SKIPPED:
println(" SKIPPED")
out.style(Style.Info).println(" SKIPPED")
break
}
it.logger.lifecycle("")
logger.lifecycle("")
}
}
}

View File

@@ -17,13 +17,6 @@ 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

View File

@@ -184,8 +184,6 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
}
}
def projectVersion = project.ext.gleanVersion
configurations {
api {
outgoing {
@@ -195,7 +193,7 @@ configurations {
}
afterEvaluate {
// Implicit capability
capability("org.mozilla.geckoview:${getArtifactId()}:${projectVersion}")
capability("org.mozilla.geckoview:${getArtifactId()}:${project.ext.versionNumber}")
}
}
}
@@ -206,7 +204,8 @@ configurations {
runtimeOnly {
outgoing {
afterEvaluate {
capability("org.mozilla.geckoview:geckoview:${projectVersion}")
// Implicit capability
capability("org.mozilla.geckoview:geckoview:${project.ext.versionNumber}")
}
}
}
@@ -251,16 +250,6 @@ 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"
@@ -270,13 +259,12 @@ 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 {
!androidLintProperty.get()
!project.hasProperty('android-lint')
}
doFirst {
classpath = classpathFilesProviderFiles.get()
classpath = files(variant.javaCompileProvider.get().classpath.files)
}
def results = []
@@ -300,9 +288,6 @@ 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)
@@ -310,8 +295,8 @@ android.libraryVariants.all { variant ->
// `android-javadoc` linter to fail in the face of Javadoc warnings.
def resultsJson = JsonOutput.toJson(results)
reportsDir.mkdirs()
reportsJsonFile.write(resultsJson)
file("$buildDir/reports").mkdirs()
file("$buildDir/reports/javadoc-results-${name}.json").write(resultsJson)
}
source = variant.sourceSets.collect({ it.java.srcDirs })
@@ -488,13 +473,6 @@ 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".
@@ -516,14 +494,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 androidBootClasspath.get()
args android.bootClasspath.findAll { it.getName().startsWith('android.jar') }
args 29
args bindingsDir
args "${topobjdir}/widget/android/bindings"
// From -Pgenerate_sdk_bindings_args=... on command line; missing in
// `android-gradle-dependencies` toolchain task.
if (generateSdkBindingsArgsProvider.get()) {
args generateSdkBindingsArgsProvider.get().split(';')
if (project.hasProperty('generate_sdk_bindings_args')) {
args project.generate_sdk_bindings_args.split(';')
}
}

View File

@@ -252,12 +252,10 @@ set_config("GRADLE_ANDROID_LINT_TASKS", gradle_android_lint_tasks)
@depends(gradle_android_build_config)
def gradle_android_api_lint_tasks(build_config):
"""Gradle tasks run by |mach android api-lint|."""
# --no-configuration-cache will be removed in bug 1950099
return [
"geckoview:apiLint{geckoview.variant.name}".format(
geckoview=build_config.geckoview
),
"--no-configuration-cache",
]

View File

@@ -15,7 +15,7 @@ export PATH=$MOZ_FETCHES_DIR/jdk-8/bin:$PATH
export MOZCONFIG=mobile/android/config/mozconfigs/android-arm-gradle-dependencies/nightly-lite
./mach build
./mach gradle downloadDependencies --no-configuration-cache
./mach android gradle-dependencies --no-configuration-cache
./mach gradle downloadDependencies
./mach android gradle-dependencies
. taskcluster/scripts/misc/android-gradle-dependencies/after.sh

View File

@@ -15,8 +15,8 @@ export PATH=$MOZ_FETCHES_DIR/jdk-8/bin:$PATH
export MOZCONFIG=mobile/android/config/mozconfigs/android-arm-gradle-dependencies/nightly
./mach build
./mach gradle downloadDependencies --no-configuration-cache
./mach android gradle-dependencies --no-configuration-cache
./mach gradle downloadDependencies
./mach android gradle-dependencies
pushd mobile/android/fenix
./gradlew detekt lint assembleDebug mozilla-lint-rules:test :benchmark:assembleBenchmark
popd