Merge "Adding ktlint hook to support library." into oc-mr1-support-27.0-dev
am: ee4da728f2
Change-Id: Ia53c99b17a6f9a59bfe892982f9147ad75611157
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index ecc61dd..7a349d5 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,5 +1,6 @@
[Hook Scripts]
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT} -c ${REPO_ROOT}/frameworks/support/development/checkstyle/config/support-lib.xml -p development/checkstyle/prebuilt/com.android.support.checkstyle.jar
+ktlint_hook = ${REPO_ROOT}/prebuilts/ktlint/ktlint.py -f ${PREUPLOAD_FILES}
[Builtin Hooks]
commit_msg_changeid_field = true
diff --git a/app-toolkit/common/build.gradle b/app-toolkit/common/build.gradle
index 9604210..d5583d9 100644
--- a/app-toolkit/common/build.gradle
+++ b/app-toolkit/common/build.gradle
@@ -29,8 +29,6 @@
testCompile libs.mockito_core
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Arch-Common"
publish = true
diff --git a/app-toolkit/core-testing/build.gradle b/app-toolkit/core-testing/build.gradle
index adb93e6..cf2d6c7 100644
--- a/app-toolkit/core-testing/build.gradle
+++ b/app-toolkit/core-testing/build.gradle
@@ -42,8 +42,6 @@
androidTestImplementation libs.espresso_core, { exclude module: 'support-annotations' }
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Core-Testing"
publish = true
diff --git a/app-toolkit/init.gradle b/app-toolkit/init.gradle
index 1d6b752..49d37c8 100644
--- a/app-toolkit/init.gradle
+++ b/app-toolkit/init.gradle
@@ -136,69 +136,3 @@
}
}
}
-
-def createKotlinCheckstyle(Project project) {
- def fs = files();
- if (project.sourceSets.hasProperty('main')) {
- fs += files(project.sourceSets.main.allJava.srcDirs.collect { fileTree(it) })
- }
- if (project.sourceSets.hasProperty('test')) {
- fs += files(project.sourceSets.test.allJava.srcDirs.collect { fileTree(it) })
- }
- if (project.hasProperty('android')) {
- fs += files(project.android.sourceSets.main.java.getSrcDirs().collect {fileTree(it)})
- fs += files(project.android.sourceSets.test.java.getSrcDirs().collect {fileTree(it)})
- fs += files(project.android.sourceSets.androidTest.java.getSrcDirs().collect {fileTree(it)})
- }
- fs = fs.filter{file -> file.name.endsWith(".kt")}
- def kotlinCheckstyle = createCheckstyleTask(project, 'checkstyleKotlin',
- "${project.rootProject.ext.supportRootFolder}/app-toolkit/kotlin-checkstyle.xml",
- fs.files)
-
- project.tasks.findByName("check").dependsOn(kotlinCheckstyle)
- // poor man's line length check
- def lineCheck = project.tasks.create(name : "lineLengthCheck") {
- fs.each { sourceDir ->
- fileTree(dir : sourceDir, include : "**/*.kt").each{ file ->
- file.readLines().eachWithIndex { line, index ->
- if (line.size() > 100) {
- project.logger.error("line too long: file: $file" +
- " index:$index line: $line")
- }
- }
- }
- }
- }
- kotlinCheckstyle.dependsOn(lineCheck)
-}
-
-def createAndroidCheckstyle(Project project) {
- def fs = files()
- if (project.hasProperty('android')) {
- fs += files(project.android.sourceSets.main.java.getSrcDirs().collect {fileTree(it)})
- }
- if (project.sourceSets.hasProperty('main')) {
- fs += files(project.sourceSets.main.allJava)
- }
- fs = fs.filter{file -> file.name.endsWith(".java")}
-
- def checkStyle = createCheckstyleTask(project, 'checkstyleAndroid',
- "${project.rootProject.ext.checkoutRoot}/prebuilts/checkstyle/android-style.xml",
- fs.files)
- project.tasks.findByName("check").dependsOn(checkStyle)
-}
-
-def createCheckstyleTask(project, taskName, configFile, inputFiles) {
- def arguments = ['-c', configFile]
- arguments.addAll(inputFiles)
- def checkStyle = project.tasks.create(name : taskName, type: JavaExec) {
- inputs.files(inputFiles).skipWhenEmpty()
- main = "com.puppycrawl.tools.checkstyle.Main"
- args = arguments
- classpath = files(file("${project.rootProject.ext.checkoutRoot}/prebuilts/checkstyle/checkstyle.jar").path)
- }
- return checkStyle;
-}
-
-ext.createKotlinCheckstyle = this.&createKotlinCheckstyle
-ext.createAndroidCheckstyle = this.&createAndroidCheckstyle
diff --git a/app-toolkit/runtime/build.gradle b/app-toolkit/runtime/build.gradle
index 3b46384..8d2c370 100644
--- a/app-toolkit/runtime/build.gradle
+++ b/app-toolkit/runtime/build.gradle
@@ -33,8 +33,6 @@
api project(":arch:common")
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Arch-Runtime"
publish = true
diff --git a/lifecycle/common-java8/build.gradle b/lifecycle/common-java8/build.gradle
index 7877b81..e96e7ae 100644
--- a/lifecycle/common-java8/build.gradle
+++ b/lifecycle/common-java8/build.gradle
@@ -29,8 +29,6 @@
compile libs.support.annotations
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Lifecycle-Common for Java 8 Language"
publish = true
diff --git a/lifecycle/common/build.gradle b/lifecycle/common/build.gradle
index a3b06dd..33d8235 100644
--- a/lifecycle/common/build.gradle
+++ b/lifecycle/common/build.gradle
@@ -28,8 +28,6 @@
compile libs.support.annotations
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Lifecycle-Common"
publish = true
diff --git a/lifecycle/compiler/build.gradle b/lifecycle/compiler/build.gradle
index edc54b0..6d6fd66 100644
--- a/lifecycle/compiler/build.gradle
+++ b/lifecycle/compiler/build.gradle
@@ -24,9 +24,6 @@
testCompile files(org.gradle.internal.jvm.Jvm.current().getToolsJar())
}
-version = LibraryVersions.LIFECYCLES_EXT.toString()
-createKotlinCheckstyle(project)
-
// we actually need to compile :lifecycle:common, but compileJava is easier
task compileTestLibrarySource(type: JavaCompile, dependsOn: compileJava) {
source "src/tests/test-data/lib/src"
diff --git a/lifecycle/extensions/build.gradle b/lifecycle/extensions/build.gradle
index 6bd1bce..f74fd40 100644
--- a/lifecycle/extensions/build.gradle
+++ b/lifecycle/extensions/build.gradle
@@ -48,8 +48,6 @@
androidTestImplementation libs.support.app_compat, libs.support_exclude_config
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Lifecycle Extensions"
publish = true
diff --git a/lifecycle/integration-tests/testapp/build.gradle b/lifecycle/integration-tests/testapp/build.gradle
index 64159bd..d733c32 100644
--- a/lifecycle/integration-tests/testapp/build.gradle
+++ b/lifecycle/integration-tests/testapp/build.gradle
@@ -77,7 +77,6 @@
testImplementation libs.mockito_core
testAnnotationProcessor project(":lifecycle:compiler")
}
-createAndroidCheckstyle(project)
tasks['check'].dependsOn(tasks['connectedCheck'])
diff --git a/lifecycle/reactivestreams/build.gradle b/lifecycle/reactivestreams/build.gradle
index d2beeed..6d77bb7 100644
--- a/lifecycle/reactivestreams/build.gradle
+++ b/lifecycle/reactivestreams/build.gradle
@@ -47,8 +47,6 @@
}
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Lifecycle Reactivestreams"
publish = true
diff --git a/lifecycle/runtime/build.gradle b/lifecycle/runtime/build.gradle
index 01a8abb..cf0e4d3 100644
--- a/lifecycle/runtime/build.gradle
+++ b/lifecycle/runtime/build.gradle
@@ -29,8 +29,6 @@
androidTestImplementation libs.test_runner, { exclude module: 'support-annotations' }
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name 'Android Lifecycle Runtime'
publish true
diff --git a/paging/common/build.gradle b/paging/common/build.gradle
index d07103f..6bebc5e 100644
--- a/paging/common/build.gradle
+++ b/paging/common/build.gradle
@@ -34,9 +34,6 @@
testCompile libs.kotlin.stdlib
}
-createAndroidCheckstyle(project)
-createKotlinCheckstyle(project)
-
supportLibrary {
name = "Android Paging-Common"
publish = true
diff --git a/paging/integration-tests/testapp/build.gradle b/paging/integration-tests/testapp/build.gradle
index fb19ba0..76ef98b 100644
--- a/paging/integration-tests/testapp/build.gradle
+++ b/paging/integration-tests/testapp/build.gradle
@@ -58,7 +58,6 @@
implementation libs.support.app_compat, libs.support_exclude_config
}
-createAndroidCheckstyle(project)
tasks['check'].dependsOn(tasks['connectedCheck'])
uploadArchives.enabled = false
diff --git a/paging/runtime/build.gradle b/paging/runtime/build.gradle
index 187acb9..ce2d722 100644
--- a/paging/runtime/build.gradle
+++ b/paging/runtime/build.gradle
@@ -43,12 +43,8 @@
androidTestImplementation libs.test_runner, { exclude module: 'support-annotations' }
androidTestImplementation libs.espresso_core, { exclude module: 'support-annotations' }
androidTestImplementation libs.kotlin.stdlib
-
}
-createAndroidCheckstyle(project)
-createKotlinCheckstyle(project)
-
supportLibrary {
name = "Android Lifecycle Extensions"
publish = true
diff --git a/persistence/db-framework/build.gradle b/persistence/db-framework/build.gradle
index 8607bf6..3ef00c1 100644
--- a/persistence/db-framework/build.gradle
+++ b/persistence/db-framework/build.gradle
@@ -33,8 +33,6 @@
api project(":persistence:db")
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Support SQLite - Framework Implementation"
publish = true
diff --git a/persistence/db/build.gradle b/persistence/db/build.gradle
index 085676d..6f5c7f5 100644
--- a/persistence/db/build.gradle
+++ b/persistence/db/build.gradle
@@ -32,8 +32,6 @@
api libs.support.annotations
}
-createAndroidCheckstyle(project)
-
// Used by testCompile in room-compiler
android.libraryVariants.all { variant ->
def name = variant.buildType.name
diff --git a/room/common/build.gradle b/room/common/build.gradle
index 21441a2..dea4b9a 100644
--- a/room/common/build.gradle
+++ b/room/common/build.gradle
@@ -28,8 +28,6 @@
testCompile libs.mockito_core
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Room-Common"
publish = true
diff --git a/room/compiler/build.gradle b/room/compiler/build.gradle
index eb9628c..56a0c27 100644
--- a/room/compiler/build.gradle
+++ b/room/compiler/build.gradle
@@ -27,7 +27,6 @@
main.java.srcDirs += antlrOut
}
project.ext.noDocs = true
-version = LibraryVersions.ROOM.toString()
// Temporary hack to stop AS to adding two guavas into test's classpath
configurations.all {
@@ -77,8 +76,6 @@
tasks.findByName("compileKotlin").dependsOn(":room:runtime:jarDebug")
tasks.findByName("compileKotlin").dependsOn(":persistence:db:jarDebug")
-createKotlinCheckstyle(project)
-
supportLibrary {
name = "Android Room Compiler"
publish = true
diff --git a/room/integration-tests/kotlintestapp/build.gradle b/room/integration-tests/kotlintestapp/build.gradle
index f1f5139..4545c07 100644
--- a/room/integration-tests/kotlintestapp/build.gradle
+++ b/room/integration-tests/kotlintestapp/build.gradle
@@ -86,8 +86,6 @@
testImplementation libs.mockito_core
}
-createAndroidCheckstyle(project)
-createKotlinCheckstyle(project)
tasks['check'].dependsOn(tasks['connectedCheck'])
uploadArchives.enabled = false
diff --git a/room/integration-tests/testapp/build.gradle b/room/integration-tests/testapp/build.gradle
index b063595..53ed69a 100644
--- a/room/integration-tests/testapp/build.gradle
+++ b/room/integration-tests/testapp/build.gradle
@@ -93,7 +93,6 @@
testImplementation libs.junit
}
-createAndroidCheckstyle(project)
tasks['check'].dependsOn(tasks['connectedCheck'])
uploadArchives.enabled = false
diff --git a/room/runtime/build.gradle b/room/runtime/build.gradle
index 0570fe8..85bcc40 100644
--- a/room/runtime/build.gradle
+++ b/room/runtime/build.gradle
@@ -52,8 +52,6 @@
androidTestImplementation libs.espresso_core, { exclude module: 'support-annotations' }
}
-createAndroidCheckstyle(project)
-
// Used by testCompile in room-compiler
android.libraryVariants.all { variant ->
def name = variant.buildType.name
diff --git a/room/rxjava2/build.gradle b/room/rxjava2/build.gradle
index efdfc48..1b6daba 100644
--- a/room/rxjava2/build.gradle
+++ b/room/rxjava2/build.gradle
@@ -39,8 +39,6 @@
testImplementation project(":arch:core-testing")
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Room RXJava2"
publish = true
diff --git a/room/testing/build.gradle b/room/testing/build.gradle
index 876300a..3556541 100644
--- a/room/testing/build.gradle
+++ b/room/testing/build.gradle
@@ -39,8 +39,6 @@
api libs.junit
}
-createAndroidCheckstyle(project)
-
supportLibrary {
name = "Android Room Testing"
publish = true