From bfb314adcbe46f720581ae6fa6b67c9237fb55e6 Mon Sep 17 00:00:00 2001 From: "Alexander.Likhachev" Date: Fri, 2 Jun 2023 19:35:03 +0200 Subject: [PATCH] [BT] Mark the Build Tools API as experimental --- .../api/kotlin-build-tools-api.api | 3 +++ .../kotlin/buildtools/api/CompilationService.kt | 2 ++ .../api/CompilerExecutionStrategyConfiguration.kt | 1 + .../kotlin/buildtools/api/ExperimentalBuildToolsApi.kt | 9 +++++++++ .../kotlin/buildtools/api/SharedApiClassesClassLoader.kt | 1 + .../jetbrains/kotlin/buildtools/api/SourcesChanges.kt | 1 + .../kotlin/buildtools/api/jvm/ClasspathEntrySnapshot.kt | 3 +++ .../buildtools/api/jvm/JvmCompilationConfiguration.kt | 6 ++++++ .../build-tools/kotlin-build-tools-impl/build.gradle.kts | 8 +++++++- .../compilerRunner/btapi/BuildToolsApiCompilationWork.kt | 3 +++ 10 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/ExperimentalBuildToolsApi.kt diff --git a/compiler/build-tools/kotlin-build-tools-api/api/kotlin-build-tools-api.api b/compiler/build-tools/kotlin-build-tools-api/api/kotlin-build-tools-api.api index 4abc73abcb5..f5c4ccbbaf3 100644 --- a/compiler/build-tools/kotlin-build-tools-api/api/kotlin-build-tools-api.api +++ b/compiler/build-tools/kotlin-build-tools-api/api/kotlin-build-tools-api.api @@ -16,6 +16,9 @@ public abstract interface class org/jetbrains/kotlin/buildtools/api/CompilerExec public abstract fun useInProcessStrategy ()Lorg/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration; } +public abstract interface annotation class org/jetbrains/kotlin/buildtools/api/ExperimentalBuildToolsApi : java/lang/annotation/Annotation { +} + public abstract interface class org/jetbrains/kotlin/buildtools/api/KotlinLogger { public abstract fun debug (Ljava/lang/String;)V public abstract fun error (Ljava/lang/String;Ljava/lang/Throwable;)V diff --git a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/CompilationService.kt b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/CompilationService.kt index fff42737669..0b87b01dc9e 100644 --- a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/CompilationService.kt +++ b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/CompilationService.kt @@ -22,6 +22,7 @@ import java.io.File * * This interface is not intended to be implemented by the API consumers. An instance of [CompilationService] is expected to be obtained from [loadImplementation]. */ +@ExperimentalBuildToolsApi public interface CompilationService { /** * TODO KT-57565 @@ -54,6 +55,7 @@ public interface CompilationService { arguments: List ) + @ExperimentalBuildToolsApi public companion object { @JvmStatic public fun loadImplementation(classLoader: ClassLoader): CompilationService = diff --git a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration.kt b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration.kt index e4da82ae0fd..5d6eb6bd246 100644 --- a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration.kt +++ b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration.kt @@ -12,6 +12,7 @@ import java.io.File * * This interface is not intended to be implemented by the API consumers. */ +@ExperimentalBuildToolsApi public interface CompilerExecutionStrategyConfiguration { /** * Marks the compilation to be run inside the same JVM as the caller. diff --git a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/ExperimentalBuildToolsApi.kt b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/ExperimentalBuildToolsApi.kt new file mode 100644 index 00000000000..a6278f401c8 --- /dev/null +++ b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/ExperimentalBuildToolsApi.kt @@ -0,0 +1,9 @@ +/* + * Copyright 2010-2023 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.buildtools.api + +@RequiresOptIn("This part of the Build Tools API is experimental and might change in the future releases") +public annotation class ExperimentalBuildToolsApi diff --git a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/SharedApiClassesClassLoader.kt b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/SharedApiClassesClassLoader.kt index c2c2850fef9..15798576a6d 100644 --- a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/SharedApiClassesClassLoader.kt +++ b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/SharedApiClassesClassLoader.kt @@ -14,6 +14,7 @@ import kotlin.reflect.KClass * This way an API implementation can be loaded with almost fully isolated classpath, sharing only the classes from `org.jetbrains.kotlin.buildtools.api`, * so a caller still able to pass API parameters in a compatible way. */ +@ExperimentalBuildToolsApi @Suppress("FunctionName") @JvmName("newInstance") public fun SharedApiClassesClassLoader(): ClassLoader = SharedApiClassesClassLoaderImpl( diff --git a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/SourcesChanges.kt b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/SourcesChanges.kt index 63a40878197..34ccc7a5b7d 100644 --- a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/SourcesChanges.kt +++ b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/SourcesChanges.kt @@ -10,6 +10,7 @@ import java.io.File /** * A hierarchy representing source files changes for incremental compilation */ +@ExperimentalBuildToolsApi public sealed interface SourcesChanges { /** * A marker object stating that the API consumer cannot calculate changes (either because it's an initial build or for some other reason). diff --git a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/jvm/ClasspathEntrySnapshot.kt b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/jvm/ClasspathEntrySnapshot.kt index f62d3b4a1cb..14a3d73529b 100644 --- a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/jvm/ClasspathEntrySnapshot.kt +++ b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/jvm/ClasspathEntrySnapshot.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.buildtools.api.jvm +import org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi import java.io.File /** @@ -12,6 +13,7 @@ import java.io.File * * This interface is not intended to be implemented by the API consumers. */ +@ExperimentalBuildToolsApi public interface ClasspathEntrySnapshot { public val classSnapshots: LinkedHashMap @@ -23,6 +25,7 @@ public interface ClasspathEntrySnapshot { * * This interface is not intended to be implemented by the API consumers. */ +@ExperimentalBuildToolsApi public interface ClassSnapshot { // ... TODO: KT-57565, it will expose some part of org.jetbrains.kotlin.incremental.classpathDiff.ClassSnapshot hierarchy } \ No newline at end of file diff --git a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration.kt b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration.kt index 4ce005bca16..903c29f5082 100644 --- a/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration.kt +++ b/compiler/build-tools/kotlin-build-tools-api/src/main/kotlin/org/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.buildtools.api.jvm +import org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi import org.jetbrains.kotlin.buildtools.api.KotlinLogger import org.jetbrains.kotlin.buildtools.api.SourcesChanges import java.io.File @@ -17,6 +18,7 @@ import java.io.File * * This interface is not intended to be implemented by the API consumers. */ +@ExperimentalBuildToolsApi public interface JvmCompilationConfiguration { /** * A logger used during the compilation. @@ -74,6 +76,7 @@ public interface JvmCompilationConfiguration { * * This interface is not intended to be implemented by the API consumers. */ +@ExperimentalBuildToolsApi public interface IncrementalJvmCompilationConfiguration

{ /** * A directory used as a base path for computing relative paths in the incremental compilation caches. @@ -151,6 +154,7 @@ public interface IncrementalJvmCompilationConfiguration

{ /** @@ -181,11 +185,13 @@ public interface ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration : /** * Mandatory parameters for an incremental compilation approach */ +@ExperimentalBuildToolsApi public sealed interface IncrementalCompilationApproachParameters /** * Mandatory parameters of the classpath snapshots based incremental compilation approach */ +@ExperimentalBuildToolsApi public class ClasspathSnapshotBasedIncrementalCompilationApproachParameters( /** * The classpath snapshots files actual at the moment of compilation diff --git a/compiler/build-tools/kotlin-build-tools-impl/build.gradle.kts b/compiler/build-tools/kotlin-build-tools-impl/build.gradle.kts index 8323766d643..a5d87c7c92e 100644 --- a/compiler/build-tools/kotlin-build-tools-impl/build.gradle.kts +++ b/compiler/build-tools/kotlin-build-tools-impl/build.gradle.kts @@ -10,4 +10,10 @@ dependencies { publish() -standardPublicJars() \ No newline at end of file +standardPublicJars() + +kotlin { + compilerOptions { + optIn.add("org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi") + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/btapi/BuildToolsApiCompilationWork.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/btapi/BuildToolsApiCompilationWork.kt index d2d48c4eec2..96f3339b617 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/btapi/BuildToolsApiCompilationWork.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/btapi/BuildToolsApiCompilationWork.kt @@ -12,12 +12,14 @@ import org.gradle.workers.WorkAction import org.gradle.workers.WorkParameters import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter import org.jetbrains.kotlin.buildtools.api.CompilationService +import org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi import org.jetbrains.kotlin.buildtools.api.SharedApiClassesClassLoader import org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWorkArguments import org.jetbrains.kotlin.gradle.internal.ClassLoadersCachingBuildService import org.jetbrains.kotlin.gradle.internal.ParentClassLoaderProvider import java.io.File +@OptIn(ExperimentalBuildToolsApi::class) internal abstract class BuildToolsApiCompilationWork : WorkAction { internal interface BuildToolsApiCompilationParameters : WorkParameters { val classLoadersCachingService: Property @@ -48,6 +50,7 @@ internal abstract class BuildToolsApiCompilationWork : WorkAction