Bug 1575999 - Always run javadoc tasks during lint. r=nalexander,esawin
authorAgi Sferro <agi@sferro.dev>
Mon, 01 Jun 2020 15:58:03 +0000
changeset 533336 0f5a98fe760847762c1536443c87fa81349c70fe
parent 533335 eb654059cd8baa99ade5008b2b5bd93166604c44
child 533337 cc5f9b171fd9a81ebfcd82839cadf2d327f4e985
push id117675
push userasferro@mozilla.com
push dateMon, 01 Jun 2020 15:59:17 +0000
treeherderautoland@cc5f9b171fd9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, esawin
bugs1575999
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1575999 - Always run javadoc tasks during lint. r=nalexander,esawin Differential Revision: https://phabricator.services.mozilla.com/D77489
mobile/android/geckoview/build.gradle
tools/lint/android/lints.py
--- a/mobile/android/geckoview/build.gradle
+++ b/mobile/android/geckoview/build.gradle
@@ -250,16 +250,25 @@ android.libraryVariants.all { variant ->
     // informed by
     // https://code.tutsplus.com/tutorials/creating-and-publishing-an-android-library--cms-24582,
     // and amended from numerous Stackoverflow posts.
     def name = variant.name
     def javadoc = task "javadoc${name.capitalize()}"(type: Javadoc) {
         failOnError = false
         description = "Generate Javadoc for build variant $name"
         destinationDir = new File(destinationDir, variant.baseName)
+
+        // The javadoc task will not re-run if the previous run is still up-to-date,
+        // 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')
+        }
+
         doFirst {
             classpath = files(variant.javaCompileProvider.get().classpath.files)
         }
 
         def results = []
         def listener = {
             if (!it.toLowerCase().contains("warning") && !it.toLowerCase().contains("error")) {
               // Likely not an error or a warning
--- a/tools/lint/android/lints.py
+++ b/tools/lint/android/lints.py
@@ -38,18 +38,21 @@ def setup(root, **setupargs):
     return 0
 
 
 def gradle(log, topsrcdir=None, topobjdir=None, tasks=[], extra_args=[], verbose=True):
     sys.path.insert(0, os.path.join(topsrcdir, 'mobile', 'android'))
     from gradle import gradle_lock
 
     with gradle_lock(topobjdir, max_wait_seconds=GRADLE_LOCK_MAX_WAIT_SECONDS):
+        # The android-lint parameter can be used by gradle tasks to run special
+        # logic when they are run for a lint using
+        #   project.hasProperty('android-lint')
         cmd_args = [sys.executable, os.path.join(topsrcdir, 'mach'),
-                    'gradle', '--verbose', '--'] + \
+                    'gradle', '--verbose', '-Pandroid-lint', '--'] + \
             tasks + \
             extra_args
 
         cmd = ' '.join(six.moves.shlex_quote(arg) for arg in cmd_args)
         log.debug(cmd)
 
         # Gradle and mozprocess do not get along well, so we use subprocess
         # directly.