Bug 1512274 - Enable Checkstyle for GeckoView. r=geckoview-reviewers,nalexander,snorp
☠☠ backed out by 1f911d12fd07 ☠ ☠
authorAgi Sferro <agi@mozilla.com>
Fri, 15 Mar 2019 18:10:27 +0000
changeset 464421 9f34d0075a7300366203a37ac0155aa2198fdf7a
parent 464420 6ca9fc4956d03fea17ac48547b7d412aaf31e804
child 464422 007b5a2e825a543d24783e7b5b65e9e44db34cb7
push id35716
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:42:17 +0000
treeherdermozilla-central@8ee97c045359 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, nalexander, snorp
bugs1512274
milestone67.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 1512274 - Enable Checkstyle for GeckoView. r=geckoview-reviewers,nalexander,snorp Depends on D23691 Differential Revision: https://phabricator.services.mozilla.com/D23692
mobile/android/geckoview/build.gradle
mobile/android/geckoview/checkstyle.xml
mobile/android/gradle.configure
--- a/mobile/android/geckoview/build.gradle
+++ b/mobile/android/geckoview/build.gradle
@@ -1,11 +1,12 @@
 buildDir "${topobjdir}/gradle/build/mobile/android/geckoview"
 
 apply plugin: 'com.android.library'
+apply plugin: 'checkstyle'
 apply plugin: 'kotlin-android'
 
 apply from: "${topsrcdir}/mobile/android/gradle/product_flavors.gradle"
 
 // The SDK binding generation tasks depend on the JAR creation task of the
 // :annotations project.
 evaluationDependsOn(':annotations')
 
@@ -292,16 +293,24 @@ android.libraryVariants.all { variant ->
     }
 
     def sourcesJar = task("sourcesJar${name.capitalize()}", type: Jar) {
         classifier 'sources'
         description = "Generate Javadoc for build variant $name"
         destinationDir = new File(destinationDir, variant.baseName)
         from files(variant.javaCompile.source)
     }
+
+    task("checkstyle${name.capitalize()}", type: Checkstyle) {
+        classpath = variant.javaCompile.classpath
+        configFile file("checkstyle.xml")
+        // TODO: cleanup and include all sources
+        source = ['src/main/java/']
+        include '**/*.java'
+    }
 }
 
 android.libraryVariants.all { variant ->
     configureLibraryVariantWithJNIWrappers(variant, "Generated")
 }
 
 apply plugin: 'maven-publish'
 
new file mode 100644
--- /dev/null
+++ b/mobile/android/geckoview/checkstyle.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<!DOCTYPE module PUBLIC
+    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<module name="Checker">
+    <property name="charset" value="UTF-8"/>
+
+    <!-- Disallow tabs -->
+    <module name="FileTabCharacter">
+        <property name="eachLine" value="true"/>
+    </module>
+
+    <!-- Disallow trailing whitespace -->
+    <module name="RegexpSingleline">
+        <property name="format" value="\s+$"/>
+        <property name="message" value="Trailing whitespace"/>
+    </module>
+
+    <module name="TreeWalker">
+        <module name="FinalParameters"/>
+        <module name="ParameterName"/>
+        <module name="StaticVariableName"/>
+        <module name="LeftCurly"/>
+        <module name="RightCurly"/>
+        <module name="Indentation"/>
+        <module name="OneStatementPerLine"/>
+        <module name="AvoidStarImport"/>
+        <module name="UnusedImports"/>
+
+        <module name="MemberName">
+            <!-- Private members must use mHungarianNotation -->
+            <property name="format" value="m[A-Z][A-Za-z]*$"/>
+            <property name="applyToPrivate" value="true" />
+            <property name="applyToPublic" value="false" />
+            <property name="applyToPackage" value="false" />
+            <property name="applyToProtected" value="false" />
+        </module>
+
+        <module name="ClassTypeParameterName">
+            <property name="format" value="^[A-Z][A-Za-z]*$"/>
+        </module>
+        <module name="InterfaceTypeParameterName">
+            <property name="format" value="^[A-Z][A-Za-z]*$"/>
+        </module>
+        <module name="LocalVariableName"/>
+
+        <module name="GenericWhitespace"/>
+        <module name="NoLineWrap">
+            <property name="tokens" value="IMPORT,PACKAGE_DEF"/>
+        </module>
+        <module name="OuterTypeFilename"/>
+        <module name="WhitespaceAfter">
+            <property name="tokens" value="COMMA, SEMI"/>
+        </module>
+        <module name="WhitespaceAround">
+            <property name="allowEmptyConstructors" value="true"/>
+            <property name="allowEmptyMethods" value="true"/>
+            <property name="allowEmptyTypes" value="true"/>
+        </module>
+        <module name="OneTopLevelClass"/>
+    </module>
+
+</module>
--- a/mobile/android/gradle.configure
+++ b/mobile/android/gradle.configure
@@ -231,21 +231,22 @@ def gradle_android_api_lint_tasks(build_
     '''Gradle tasks run by |mach android api-lint|.'''
     return [
         'geckoview:apiLint{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
     ]
 
 set_config('GRADLE_ANDROID_API_LINT_TASKS', gradle_android_api_lint_tasks)
 
 
-@dependable
-def gradle_android_checkstyle_tasks():
+@depends(gradle_android_build_config)
+def gradle_android_checkstyle_tasks(build_config):
     '''Gradle tasks run by |mach android checkstyle|.'''
     return [
         'app:checkstyle',
+        'geckoview:checkstyle{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
     ]
 
 set_config('GRADLE_ANDROID_CHECKSTYLE_TASKS', gradle_android_checkstyle_tasks)
 
 
 @depends(gradle_android_build_config)
 def gradle_android_findbugs_tasks(build_config):
     '''Gradle tasks run by |mach android findbugs|.'''