[#309] Move ktlint to convention plugin
This resolves some compatibility issues with trying to invoke ktlint directly from the the app module, while also enabling ktlint to be run on the entire project
This commit is contained in:
parent
b1ce0ef1d2
commit
cb7c2d3e74
|
@ -198,7 +198,3 @@ dependencies {
|
|||
}
|
||||
|
||||
defaultTasks 'clean', 'assembleZcashmainnetRelease'
|
||||
|
||||
apply from: "$rootDir/ktlint.gradle"
|
||||
preBuild.dependsOn('ktlintFormat')
|
||||
preBuild.dependsOn('ktlint')
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import org.jetbrains.kotlin.konan.properties.loadProperties
|
||||
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
buildscript {
|
||||
dependencyLocking {
|
||||
lockAllConfigurations()
|
||||
}
|
||||
}
|
||||
|
||||
dependencyLocking {
|
||||
lockAllConfigurations()
|
||||
}
|
||||
|
||||
// Per conversation in the KotlinLang Slack, Gradle uses Java 8 compatibility internally
|
||||
// for all build scripts.
|
||||
// https://kotlinlang.slack.com/archives/C19FD9681/p1636632870122900?thread_ts=1636572288.117000&cid=C19FD9681
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
# This is a Gradle generated file for dependency locking.
|
||||
# Manual edits can break the build and are not advised.
|
||||
# This file is expected to be part of source control.
|
||||
com.github.gundy:semver4j:0.16.4=classpath
|
||||
com.google.code.findbugs:jsr305:3.0.2=classpath
|
||||
com.google.code.gson:gson:2.8.6=classpath
|
||||
com.google.errorprone:error_prone_annotations:2.3.4=classpath
|
||||
com.google.guava:failureaccess:1.0.1=classpath
|
||||
com.google.guava:guava:29.0-jre=classpath
|
||||
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=classpath
|
||||
com.google.j2objc:j2objc-annotations:1.3=classpath
|
||||
de.undercouch:gradle-download-task:4.1.1=classpath
|
||||
org.checkerframework:checker-qual:2.11.1=classpath
|
||||
org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:2.1.7=classpath
|
||||
org.gradle.kotlin:gradle-kotlin-dsl-plugins:2.1.7=classpath
|
||||
org.jetbrains.intellij.deps:trove4j:1.0.20181211=classpath
|
||||
org.jetbrains.kotlin:kotlin-android-extensions:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-build-common:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-compiler-runner:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-daemon-client:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-native-utils:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-project-model:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-sam-with-receiver:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-scripting-common:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-scripting-jvm:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-tooling-metadata:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-util-io:1.5.31=classpath
|
||||
org.jetbrains.kotlin:kotlin-util-klib:1.5.31=classpath
|
||||
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=classpath
|
||||
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0=classpath
|
||||
org.jetbrains:annotations:13.0=classpath
|
||||
empty=
|
|
@ -0,0 +1,28 @@
|
|||
# This is a Gradle generated file for dependency locking.
|
||||
# Manual edits can break the build and are not advised.
|
||||
# This file is expected to be part of source control.
|
||||
org.jetbrains.intellij.deps:trove4j:1.0.20181211=kotlinCompilerClasspath
|
||||
org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.31=kotlinCompilerClasspath
|
||||
org.jetbrains.kotlin:kotlin-daemon-embeddable:1.5.31=kotlinCompilerClasspath
|
||||
org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-native-utils:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-project-model:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-reflect:1.5.31=compileClasspath,kotlinCompilerClasspath
|
||||
org.jetbrains.kotlin:kotlin-sam-with-receiver:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-script-runtime:1.5.31=kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-scripting-common:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-scripting-jvm:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31=compileClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.0=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31=compileClasspath
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.0=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31=compileClasspath
|
||||
org.jetbrains.kotlin:kotlin-stdlib:1.5.31=compileClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlin:kotlin-util-io:1.5.31=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0=kotlinCompilerPluginClasspathMain
|
||||
org.jetbrains:annotations:13.0=compileClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain
|
||||
empty=annotationProcessor,runtimeClasspath
|
|
@ -0,0 +1,31 @@
|
|||
@Suppress("UnstableApiUsage")
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
val isRepoRestrictionEnabled = true
|
||||
|
||||
google {
|
||||
if (isRepoRestrictionEnabled) {
|
||||
content {
|
||||
includeGroup("androidx.navigation")
|
||||
includeGroup("com.android.tools")
|
||||
includeGroup("com.google.testing.platform")
|
||||
includeGroupByRegex("androidx.*")
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.android\\.tools.*")
|
||||
}
|
||||
}
|
||||
}
|
||||
mavenCentral {
|
||||
if (isRepoRestrictionEnabled) {
|
||||
content {
|
||||
excludeGroup("androidx.navigation")
|
||||
excludeGroup("com.android.tools")
|
||||
excludeGroup("com.google.testing.platform")
|
||||
excludeGroupByRegex("androidx.*")
|
||||
excludeGroupByRegex("com\\.android.*")
|
||||
excludeGroupByRegex("com\\.android\\.tools.*")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
disabled_rules=import-ordering,no-wildcard-imports
|
||||
|
||||
# Defines the imports layout. The layout can be composed by the following symbols:
|
||||
# "*" - wildcard. There must be at least one entry of a single wildcard to match all other imports. Matches anything after a specified symbol/import as well.
|
||||
# "|" - blank line. Supports only single blank lines between imports. No blank line is allowed in the beginning or end of the layout.
|
||||
# "^" - alias import, e.g. "^android.*" will match all android alias imports, "^" will match all other alias imports.
|
||||
# import paths - these can be full paths, e.g. "java.util.List.*" as well as wildcard paths, e.g. "kotlin.**"
|
||||
# Examples (we use ij_kotlin_imports_layout to set an imports layout for both ktlint and IDEA via a single property):
|
||||
ij_kotlin_imports_layout=* # alphabetical with capital letters before lower case letters (e.g. Z before a), no blank lines
|
||||
ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^ # default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
|
||||
ij_kotlin_imports_layout=android.**,|,^org.junit.**,kotlin.io.Closeable.*,|,*,^ # custom imports layout
|
|
@ -0,0 +1,44 @@
|
|||
plugins {
|
||||
id("java")
|
||||
}
|
||||
|
||||
val ktlint by configurations.creating
|
||||
|
||||
dependencies {
|
||||
ktlint("com.pinterest:ktlint:${project.property("KTLINT_VERSION")}") {
|
||||
attributes {
|
||||
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named<Bundling>(Bundling.EXTERNAL))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
val editorConfigFile = rootProject.file(".editorconfig")
|
||||
val ktlintArgs = listOf("**/src/**/*.kt", "!**/build/**.kt", "--editorconfig=$editorConfigFile")
|
||||
|
||||
register("ktlint", org.gradle.api.tasks.JavaExec::class) {
|
||||
description = "Check code style with ktlint"
|
||||
classpath = ktlint
|
||||
mainClass.set("com.pinterest.ktlint.Main")
|
||||
args = ktlintArgs
|
||||
}
|
||||
|
||||
register("ktlintFormat", org.gradle.api.tasks.JavaExec::class) {
|
||||
// Workaround for ktlint bug; force to run on an older JDK
|
||||
// https://github.com/pinterest/ktlint/issues/1274
|
||||
javaLauncher.set(javaToolchains.launcherFor {
|
||||
languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_11.majorVersion))
|
||||
})
|
||||
|
||||
description = "Apply code style formatting with ktlint"
|
||||
classpath = ktlint
|
||||
mainClass.set("com.pinterest.ktlint.Main")
|
||||
args = listOf("-F") + ktlintArgs
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
val javaVersion = JavaVersion.toVersion(project.property("ANDROID_JVM_TARGET").toString())
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
}
|
|
@ -13,6 +13,7 @@ buildscript {
|
|||
|
||||
plugins {
|
||||
id("com.github.ben-manes.versions")
|
||||
id("zcash.ktlint-conventions")
|
||||
}
|
||||
|
||||
defaultTasks("clean", "installZcashmainnetRelease")
|
||||
|
|
|
@ -23,4 +23,9 @@ android.builder.sdkDownload=true
|
|||
isUseTestOrchestrator=false
|
||||
|
||||
# Toggles between using the SDK Maven artifact versus an included build
|
||||
IS_SDK_INCLUDED_BUILD=false
|
||||
IS_SDK_INCLUDED_BUILD=false
|
||||
|
||||
KTLINT_VERSION=0.45.2
|
||||
|
||||
|
||||
ANDROID_JVM_TARGET=1.8
|
|
@ -1,21 +0,0 @@
|
|||
configurations {
|
||||
ktlint
|
||||
}
|
||||
|
||||
dependencies {
|
||||
ktlint "com.pinterest:ktlint:0.41.0"
|
||||
}
|
||||
|
||||
task ktlint(type: org.gradle.api.tasks.JavaExec, group: "verification") {
|
||||
description = "Verifying Kotlin code style.."
|
||||
classpath = configurations.ktlint
|
||||
main = "com.pinterest.ktlint.Main"
|
||||
args "-F", "src/**/*.kt", "--editorconfig=${rootProject.file(".editorconfig")}"
|
||||
}
|
||||
|
||||
task ktlintFormat(type: org.gradle.api.tasks.JavaExec, group: "formatting") {
|
||||
description = "Format Kotlin code style deviations."
|
||||
classpath = configurations.ktlint
|
||||
main = "com.pinterest.ktlint.Main"
|
||||
args "-F", "src/**/*.kt", "--editorconfig=${rootProject.file(".editorconfig")}"
|
||||
}
|
|
@ -18,6 +18,9 @@ dependencyResolutionManagement {
|
|||
}
|
||||
|
||||
rootProject.name="ecc-wallet"
|
||||
|
||||
includeBuild("build-convention")
|
||||
|
||||
include(":app")
|
||||
include(":qrecycler")
|
||||
include(":feedback")
|
||||
|
|
Loading…
Reference in New Issue