Commit 1756e826 authored by Makoto Kato's avatar Makoto Kato
Browse files

Bug 1740799 - Format Kotlin code using ktlint....

Bug 1740799 - Format Kotlin code using ktlint. r=geckoview-reviewers,owlish,linter-reviewers,sylvestre

Android-component and Fenix use ktlint, so mozilla-central should use same
tools via spotless.

This is from https://phabricator.services.mozilla.com/D131018

Differential Revision: https://phabricator.services.mozilla.com/D161557
parent 3f99c2ac
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -362,5 +362,12 @@ subprojects {
            }
            googleJavaFormat('1.15.0')
        }
        kotlin {
            target project.fileTree(project.projectDir) {
                include '**/*.kt'
                exclude '**/thirdparty/**'
            }
            ktlint('0.46.1')
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ In this document, we try to list these all tools.
     - :ref:`clippy`
     - https://github.com/rust-lang/rust-clippy

.. list-table:: Java
.. list-table:: Java/Kotlin
   :widths: 20 20 20 20 20
   :header-rows: 1

+4 −1
Original line number Diff line number Diff line
@@ -6,7 +6,10 @@ for Gradle and Android.

In our current configuration, Spotless includes the
`Google Java Format plug-in <https://github.com/google/google-java-format>`__
which formats all our Java code using the Google Java coding style guidelines.
which formats all our Java code using the Google Java coding style guidelines,
and `ktlint <https://ktlint.github.io/>`__ which formats all
our Kotlin code using the official Kotlin coding convention and Android Kotlin
Style Guide.


Run Locally
+4 −0
Original line number Diff line number Diff line
@@ -123,6 +123,10 @@ native code. `Bug
1509539 <https://bugzilla.mozilla.org/show_bug.cgi?id=1509539>`_ tracks
making Android Studio and Gradle do this automatically.

If you want set up code formatting for Kotlin, please reference
`IntelliJ IDEA configuration
<https://pinterest.github.io/ktlint/rules/configuration-intellij-idea/>`_.

Custom mozconfig with Android Studio
------------------------------------

+4 −2
Original line number Diff line number Diff line
@@ -284,12 +284,14 @@ def gradle_android_api_lint_tasks(build_config):
set_config("GRADLE_ANDROID_API_LINT_TASKS", gradle_android_api_lint_tasks)


set_config("GRADLE_ANDROID_FORMAT_LINT_FIX_TASKS", ["spotlessJavaApply"])
set_config(
    "GRADLE_ANDROID_FORMAT_LINT_FIX_TASKS", ["spotlessJavaApply", "spotlessKotlinApply"]
)


@dependable
def gradle_android_format_lint_check_tasks():
    return ["spotlessJavaCheck"]
    return ["spotlessJavaCheck", "spotlessKotlinCheck"]


set_config(
Loading