Skip to content

Commit

Permalink
UPDATE_KOTLIN_VERSION: 1.7.0-Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed May 5, 2022
1 parent f4d72cc commit 9cb7b30
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 35 deletions.
8 changes: 2 additions & 6 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ pluginManagement {
props.load(it)
}
}["kotlinBaseVersion"] as String
resolutionStrategy {
eachPlugin {
if (requested.id.id == "org.jetbrains.kotlin.jvm") {
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinBaseVersion")
}
}
plugins {
id("org.jetbrains.kotlin.jvm") version kotlinBaseVersion
}
}
4 changes: 2 additions & 2 deletions compiler-plugin/testData/api/sealedClass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// TEST PROCESSOR: SealedClassProcessor
// EXPECTED:
// Expr : [Const, Sum, NotANumber]
// Expr : [Const, NotANumber, Sum]
// Const : []
// Sum : []
// NotANumber : []
Expand All @@ -27,4 +27,4 @@
sealed class Expr
data class Const(val number: Double) : Expr()
data class Sum(val e1: Expr, val e2: Expr) : Expr()
object NotANumber : Expr()
object NotANumber : Expr()
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.enabledOnCurrentHost
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinNativeCompilationData
import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.Configurator
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.configuration.AbstractKotlinCompileConfig
import org.jetbrains.kotlin.incremental.ChangedFiles
import org.jetbrains.kotlin.incremental.destinationAsFile
import org.jetbrains.kotlin.incremental.isJavaFile
Expand All @@ -73,6 +73,29 @@ 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<AbstractKotlinCompile<*>> {
constructor(compilation: KotlinCompilationData<*>, kotlinCompile: AbstractKotlinCompile<*>) : super(compilation) {
configureTask { task ->
if (task is KspTaskJvm) {
// Assign moduleName different from kotlin compilation to
// work around https://github.com/google/ksp/issues/647
// This will not be necessary once https://youtrack.jetbrains.com/issue/KT-45777 lands
task.moduleName.value(kotlinCompile.moduleName.map { "$it-ksp" })
}
if (task is KspTaskJS) {
val libraryCacheService = project.rootProject.gradle.sharedServices.registerIfAbsent(
"${Kotlin2JsCompile.LibraryFilterCachingService::class.java.canonicalName}" +
"_${Kotlin2JsCompile.LibraryFilterCachingService::class.java.classLoader.hashCode()}",
Kotlin2JsCompile.LibraryFilterCachingService::class.java
) {}
task.libraryCache.set(libraryCacheService).also { task.libraryCache.disallowChanges() }
task.pluginClasspath.setFrom(objectFactory.fileCollection())
}
}
}
}

class KspGradleSubplugin @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
KotlinCompilerPluginSupportPlugin {
companion object {
Expand Down Expand Up @@ -338,7 +361,10 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
}
else -> return project.provider { emptyList() }
}

kotlinCompileTask.safeAs<AbstractKotlinCompile<*>>()?.let {
Configurator(kotlinCompilation as KotlinCompilationData<*>, kotlinCompileTask as AbstractKotlinCompile<*>)
.execute(kspTaskProvider as TaskProvider<AbstractKotlinCompile<*>>)
}
kotlinCompileProvider.configure { kotlinCompile ->
kotlinCompile.dependsOn(kspTaskProvider)
kotlinCompile.setSource(kotlinOutputDir, javaOutputDir)
Expand Down Expand Up @@ -463,10 +489,6 @@ abstract class KspTaskJvm @Inject constructor(
kotlinCompilation: KotlinCompilationData<*>,
kotlinCompile: AbstractKotlinCompile<*>,
) {
Configurator<KspTaskJvm>(kotlinCompilation).configure(this)
// Assign moduleName different from kotlin compilation to work around https://github.com/google/ksp/issues/647
// This will not be necessary once https://youtrack.jetbrains.com/issue/KT-45777 lands
this.moduleName.set(kotlinCompile.moduleName.map { "$it-ksp" })
kotlinCompile as KotlinCompile
val providerFactory = kotlinCompile.project.providers
compileKotlinArgumentsContributor.set(
Expand Down Expand Up @@ -608,7 +630,7 @@ abstract class KspTaskJvm @Inject constructor(
// Overrding an internal function is hacky.
// TODO: Ask upstream to open it.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
fun `callCompilerAsync$kotlin_gradle_plugin`(
fun `callCompilerAsync$kotlin_gradle_plugin_common`(
args: K2JVMCompilerArguments,
kotlinSources: Set<File>,
inputChanges: InputChanges,
Expand Down Expand Up @@ -678,7 +700,6 @@ abstract class KspTaskJS @Inject constructor(
kotlinCompilation: KotlinCompilationData<*>,
kotlinCompile: AbstractKotlinCompile<*>,
) {
Configurator<KspTaskJS>(kotlinCompilation).configure(this)
kotlinCompile as Kotlin2JsCompile
kotlinOptions.freeCompilerArgs = kotlinCompile.kotlinOptions.freeCompilerArgs.filter {
it in backendSelectionArgs
Expand Down Expand Up @@ -728,7 +749,7 @@ abstract class KspTaskJS @Inject constructor(
// Overrding an internal function is hacky.
// TODO: Ask upstream to open it.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
fun `callCompilerAsync$kotlin_gradle_plugin`(
fun `callCompilerAsync$kotlin_gradle_plugin_common`(
args: K2JSCompilerArguments,
kotlinSources: Set<File>,
inputChanges: InputChanges,
Expand All @@ -745,8 +766,9 @@ abstract class KspTaskJS @Inject constructor(

// Overrding an internal function is hacky.
// TODO: Ask upstream to open it.
@Internal
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
fun `isIncrementalCompilationEnabled$kotlin_gradle_plugin`(): Boolean = false
fun `isIncrementalCompilationEnabled$kotlin_gradle_plugin_common`(): Boolean = false

@get:InputFiles
@get:SkipWhenEmpty
Expand All @@ -766,7 +788,6 @@ abstract class KspTaskMetadata @Inject constructor(
kotlinCompilation: KotlinCompilationData<*>,
kotlinCompile: AbstractKotlinCompile<*>,
) {
Configurator<KspTaskMetadata>(kotlinCompilation).configure(this)
kotlinCompile as KotlinCompileCommon
val providerFactory = kotlinCompile.project.providers
compileKotlinArgumentsContributor.set(
Expand Down Expand Up @@ -817,7 +838,7 @@ abstract class KspTaskMetadata @Inject constructor(
// Overrding an internal function is hacky.
// TODO: Ask upstream to open it.
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
fun `callCompilerAsync$kotlin_gradle_plugin`(
fun `callCompilerAsync$kotlin_gradle_plugin_common`(
args: K2MetadataCompilerArguments,
kotlinSources: Set<File>,
inputChanges: InputChanges,
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copied from kotlinc
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx2200m -Dfile.encoding=UTF-8

kotlinBaseVersion=1.7.0-dev-3025
kotlinBaseVersion=1.7.0-Beta
agpBaseVersion=7.0.0
intellijVersion=203.8084.24
junitVersion=4.12
Expand Down
8 changes: 2 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ pluginManagement {
maven("https://www.jetbrains.com/intellij-repository/snapshots")
}
val kotlinBaseVersion: String by settings
resolutionStrategy {
eachPlugin {
if (requested.id.id == "org.jetbrains.kotlin.jvm") {
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinBaseVersion")
}
}
plugins {
id("org.jetbrains.kotlin.jvm") version kotlinBaseVersion
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SealedClassProcessor : AbstractTestProcessor() {
resolver.getNewFiles().forEach { f ->
f.declarations.forEach {
if (it is KSClassDeclaration) {
val subs = it.getSealedSubclasses().map { it.simpleName.asString() }.toList()
val subs = it.getSealedSubclasses().map { it.simpleName.asString() }.toList().sorted()
result.add("${it.simpleName.asString()} : $subs")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,10 @@ import org.jetbrains.kotlin.test.model.FrontendKind
import org.jetbrains.kotlin.test.model.ResultingArtifact
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
import org.jetbrains.kotlin.test.services.JUnit5Assertions
import org.jetbrains.kotlin.test.services.KotlinTestInfo
import org.jetbrains.kotlin.test.services.TemporaryDirectoryManager
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.compilerConfigurationProvider
import org.jetbrains.kotlin.test.services.*
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
import org.jetbrains.kotlin.test.services.isKtFile
import org.jetbrains.kotlin.test.services.javaFiles
import org.jetbrains.kotlin.test.util.KtTestUtil
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions
Expand Down

0 comments on commit 9cb7b30

Please sign in to comment.