fix(deps): update ktfmt to 0.51
This commit is contained in:
parent
4c0b6d1f91
commit
b596930ec5
4 changed files with 18 additions and 25 deletions
|
@ -2,6 +2,7 @@ package app.passwordstore.gradle
|
|||
|
||||
import app.passwordstore.gradle.ktfmt.KtfmtCheckTask
|
||||
import app.passwordstore.gradle.ktfmt.KtfmtFormatTask
|
||||
import com.facebook.ktfmt.format.FormattingOptions
|
||||
import java.util.concurrent.Callable
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
@ -21,4 +22,16 @@ class KtfmtPlugin : Plugin<Project> {
|
|||
projectDirectory.set(target.layout.projectDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val DEFAULT_FORMATTING_OPTIONS =
|
||||
FormattingOptions(
|
||||
maxWidth = FormattingOptions.DEFAULT_MAX_WIDTH,
|
||||
blockIndent = 2,
|
||||
continuationIndent = 2,
|
||||
removeUnusedImports = true,
|
||||
debuggingPrintOpsAfterFormatting = false,
|
||||
manageTrailingCommas = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package app.passwordstore.gradle.ktfmt
|
||||
|
||||
import app.passwordstore.gradle.KtfmtPlugin
|
||||
import com.facebook.ktfmt.format.Formatter
|
||||
import com.facebook.ktfmt.format.FormattingOptions
|
||||
import java.io.File
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
|
@ -50,15 +50,7 @@ abstract class KtfmtCheckTask : SourceTask() {
|
|||
|
||||
private fun checkFile(input: File): Pair<Boolean, List<KtfmtDiffEntry>> {
|
||||
val originCode = input.readText()
|
||||
val formattedCode =
|
||||
Formatter.format(
|
||||
FormattingOptions(
|
||||
style = FormattingOptions.Style.GOOGLE,
|
||||
maxWidth = 100,
|
||||
continuationIndent = 2,
|
||||
),
|
||||
originCode,
|
||||
)
|
||||
val formattedCode = Formatter.format(KtfmtPlugin.DEFAULT_FORMATTING_OPTIONS, originCode)
|
||||
val pathNormalizer = { file: File -> file.toRelativeString(projectDirectory.asFile.get()) }
|
||||
return (originCode != formattedCode) to
|
||||
KtfmtDiffer.computeDiff(input, formattedCode, pathNormalizer)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package app.passwordstore.gradle.ktfmt
|
||||
|
||||
import app.passwordstore.gradle.KtfmtPlugin
|
||||
import com.facebook.ktfmt.format.Formatter
|
||||
import com.facebook.ktfmt.format.FormattingOptions
|
||||
import java.io.File
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.logging.Logger
|
||||
|
@ -24,19 +24,7 @@ abstract class KtfmtWorkerAction : WorkAction<KtfmtWorkerParameters> {
|
|||
|
||||
logger.log(LogLevel.DEBUG, "$name checking format: $relativePath")
|
||||
|
||||
val formattedText =
|
||||
Formatter.format(
|
||||
FormattingOptions(
|
||||
style = FormattingOptions.Style.GOOGLE,
|
||||
maxWidth = FormattingOptions.DEFAULT_MAX_WIDTH,
|
||||
blockIndent = 2,
|
||||
continuationIndent = 2,
|
||||
removeUnusedImports = true,
|
||||
debuggingPrintOpsAfterFormatting = false,
|
||||
manageTrailingCommas = true,
|
||||
),
|
||||
sourceText,
|
||||
)
|
||||
val formattedText = Formatter.format(KtfmtPlugin.DEFAULT_FORMATTING_OPTIONS, sourceText)
|
||||
|
||||
if (!formattedText.contentEquals(sourceText)) {
|
||||
logger.log(LogLevel.QUIET, "${file.toRelativeString(projectDirectory)}: Format fixed")
|
||||
|
|
|
@ -39,7 +39,7 @@ build-diffutils = "io.github.java-diff-utils:java-diff-utils:4.12"
|
|||
build-download = "de.undercouch:gradle-download-task:5.6.0"
|
||||
build-javapoet = "com.squareup:javapoet:1.13.0"
|
||||
build-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
build-ktfmt = "com.facebook:ktfmt:0.50"
|
||||
build-ktfmt = "com.facebook:ktfmt:0.51"
|
||||
build-mavenpublish = "com.vanniktech:gradle-maven-publish-plugin:0.28.0"
|
||||
build-metalava = "me.tylerbwong.gradle.metalava:plugin:0.3.5"
|
||||
build-moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
|
||||
|
|
Loading…
Reference in a new issue