build: apply Ktfmt Gradle plugin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
5e28cf45e4
commit
cd378d1bbc
5 changed files with 28 additions and 0 deletions
|
@ -7,6 +7,16 @@ plugins {
|
||||||
`aps-plugin`
|
`aps-plugin`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath(Plugins.ktfmtGradlePlugin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
apply(plugin = "com.ncorti.ktfmt.gradle")
|
||||||
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy.dependencySubstitution {
|
resolutionStrategy.dependencySubstitution {
|
||||||
|
|
|
@ -37,6 +37,7 @@ dependencies {
|
||||||
implementation(Plugins.dokkaPlugin)
|
implementation(Plugins.dokkaPlugin)
|
||||||
implementation(Plugins.downloadTaskPlugin)
|
implementation(Plugins.downloadTaskPlugin)
|
||||||
implementation(Plugins.kotlinGradlePlugin)
|
implementation(Plugins.kotlinGradlePlugin)
|
||||||
|
implementation(Plugins.ktfmtGradlePlugin)
|
||||||
implementation(Plugins.mavenPublishPlugin)
|
implementation(Plugins.mavenPublishPlugin)
|
||||||
implementation(Plugins.semver4j)
|
implementation(Plugins.semver4j)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ object Plugins {
|
||||||
const val dokkaPlugin = "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20"
|
const val dokkaPlugin = "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20"
|
||||||
const val downloadTaskPlugin = "de.undercouch:gradle-download-task:4.1.1"
|
const val downloadTaskPlugin = "de.undercouch:gradle-download-task:4.1.1"
|
||||||
const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
|
const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
|
||||||
|
const val ktfmtGradlePlugin = "com.ncorti.ktfmt.gradle:plugin:0.4.0"
|
||||||
const val mavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.13.0"
|
const val mavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.13.0"
|
||||||
const val semver4j = "com.vdurmont:semver4j:3.1.0"
|
const val semver4j = "com.vdurmont:semver4j:3.1.0"
|
||||||
}
|
}
|
||||||
|
|
11
buildSrc/src/main/java/Ktfmt.kt
Normal file
11
buildSrc/src/main/java/Ktfmt.kt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.ncorti.ktfmt.gradle.KtfmtExtension
|
||||||
|
|
||||||
|
fun KtfmtExtension.configureKtfmt() {
|
||||||
|
googleStyle()
|
||||||
|
maxWidth.set(120)
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import com.android.build.gradle.TestedExtension
|
||||||
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
||||||
import com.android.build.gradle.internal.plugins.AppPlugin
|
import com.android.build.gradle.internal.plugins.AppPlugin
|
||||||
import com.android.build.gradle.internal.plugins.LibraryPlugin
|
import com.android.build.gradle.internal.plugins.LibraryPlugin
|
||||||
|
import com.ncorti.ktfmt.gradle.KtfmtExtension
|
||||||
|
import com.ncorti.ktfmt.gradle.KtfmtPlugin
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.plugins.JavaLibraryPlugin
|
import org.gradle.api.plugins.JavaLibraryPlugin
|
||||||
|
@ -41,6 +43,9 @@ class PasswordStorePlugin : Plugin<Project> {
|
||||||
project.extensions.getByType<BaseAppModuleExtension>().configureBuildSigning(project)
|
project.extensions.getByType<BaseAppModuleExtension>().configureBuildSigning(project)
|
||||||
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
|
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
|
||||||
}
|
}
|
||||||
|
is KtfmtPlugin -> {
|
||||||
|
project.extensions.getByType<KtfmtExtension>().configureKtfmt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue