Update ktlint to 1.8.0 (#1627)
diff --git a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/CompilationTask.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/CompilationTask.kt
index 87fd7a8..4fd12c2 100644
--- a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/CompilationTask.kt
+++ b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/CompilationTask.kt
@@ -74,7 +74,10 @@
}
inputs.directDependenciesList + transitiveDepsForCompile
}
- else -> inputs.classpathList
+
+ else -> {
+ inputs.classpathList
+ }
} as List<String>
return CompilationArgs()
@@ -169,18 +172,21 @@
.toFloat()
when {
- version < 1.5 ->
+ version < 1.5 -> {
base64Encode(
"-P",
*values + ("processors" to inputs.processorsList).asKeyToCommaList(),
) { enc -> "plugin:${plugins.kapt.id}:configuration=$enc" }
- else ->
+ }
+
+ else -> {
repeatFlag(
"-P",
*values + ("processors" to inputs.processorsList),
) { option, value ->
"plugin:${plugins.kapt.id}:$option=$value"
}
+ }
}
// Read kapt options from the plugin options
val optionPrefix = plugins.kapt.id + ":apoption="
diff --git a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt
index e8d2451..6eeedae 100644
--- a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt
+++ b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt
@@ -41,8 +41,13 @@
return one
}
- one != null -> one
- else -> two
+ one != null -> {
+ one
+ }
+
+ else -> {
+ two
+ }
}
}
@@ -120,10 +125,13 @@
}.map {
when (it.second) {
// TODO(issue/296): remove when the CompilationStatusException is unified.
- is CompilationStatusException ->
+ is CompilationStatusException -> {
(it.second as CompilationStatusException).lines + it.first to it.second
+ }
- else -> it
+ else -> {
+ it
+ }
}
}.fold(Pair<List<String>, Throwable?>(emptyList(), null)) { acc, result ->
acc.first + result.first to combine(acc.second, result.second)
diff --git a/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarExtractor.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarExtractor.kt
index dcba24f..5a4e6ad 100644
--- a/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarExtractor.kt
+++ b/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarExtractor.kt
@@ -41,13 +41,16 @@
destDir.resolve(entry.name).also { target ->
if (preWrite(entry.isDirectory, target)) {
when {
- entry.isDirectory ->
+ entry.isDirectory -> {
Files.createDirectories(target)
- else ->
+ }
+
+ else -> {
jar.getInputStream(entry).use {
Files.createDirectories(target.parent)
Files.copy(it, target, StandardCopyOption.REPLACE_EXISTING)
}
+ }
}
}
}
diff --git a/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/BaseJdepsGenExtension.kt b/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/BaseJdepsGenExtension.kt
index 33b30d4..f7dd650 100644
--- a/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/BaseJdepsGenExtension.kt
+++ b/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/BaseJdepsGenExtension.kt
@@ -148,7 +148,10 @@
explicitDeps: Map<String, List<String>>,
) {
when (compilerConfiguration.getNotNull(JdepsGenConfigurationKeys.STRICT_KOTLIN_DEPS)) {
- "warn" -> checkStrictDeps(explicitDeps, directDeps, targetLabel)
+ "warn" -> {
+ checkStrictDeps(explicitDeps, directDeps, targetLabel)
+ }
+
"error" -> {
if (checkStrictDeps(explicitDeps, directDeps, targetLabel)) {
error(
diff --git a/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenCommandLineProcessor.kt b/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenCommandLineProcessor.kt
index f463f9f..a37acf4 100644
--- a/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenCommandLineProcessor.kt
+++ b/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenCommandLineProcessor.kt
@@ -54,24 +54,38 @@
configuration: CompilerConfiguration,
) {
when (option) {
- OUTPUT_JDEPS_FILE_OPTION -> configuration.put(JdepsGenConfigurationKeys.OUTPUT_JDEPS, value)
- TARGET_LABEL_OPTION -> configuration.put(JdepsGenConfigurationKeys.TARGET_LABEL, value)
- DIRECT_DEPENDENCIES_OPTION ->
+ OUTPUT_JDEPS_FILE_OPTION -> {
+ configuration.put(JdepsGenConfigurationKeys.OUTPUT_JDEPS, value)
+ }
+
+ TARGET_LABEL_OPTION -> {
+ configuration.put(JdepsGenConfigurationKeys.TARGET_LABEL, value)
+ }
+
+ DIRECT_DEPENDENCIES_OPTION -> {
configuration.appendList(
JdepsGenConfigurationKeys.DIRECT_DEPENDENCIES,
value,
)
- FULL_CLASSPATH_OPTION ->
+ }
+
+ FULL_CLASSPATH_OPTION -> {
configuration.appendList(
JdepsGenConfigurationKeys.FULL_CLASSPATH,
value,
)
- STRICT_KOTLIN_DEPS_OPTION ->
+ }
+
+ STRICT_KOTLIN_DEPS_OPTION -> {
configuration.put(
JdepsGenConfigurationKeys.STRICT_KOTLIN_DEPS,
value,
)
- else -> throw CliOptionProcessingException("Unknown option: ${option.optionName}")
+ }
+
+ else -> {
+ throw CliOptionProcessingException("Unknown option: ${option.optionName}")
+ }
}
}
diff --git a/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenExtension.kt b/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenExtension.kt
index 595a203..6cff3ab 100644
--- a/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenExtension.kt
+++ b/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/JdepsGenExtension.kt
@@ -94,7 +94,7 @@
}
return when (sourceElement) {
- is JavaSourceElement ->
+ is JavaSourceElement -> {
if (sourceElement.javaElement is BinaryJavaClass) {
(sourceElement.javaElement as BinaryJavaClass).virtualFile.canonicalPath
} else if (sourceElement.javaElement is BinaryJavaField) {
@@ -108,9 +108,11 @@
// Ignore Java source local to this module.
null
}
+ }
- is KotlinJvmBinarySourceElement ->
+ is KotlinJvmBinarySourceElement -> {
(sourceElement.binaryClass as VirtualFileKotlinClass).file.canonicalPath
+ }
is JvmPackagePartSource -> { // This case is needed to collect type aliases
((sourceElement.knownJvmBinaryClass) as VirtualFileKotlinClass).file.canonicalPath
diff --git a/src/main/starlark/core/repositories/versions.bzl b/src/main/starlark/core/repositories/versions.bzl
index b697fcd..97e88e6 100644
--- a/src/main/starlark/core/repositories/versions.bzl
+++ b/src/main/starlark/core/repositories/versions.bzl
@@ -59,11 +59,11 @@
],
),
PINTEREST_KTLINT = version(
- version = "1.6.0",
+ version = "1.8.0",
url_templates = [
"https://github.com/pinterest/ktlint/releases/download/{version}/ktlint",
],
- sha256 = "5ba1ac917a06b0f02daaa60d10abbedd2220d60216af670c67a45b91c74cf8bb",
+ sha256 = "a3fd620207d5c40da6ca789b95e7f823c54e854b7fade7f613e91096a3706d75",
),
KOTLIN_CURRENT_COMPILER_RELEASE = version(
version = "2.4.0",