Bug 1882087 - Format build failure messages for treeherder. r=tthibaud,android-reviewers
Co-authored with @tthibaud : We have borrowed from geckoview's reformatting of gradle errors and warnings: https://searchfox.org/mozilla-central/rev/b189986e26a92f749462094e7869771c1a6607c0/mobile/android/geckoview/build.gradle#165-202 ...with adaptations as needed for A-C, Focus, and Fenix. Example: https://treeherder.mozilla.org/jobs?repo=try&revision=221a0bc4bd8040e179735213e49a618fb83bf827 Differential Revision: https://phabricator.services.mozilla.com/D204425
This commit is contained in:
@@ -244,6 +244,40 @@ subprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(KotlinCompile).configureEach {
|
||||
// Translate Kotlin messages like "w: ..." and "e: ..." into
|
||||
// "...: warning: ..." and "...: error: ...", to make Treeherder understand.
|
||||
def listener = {
|
||||
if (it.startsWith("e: warnings found")) {
|
||||
return
|
||||
}
|
||||
|
||||
if (it.startsWith('w: ') || it.startsWith('e: ')) {
|
||||
def matches = (it =~ /([ew]): (.+):(\d+):(\d+) (.*)/)
|
||||
if (!matches) {
|
||||
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
|
||||
// message format gets translated properly.
|
||||
return
|
||||
}
|
||||
}
|
||||
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"
|
||||
}
|
||||
} as StandardOutputListener
|
||||
|
||||
doFirst {
|
||||
logging.addStandardErrorListener(listener)
|
||||
}
|
||||
doLast {
|
||||
logging.removeStandardErrorListener(listener)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (findProject(":geckoview") == null) {
|
||||
|
||||
Reference in New Issue
Block a user