Fix some warnings in Gradle plugin and related modules

This commit is contained in:
Alexander Udalov
2021-07-26 13:41:43 +02:00
parent 376b420d1a
commit ca7334acb9
29 changed files with 77 additions and 49 deletions
@@ -250,6 +250,7 @@ private fun Printer.generateDeclaration(
println("package ${type.parent()}")
println()
}
println("@Suppress(\"DEPRECATION\")")
print("$modifiers ${type.shortName()} ")
afterType?.let { print("$afterType ") }
println("{")
@@ -16,16 +16,16 @@
package example
import com.intellij.mock.MockProject
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.config.CompilerConfigurationKey
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
import org.jetbrains.kotlin.compiler.plugin.CliOption
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.compiler.plugin.CliOptionProcessingException
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
import com.intellij.mock.MockProject
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.CompilerConfigurationKey
public object ExampleConfigurationKeys {
public val EXAMPLE_KEY: CompilerConfigurationKey<String> = CompilerConfigurationKey.create<String>("example argument")
@@ -46,7 +46,7 @@ public class ExampleCommandLineProcessor : CommandLineProcessor {
when (option) {
EXAMPLE_OPTION -> configuration.put(ExampleConfigurationKeys.EXAMPLE_KEY, value)
EXAMPLE_LEGACY_OPTION -> configuration.put(ExampleConfigurationKeys.EXAMPLE_LEGACY_KEY, value)
else -> throw CliOptionProcessingException("Unknown option: ${option.name}")
else -> throw CliOptionProcessingException("Unknown option: ${option.optionName}")
}
}
}
@@ -20,7 +20,7 @@ import org.gradle.api.Project
import org.gradle.api.tasks.compile.AbstractCompile
import org.jetbrains.kotlin.gradle.plugin.*
class ExampleLegacySubplugin : KotlinGradleSubplugin<AbstractCompile> {
class ExampleLegacySubplugin : @Suppress("DEPRECATION") KotlinGradleSubplugin<AbstractCompile> {
override fun isApplicable(project: Project, task: AbstractCompile): Boolean {
return true
@@ -46,4 +46,4 @@ class ExampleLegacySubplugin : KotlinGradleSubplugin<AbstractCompile> {
override fun getPluginArtifact(): SubpluginArtifact =
JetBrainsSubpluginArtifact("kotlin-gradle-subplugin-example")
}
}
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
interface KotlinCommonOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonToolOptions {
/**
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
interface KotlinCommonToolOptions {
/**
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle
import com.intellij.testFramework.TestDataFile
@@ -464,11 +469,11 @@ abstract class BaseGradleIT {
val errors = "(?m)^.*\\[ERROR] \\[\\S+] (.*)$".toRegex().findAll(output)
val errorMessage = buildString {
appendln("Gradle build failed")
appendln()
appendLine("Gradle build failed")
appendLine()
if (errors.any()) {
appendln("Possible errors:")
errors.forEach { match -> appendln(match.groupValues[1]) }
appendLine("Possible errors:")
errors.forEach { match -> appendLine(match.groupValues[1]) }
}
}
fail(errorMessage)
@@ -863,10 +868,10 @@ Finished executing task ':$taskName'|
}
val xmlString = buildString {
appendln("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
appendln("<results>")
appendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
appendLine("<results>")
files.forEach { file ->
appendln(
appendLine(
file.readText()
.trimTrailingWhitespaces()
.replace(projectDir.absolutePath, "/\$PROJECT_DIR$")
@@ -874,7 +879,7 @@ Finished executing task ':$taskName'|
.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
)
}
appendln("</results>")
appendLine("</results>")
}
val doc = SAXBuilder().build(xmlString.reader())
@@ -75,7 +75,7 @@ class KotlinGradleIT : BaseGradleIT() {
wd1.deleteRecursively()
if (wd1.exists()) {
val files = buildString {
wd1.walk().forEach { appendln(" " + it.relativeTo(wd1).path) }
wd1.walk().forEach { appendLine(" " + it.relativeTo(wd1).path) }
}
error("Some files in $wd1 were not removed:\n$files")
}
@@ -55,11 +55,11 @@ class MppHighlightingTestDataWithGradleIT : BaseGradleIT() {
// create Gradle Kotlin source sets for project roots:
val scriptCustomization = buildString {
appendln()
appendln("kotlin {\n sourceSets {")
appendLine()
appendLine("kotlin {\n sourceSets {")
sourceRoots.forEach { sourceRoot ->
if (sourceRoot.kotlinSourceSetName != "commonMain") {
appendln(
appendLine(
""" create("${sourceRoot.kotlinSourceSetName}") {
| dependsOn(getByName("commonMain"))
| listOf(${cliCompiler.targets.joinToString { "$it()" }}).forEach {
@@ -70,7 +70,7 @@ class MppHighlightingTestDataWithGradleIT : BaseGradleIT() {
""".trimMargin()
)
} else {
appendln(" // commonMain source set used for common module")
appendLine(" // commonMain source set used for common module")
}
}
@@ -79,11 +79,11 @@ class MppHighlightingTestDataWithGradleIT : BaseGradleIT() {
sourceRoot.dependencies.forEach { dependency ->
sourceRoots.find { it.qualifiedName == dependency }?.let { depSourceRoot ->
val depSourceSet = depSourceRoot.kotlinSourceSetName
appendln(""" getByName("${sourceRoot.kotlinSourceSetName}").dependsOn(getByName("$depSourceSet"))""")
appendLine(""" getByName("${sourceRoot.kotlinSourceSetName}").dependsOn(getByName("$depSourceSet"))""")
}
}
}
appendln(" }\n}")
appendLine(" }\n}")
}
gradleBuildScript().appendText("\n" + scriptCustomization)
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.util
import java.io.File
@@ -70,7 +75,9 @@ fun normalizePath(path: String): String {
}
private fun normalizeTail(prefixEnd: Int, path: String, separator: Boolean): String {
@Suppress("NAME_SHADOWING")
var separator = separator
val result = StringBuilder(path.length)
result.append(path, 0, prefixEnd)
var start = prefixEnd
@@ -92,4 +99,4 @@ private fun normalizeTail(prefixEnd: Int, path: String, separator: Boolean): Str
}
return result.toString()
}
}
@@ -1,6 +1,12 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.util
import org.jetbrains.kotlin.gradle.BaseGradleIT
import org.jetbrains.kotlin.gradle.SYSTEM_LINE_SEPARATOR
import java.io.File
class ProcessRunResult(
@@ -39,7 +45,7 @@ fun runProcess(
if (options?.forceOutputToStdout ?: false) {
println(it)
}
sb.appendln(it)
sb.append(it).append(SYSTEM_LINE_SEPARATOR)
}
val exitCode = process.waitFor()
@@ -406,8 +406,8 @@ class CInteropCommonizerTaskTest : MultiplatformExtensionTest() {
iosX64.testCinteropIdentifier("iosX64TestHelper")
)
val mainGroup = groups.maxBy { it.targets.size }!!
val testGroup = groups.minBy { it.targets.size }!!
val mainGroup = groups.maxByOrNull { it.targets.size }!!
val testGroup = groups.minByOrNull { it.targets.size }!!
assertEquals(
expectedMainGroup, mainGroup,
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
interface KotlinJsDceOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonToolOptions {
/**
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
internal abstract class KotlinJsDceOptionsBase : org.jetbrains.kotlin.gradle.dsl.KotlinJsDceOptions {
private var allWarningsAsErrorsField: kotlin.Boolean? = null
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
interface KotlinJsOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions {
/**
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
internal abstract class KotlinJsOptionsBase : org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions {
private var allWarningsAsErrorsField: kotlin.Boolean? = null
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions {
/**
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions {
private var allWarningsAsErrorsField: kotlin.Boolean? = null
@@ -2,5 +2,6 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
interface KotlinMultiplatformCommonOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions {
}
@@ -2,6 +2,7 @@
// Generated by org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt
package org.jetbrains.kotlin.gradle.dsl
@Suppress("DEPRECATION")
internal abstract class KotlinMultiplatformCommonOptionsBase : org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformCommonOptions {
private var allWarningsAsErrorsField: kotlin.Boolean? = null
@@ -73,6 +73,7 @@ object ClasspathChangesComputer {
return Success
}
@Suppress("UNUSED_PARAMETER")
private fun collectClassChanges(
current: ClassSnapshot,
previous: ClassSnapshot,
@@ -30,6 +30,7 @@ object ClasspathEntrySnapshotter {
@Suppress("SpellCheckingInspection")
object ClassSnapshotter {
@Suppress("UNUSED_PARAMETER")
fun snapshot(invariantSeparatorsRelativePath: String, classContents: ByteArray): ClassSnapshot {
// TODO WORK-IN-PROGRESS
return ClassSnapshot()
@@ -110,7 +110,10 @@ internal open class KotlinJvmCompilerArgumentsContributor(
private fun warnJdkHomeNotUsed(kotlinOptions: List<KotlinJvmOptionsImpl>) {
kotlinOptions
.firstOrNull { it.jdkHome != null }
.firstOrNull {
@Suppress("DEPRECATION")
it.jdkHome != null
}
?.run {
logger.warn(
"""
@@ -44,7 +44,7 @@ internal class KotlinCompilationsModuleGroups {
val newLeader = singleOrNull { it.isMain() }
?: singleOrNull { it.name.contains("main", true) }
?: singleOrNull { !it.name.contains("test", true) }
?: minBy { it.name }!!
?: minByOrNull { it.name }!!
forEach { moduleLeaderCompilationMap[it] = newLeader }
}
@@ -167,11 +167,11 @@ private abstract class NpmDependencyExtensionDelegate(
return when (val arg = args[0]) {
is String -> withName(
name = arg,
args = *args
args = args
)
is GString -> withName(
name = arg.toString(),
args = *args
args = args
)
else -> processNonStringFirstArgument(arg, *args)
}
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.internal.testing
import org.gradle.api.internal.tasks.testing.*
@@ -9,7 +14,7 @@ class RecordingTestResultProcessor : TestResultProcessor {
fun line(line: String) {
repeat(indent) { output.append(" ") }
output.appendln(line)
output.append(line).append("\n")
}
override fun started(test: TestDescriptorInternal, event: TestStartEvent) {
@@ -37,4 +42,4 @@ class RecordingTestResultProcessor : TestResultProcessor {
indent--
line("COMPLETED ${event.resultType} // $testId")
}
}
}
@@ -311,7 +311,7 @@ class MockKotlinCompilation(
override val compileDependencyConfigurationName: String get() = throw UnsupportedOperationException()
override var compileDependencyFiles: FileCollection
get() = throw UnsupportedOperationException()
set(value) = throw UnsupportedOperationException()
set(_) = throw UnsupportedOperationException()
override val output: KotlinCompilationOutput get() = throw UnsupportedOperationException()
override val compileKotlinTaskName: String get() = throw UnsupportedOperationException()
override val compileKotlinTask: KotlinCompile<KotlinCommonOptions> get() = throw UnsupportedOperationException()
@@ -325,4 +325,4 @@ class MockKotlinCompilation(
//endregion
override fun toString(): String = "compilation '${name}'"
}
}
@@ -20,7 +20,7 @@ class GradleNodeModuleBuilderTest {
)
assertNotNull(packageJson, "package.json should be deserialized")
with(packageJson!!) {
with(packageJson) {
listOf(
dependencies,
devDependencies,
@@ -32,4 +32,4 @@ class GradleNodeModuleBuilderTest {
}
}
}
}
}
@@ -20,7 +20,7 @@ pill {
kotlin.target.compilations.all {
kotlinOptions.languageVersion = "1.4"
kotlinOptions.apiVersion = "1.4"
kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check")
kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check", "-Xsuppress-version-warnings")
}
tasks.named<Jar>("jar") {
@@ -5,21 +5,11 @@
package org.jetbrains.kotlin.tooling
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertTrue
import org.intellij.lang.annotations.Language
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
import kotlin.test.*
class DeserializeStringTest {
@Test
fun `schemaVersion 1 0 0`() {
@Language("JSON") val json = """
@@ -135,4 +125,3 @@ class DeserializeStringTest {
assertNull(commonTarget.extras.native)
}
}