[BT] Introduce the project build uuid
This allows to perform some cleanups after the entire project build finished. #KT-57398 In Progress
This commit is contained in:
committed by
Space Team
parent
28c059f25b
commit
175c00e5c7
@@ -10,7 +10,8 @@ public final class org/jetbrains/kotlin/buildtools/api/CompilationResult : java/
|
||||
public abstract interface class org/jetbrains/kotlin/buildtools/api/CompilationService {
|
||||
public static final field Companion Lorg/jetbrains/kotlin/buildtools/api/CompilationService$Companion;
|
||||
public abstract fun calculateClasspathSnapshot (Ljava/io/File;)Lorg/jetbrains/kotlin/buildtools/api/jvm/ClasspathEntrySnapshot;
|
||||
public abstract fun compileJvm (Lorg/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration;Lorg/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
|
||||
public abstract fun compileJvm (Lorg/jetbrains/kotlin/buildtools/api/ProjectId;Lorg/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration;Lorg/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
|
||||
public abstract fun finishProjectCompilation (Lorg/jetbrains/kotlin/buildtools/api/ProjectId;)V
|
||||
public static fun loadImplementation (Ljava/lang/ClassLoader;)Lorg/jetbrains/kotlin/buildtools/api/CompilationService;
|
||||
public abstract fun makeCompilerExecutionStrategyConfiguration ()Lorg/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration;
|
||||
public abstract fun makeJvmCompilationConfiguration ()Lorg/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration;
|
||||
@@ -46,6 +47,20 @@ public abstract interface class org/jetbrains/kotlin/buildtools/api/KotlinLogger
|
||||
public abstract fun warn (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/buildtools/api/ProjectId {
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/buildtools/api/ProjectId$ProjectUUID : org/jetbrains/kotlin/buildtools/api/ProjectId {
|
||||
public fun <init> (Ljava/util/UUID;)V
|
||||
public final fun component1 ()Ljava/util/UUID;
|
||||
public final fun copy (Ljava/util/UUID;)Lorg/jetbrains/kotlin/buildtools/api/ProjectId$ProjectUUID;
|
||||
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/buildtools/api/ProjectId$ProjectUUID;Ljava/util/UUID;ILjava/lang/Object;)Lorg/jetbrains/kotlin/buildtools/api/ProjectId$ProjectUUID;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getUuid ()Ljava/util/UUID;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/buildtools/api/SharedApiClassesClassLoader {
|
||||
public static final fun newInstance ()Ljava/lang/ClassLoader;
|
||||
}
|
||||
|
||||
+14
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.buildtools.api
|
||||
import org.jetbrains.kotlin.buildtools.api.jvm.ClasspathEntrySnapshot
|
||||
import org.jetbrains.kotlin.buildtools.api.jvm.JvmCompilationConfiguration
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* A facade for invoking compilation and related stuff (such as [calculateClasspathSnapshot]) in Kotlin compiler.
|
||||
@@ -43,18 +44,31 @@ public interface CompilationService {
|
||||
|
||||
/**
|
||||
* Compiles Kotlin code targeting JVM platform and using specified options.
|
||||
*
|
||||
* The [finishProjectCompilation] must be called with the same [projectId] after the entire project is compiled.
|
||||
* @param projectId The unique identifier of the project to be compiled. It may be the same for different modules of the project.
|
||||
* @param strategyConfig an instance of [CompilerExecutionStrategyConfiguration] initially obtained from [makeCompilerExecutionStrategyConfiguration]
|
||||
* @param compilationConfig an instance of [JvmCompilationConfiguration] initially obtained from [makeJvmCompilationConfiguration]
|
||||
* @param sources a list of all sources of the compilation unit
|
||||
* @param arguments a list of Kotlin JVM compiler arguments
|
||||
*/
|
||||
public fun compileJvm(
|
||||
projectId: ProjectId,
|
||||
strategyConfig: CompilerExecutionStrategyConfiguration,
|
||||
compilationConfig: JvmCompilationConfiguration,
|
||||
sources: List<File>,
|
||||
arguments: List<String>
|
||||
): CompilationResult
|
||||
|
||||
/**
|
||||
* A finalization function that must be called when all the modules of the project are compiled.
|
||||
*
|
||||
* May perform cache clean-ups and resource freeing.
|
||||
*
|
||||
* @param projectId The unique identifier of the compiled project.
|
||||
*/
|
||||
public fun finishProjectCompilation(projectId: ProjectId)
|
||||
|
||||
@ExperimentalBuildToolsApi
|
||||
public companion object {
|
||||
@JvmStatic
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Represents a unique identifier for a specific project. In this context, a "project" refers to the top-level entity
|
||||
* or the main project itself, rather than a project's module. It's important to note that in certain build systems,
|
||||
* like Gradle, the term "project" may be used to refer to individual modules. However, in this interface, we are
|
||||
* explicitly using it to represent a complete project rather than its sub-modules.
|
||||
*/
|
||||
public sealed interface ProjectId {
|
||||
public data class ProjectUUID(public val uuid: UUID) : ProjectId
|
||||
}
|
||||
+10
-6
@@ -5,10 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.buildtools.internal
|
||||
|
||||
import org.jetbrains.kotlin.buildtools.api.CompilationResult
|
||||
import org.jetbrains.kotlin.buildtools.api.CompilationService
|
||||
import org.jetbrains.kotlin.buildtools.api.CompilerArgumentsParseException
|
||||
import org.jetbrains.kotlin.buildtools.api.CompilerExecutionStrategyConfiguration
|
||||
import org.jetbrains.kotlin.buildtools.api.*
|
||||
import org.jetbrains.kotlin.buildtools.api.jvm.*
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||
@@ -27,7 +24,7 @@ private val ExitCode.asCompilationResult
|
||||
else -> error("Unexpected exit code: $this")
|
||||
}
|
||||
|
||||
internal class CompilationServiceImpl : CompilationService {
|
||||
internal object CompilationServiceImpl : CompilationService {
|
||||
override fun calculateClasspathSnapshot(classpathEntry: File): ClasspathEntrySnapshot {
|
||||
TODO("Calculating classpath snapshots via the Build Tools API is not yet implemented: KT-57565")
|
||||
}
|
||||
@@ -37,6 +34,7 @@ internal class CompilationServiceImpl : CompilationService {
|
||||
override fun makeJvmCompilationConfiguration() = JvmCompilationConfigurationImpl()
|
||||
|
||||
override fun compileJvm(
|
||||
projectId: ProjectId,
|
||||
strategyConfig: CompilerExecutionStrategyConfiguration,
|
||||
compilationConfig: JvmCompilationConfiguration,
|
||||
sources: List<File>,
|
||||
@@ -55,6 +53,10 @@ internal class CompilationServiceImpl : CompilationService {
|
||||
}
|
||||
}
|
||||
|
||||
override fun finishProjectCompilation(projectId: ProjectId) {
|
||||
|
||||
}
|
||||
|
||||
private fun compileInProcess(
|
||||
loggerAdapter: KotlinLoggerMessageCollectorAdapter,
|
||||
sources: List<File>,
|
||||
@@ -70,4 +72,6 @@ internal class CompilationServiceImpl : CompilationService {
|
||||
loggerAdapter.report(CompilerMessageSeverity.INFO, arguments.toString())
|
||||
return compiler.exec(loggerAdapter, Services.EMPTY, parsedArguments).asCompilationResult
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class CompilationServiceProxy : CompilationService by CompilationServiceImpl
|
||||
+1
-1
@@ -1 +1 @@
|
||||
org.jetbrains.kotlin.buildtools.internal.CompilationServiceImpl
|
||||
org.jetbrains.kotlin.buildtools.internal.CompilationServiceProxy
|
||||
Reference in New Issue
Block a user