From c3bdc4345e19d65b6acae55ed2468f6b3275a48b Mon Sep 17 00:00:00 2001 From: Ting-Yuan Huang Date: Sat, 24 Sep 2022 02:10:09 -0700 Subject: [PATCH] Fix lint errors --- gradle-plugin/build.gradle.kts | 3 +- .../ksp/gradle/KotlinCompilerRunnerImpls.kt | 4 +-- .../devtools/ksp/gradle/KspSubplugin.kt | 29 +++++++++---------- .../gradle/tasks/inherited/InheritedTasks.kt | 10 +++---- .../tasks/standalone/StandaloneTasks.kt | 11 ++++--- integration-tests/build.gradle.kts | 3 +- 6 files changed, 28 insertions(+), 32 deletions(-) diff --git a/gradle-plugin/build.gradle.kts b/gradle-plugin/build.gradle.kts index 901e3ce5bf..6322082c61 100644 --- a/gradle-plugin/build.gradle.kts +++ b/gradle-plugin/build.gradle.kts @@ -106,8 +106,7 @@ val writeTestPropsTask = tasks.register("prepareTestConfigurati property("mavenRepoDir", File(rootProject.buildDir, "repos/test").absolutePath) property("kspProjectRootDir", rootProject.projectDir.absolutePath) property("processorClasspath", project.tasks["compileTestKotlin"].outputs.files.asPath) - property("kspCompilerRunner", - project.properties.getOrDefault("ksp.compiler.runner", "inherited") as String) + property("kspCompilerRunner", project.properties.getOrDefault("ksp.compiler.runner", "inherited") as String) } java { diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinCompilerRunnerImpls.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinCompilerRunnerImpls.kt index 15fd00ab2c..e8202e7175 100644 --- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinCompilerRunnerImpls.kt +++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinCompilerRunnerImpls.kt @@ -19,8 +19,6 @@ package com.google.devtools.ksp.gradle -import java.io.File -import javax.inject.Inject import org.gradle.api.Task import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Property @@ -47,6 +45,8 @@ import org.jetbrains.kotlin.gradle.tasks.GradleCompileTaskProvider import org.jetbrains.kotlin.gradle.utils.newInstance import org.jetbrains.kotlin.gradle.utils.propertyWithNewInstance import org.jetbrains.kotlin.konan.target.KonanTarget +import java.io.File +import javax.inject.Inject internal inline fun ObjectFactory.property() = property(T::class.java) internal inline fun ObjectFactory.property(initialValue: T) = property().value(initialValue) diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt index 7f3585bfa3..f15acb4f90 100644 --- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt +++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt @@ -24,10 +24,24 @@ import org.gradle.api.Task import org.gradle.api.UnknownTaskException import org.gradle.api.artifacts.Configuration import org.gradle.api.attributes.Attribute +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.FileCollection +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property import org.gradle.api.provider.Provider +import org.gradle.api.tasks.Classpath +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.LocalState +import org.gradle.api.tasks.Nested +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.TaskProvider import org.gradle.api.tasks.compile.JavaCompile import org.gradle.language.jvm.tasks.ProcessResources +import org.gradle.process.CommandLineArgumentProvider import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.gradle.plugin.FilesSubpluginOption @@ -44,20 +58,6 @@ import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompileTool import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.io.File import javax.inject.Inject -import org.gradle.api.file.ConfigurableFileCollection -import org.gradle.api.file.DirectoryProperty -import org.gradle.api.file.FileCollection -import org.gradle.api.provider.ListProperty -import org.gradle.api.provider.MapProperty -import org.gradle.api.provider.Property -import org.gradle.api.tasks.Classpath -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.LocalState -import org.gradle.api.tasks.Nested -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputDirectory -import org.gradle.process.CommandLineArgumentProvider class KspGradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) : KotlinCompilerPluginSupportPlugin { @@ -323,4 +323,3 @@ interface KspTask : Task { @get:Input var isKspIncremental: Boolean } - diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/tasks/inherited/InheritedTasks.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/tasks/inherited/InheritedTasks.kt index ec627d6a28..6eaeef6c3d 100644 --- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/tasks/inherited/InheritedTasks.kt +++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/tasks/inherited/InheritedTasks.kt @@ -25,11 +25,6 @@ import com.google.devtools.ksp.gradle.KspGradleSubplugin.Companion.KSP_ARTIFACT_ import com.google.devtools.ksp.gradle.KspGradleSubplugin.Companion.getKspCachesDir import com.google.devtools.ksp.gradle.KspTask import com.google.devtools.ksp.gradle.tasks.KspTaskCreator -import java.io.File -import java.nio.file.Paths -import java.util.concurrent.Callable -import javax.inject.Inject -import kotlin.reflect.KProperty1 import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.artifacts.Configuration @@ -95,6 +90,11 @@ import org.jetbrains.kotlin.incremental.isJavaFile import org.jetbrains.kotlin.incremental.isKotlinFile import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty import org.jetbrains.kotlin.utils.addToStdlib.safeAs +import java.io.File +import java.nio.file.Paths +import java.util.concurrent.Callable +import javax.inject.Inject +import kotlin.reflect.KProperty1 @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE") internal class Configurator : AbstractKotlinCompileConfig> { diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/tasks/standalone/StandaloneTasks.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/tasks/standalone/StandaloneTasks.kt index fb8acb2048..d7158f4431 100644 --- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/tasks/standalone/StandaloneTasks.kt +++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/tasks/standalone/StandaloneTasks.kt @@ -31,10 +31,6 @@ import com.google.devtools.ksp.gradle.createKotlinJvmCompilerRunner import com.google.devtools.ksp.gradle.createKotlinMetadataCompilerRunner import com.google.devtools.ksp.gradle.createKotlinNativeCompilerRunner import com.google.devtools.ksp.gradle.tasks.KspTaskCreator -import java.io.File -import java.nio.file.Paths -import javax.inject.Inject -import kotlin.reflect.KProperty1 import org.gradle.api.DefaultTask import org.gradle.api.Project import org.gradle.api.Task @@ -83,7 +79,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinNativeCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinCommonCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.enabledOnCurrentHost -import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData import org.jetbrains.kotlin.gradle.plugin.pluginConfigurationName import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompileTool @@ -102,6 +97,10 @@ import org.jetbrains.kotlin.library.impl.isKotlinLibrary import org.jetbrains.kotlin.utils.JsLibraryUtils import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty import org.jetbrains.kotlin.utils.addToStdlib.safeAs +import java.io.File +import java.nio.file.Paths +import javax.inject.Inject +import kotlin.reflect.KProperty1 object StandaloneTasks : KspTaskCreator { override fun createKspTask( @@ -594,7 +593,7 @@ abstract class KspTaskJs @Inject constructor( commonSources, ) - private fun isJsLib(file: File) : Boolean = + private fun isJsLib(file: File): Boolean = file.exists() && when (backend.get()) { JS_BACKEND.JS_IR -> isKotlinLibrary(file) JS_BACKEND.JS_LEGACY -> JsLibraryUtils.isKotlinJavascriptLibrary(file) diff --git a/integration-tests/build.gradle.kts b/integration-tests/build.gradle.kts index be77327289..2fb58572a8 100644 --- a/integration-tests/build.gradle.kts +++ b/integration-tests/build.gradle.kts @@ -17,8 +17,7 @@ tasks.named("test") { systemProperty("kspVersion", version) systemProperty("agpVersion", agpBaseVersion) systemProperty("testRepo", File(rootProject.buildDir, "repos/test").absolutePath) - systemProperty("kspCompilerRunner", - project.properties.getOrDefault("ksp.compiler.runner", "inherited") as String) + systemProperty("kspCompilerRunner", project.properties.getOrDefault("ksp.compiler.runner", "inherited") as String) dependsOn(":api:publishAllPublicationsToTestRepository") dependsOn(":gradle-plugin:publishAllPublicationsToTestRepository") dependsOn(":symbol-processing:publishAllPublicationsToTestRepository")