From 81b2dfd9d039d62f169be60151e3dd3db6ea1b13 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 25 Apr 2020 14:30:14 -0400 Subject: [PATCH] Update top level project build scripts --- app/build.gradle | 4 +- build.gradle.kts | 55 ++++++++++++++++-------- buildSrc/.gitignore | 1 + buildSrc/build.gradle.kts | 6 +++ buildSrc/src/main/kotlin/Dependencies.kt | 10 +++++ settings.gradle.kts | 19 ++++++++ 6 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 buildSrc/.gitignore create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/Dependencies.kt diff --git a/app/build.gradle b/app/build.gradle index 8608d7ad04..11551ccdcd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,6 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'com.github.zellius.shortcut-helper' -apply plugin: "org.jmailen.kotlinter" shortcutHelper.filePath = './shortcuts.xml' @@ -292,8 +291,7 @@ task copyResources(type: Copy) { include '**/*' } -preBuild.dependsOn(lintKotlin, copyResources) -lintKotlin.dependsOn(formatKotlin) +preBuild.dependsOn(ktlintFormat, copyResources) if (getGradle().getStartParameter().getTaskRequests().toString().contains("Standard")) { apply plugin: 'com.google.gms.google-services' diff --git a/build.gradle.kts b/build.gradle.kts index 837208b3fe..dce058679c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,22 +1,9 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.github.ben-manes.versions") version "0.28.0" -} - -buildscript { - repositories { - google() - jcenter() - } - dependencies { - classpath("com.android.tools.build:gradle:3.6.2") - classpath("com.github.zellius:android-shortcut-gradle-plugin:0.1.2") - classpath("org.jmailen.gradle:kotlinter-gradle:2.3.2") - classpath("com.google.gms:google-services:4.3.3") - classpath("com.google.android.gms:oss-licenses-plugin:0.10.2") - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } + id("com.android.application") version BuildPluginsVersion.AGP apply false + id("com.android.library") version BuildPluginsVersion.AGP apply false + kotlin("android") version BuildPluginsVersion.KOTLIN apply false + id("org.jlleitschuh.gradle.ktlint") version BuildPluginsVersion.KTLINT + id("com.github.ben-manes.versions") version BuildPluginsVersion.VERSIONS_PLUGIN } allprojects { @@ -28,6 +15,38 @@ allprojects { } } +subprojects { + apply { + plugin("org.jlleitschuh.gradle.ktlint") + } + + ktlint { + debug.set(false) + version.set(Versions.KTLINT) + verbose.set(true) + android.set(false) + outputToConsole.set(true) + ignoreFailures.set(false) + enableExperimentalRules.set(true) + filter { + exclude("**/generated/**") + include("**/kotlin/**") + } + } +} + +buildscript { + dependencies { + classpath("com.github.zellius:android-shortcut-gradle-plugin:0.1.2") + classpath("com.google.gms:google-services:4.3.3") + classpath("com.google.android.gms:oss-licenses-plugin:0.10.2") + } + repositories { + google() + jcenter() + } +} + tasks.register("clean", Delete::class) { delete(rootProject.buildDir) } diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/buildSrc/.gitignore @@ -0,0 +1 @@ +/build diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000000..cc48205ae6 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,6 @@ +plugins { + `kotlin-dsl` +} +repositories { + jcenter() +} diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt new file mode 100644 index 0000000000..0ae0ed61e7 --- /dev/null +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -0,0 +1,10 @@ +object Versions { + const val KTLINT = "0.36.0" +} + +object BuildPluginsVersion { + const val AGP = "3.6.3" + const val KOTLIN = "1.3.72" + const val KTLINT = "9.2.1" + const val VERSIONS_PLUGIN = "0.28.0" +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 15a801b10a..68ad4f3b8d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,20 @@ +pluginManagement { + resolutionStrategy { + eachPlugin { + if (requested.id.id == "com.android.library") { + useModule("com.android.tools.build:gradle:${requested.version}") + } + if (requested.id.id == "com.android.application") { + useModule("com.android.tools.build:gradle:${requested.version}") + } + } + } + repositories { + gradlePluginPortal() + google() + mavenCentral() + jcenter() + } +} + include(":app")