Make plugin classpath serialization path agnostic
This is needed for correct usage of portable caches ^KT-63799 Fixed
This commit is contained in:
committed by
Space Team
parent
ea85b30f88
commit
c002af6365
@@ -7,9 +7,8 @@ package org.jetbrains.kotlin.build
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.*
|
||||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
|
||||||
|
|
||||||
abstract class BuildMetaInfo(val converter: RelativeFileToPathConverter?) {
|
abstract class BuildMetaInfo {
|
||||||
enum class CustomKeys {
|
enum class CustomKeys {
|
||||||
LANGUAGE_VERSION_STRING, IS_EAP, METADATA_VERSION_STRING, PLUGIN_CLASSPATHS, API_VERSION_STRING
|
LANGUAGE_VERSION_STRING, IS_EAP, METADATA_VERSION_STRING, PLUGIN_CLASSPATHS, API_VERSION_STRING
|
||||||
}
|
}
|
||||||
@@ -78,7 +77,7 @@ abstract class BuildMetaInfo(val converter: RelativeFileToPathConverter?) {
|
|||||||
val apiVersionString = args.apiVersion ?: languageVersionSting
|
val apiVersionString = args.apiVersion ?: languageVersionSting
|
||||||
resultMap[CustomKeys.API_VERSION_STRING.name] = apiVersionString
|
resultMap[CustomKeys.API_VERSION_STRING.name] = apiVersionString
|
||||||
|
|
||||||
val pluginClasspath = PluginClasspath(args.pluginClasspaths, converter).serialize()
|
val pluginClasspath = PluginClasspath(args.pluginClasspaths).serialize()
|
||||||
resultMap[CustomKeys.PLUGIN_CLASSPATHS.name] = pluginClasspath
|
resultMap[CustomKeys.PLUGIN_CLASSPATHS.name] = pluginClasspath
|
||||||
|
|
||||||
return resultMap
|
return resultMap
|
||||||
|
|||||||
@@ -6,11 +6,10 @@
|
|||||||
package org.jetbrains.kotlin.build
|
package org.jetbrains.kotlin.build
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
|
||||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||||
|
|
||||||
class CommonBuildMetaInfo(converter: RelativeFileToPathConverter?) : BuildMetaInfo(converter) {
|
class CommonBuildMetaInfo : BuildMetaInfo() {
|
||||||
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
||||||
when (key) {
|
when (key) {
|
||||||
CustomKeys.METADATA_VERSION_STRING.name -> {
|
CustomKeys.METADATA_VERSION_STRING.name -> {
|
||||||
|
|||||||
@@ -6,11 +6,10 @@
|
|||||||
package org.jetbrains.kotlin.build
|
package org.jetbrains.kotlin.build
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
|
||||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||||
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
||||||
|
|
||||||
class JsBuildMetaInfo(converter: RelativeFileToPathConverter?) : BuildMetaInfo(converter) {
|
class JsBuildMetaInfo : BuildMetaInfo() {
|
||||||
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
||||||
when (key) {
|
when (key) {
|
||||||
CustomKeys.METADATA_VERSION_STRING.name -> {
|
CustomKeys.METADATA_VERSION_STRING.name -> {
|
||||||
|
|||||||
@@ -17,11 +17,10 @@
|
|||||||
package org.jetbrains.kotlin.build
|
package org.jetbrains.kotlin.build
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
|
||||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||||
|
|
||||||
class JvmBuildMetaInfo(converter: RelativeFileToPathConverter?) : BuildMetaInfo(converter) {
|
class JvmBuildMetaInfo : BuildMetaInfo() {
|
||||||
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
||||||
when (key) {
|
when (key) {
|
||||||
CustomKeys.METADATA_VERSION_STRING.name -> {
|
CustomKeys.METADATA_VERSION_STRING.name -> {
|
||||||
|
|||||||
@@ -5,24 +5,23 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.build
|
package org.jetbrains.kotlin.build
|
||||||
|
|
||||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.DigestInputStream
|
import java.security.DigestInputStream
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
|
||||||
internal class PluginClasspath(private val classpath: Array<String>?, val converter: RelativeFileToPathConverter?) {
|
internal class PluginClasspath(private val classpath: Array<String>?) {
|
||||||
companion object {
|
companion object {
|
||||||
fun deserializeWithHashes(str: String): List<Pair<String, String>> =
|
fun deserializeWithHashes(str: String): List<Pair<String, String>> =
|
||||||
str.split(":")
|
str.split(":")
|
||||||
.filter(String::isNotBlank)
|
.filter(String::isNotBlank)
|
||||||
.map { Pair(File(it.substringBeforeLast("-")).name, it.substringAfterLast("-")) }
|
.map { Pair(it.substringBeforeLast("-"), it.substringAfterLast("-")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun serialize() = classpath?.mapNotNull { it ->
|
fun serialize() = classpath?.mapNotNull { it ->
|
||||||
val jar = File(it).takeIf { it.exists() } ?: return@mapNotNull null
|
val jar = File(it).takeIf { it.exists() } ?: return@mapNotNull null
|
||||||
val jarPath = converter?.toPath(jar) ?: jar.absolutePath
|
val jarName = jar.name
|
||||||
val jarHash = jar.sha256()
|
val jarHash = jar.sha256()
|
||||||
"$jarPath-$jarHash"
|
"$jarName-$jarHash"
|
||||||
}?.joinToString(":") ?: ""
|
}?.joinToString(":") ?: ""
|
||||||
|
|
||||||
private fun File.sha256(): String {
|
private fun File.sha256(): String {
|
||||||
|
|||||||
+2
-1
@@ -119,7 +119,8 @@ abstract class RelocatableCacheTestCase(
|
|||||||
val facet = KotlinFacetSettings()
|
val facet = KotlinFacetSettings()
|
||||||
facet.useProjectSettings = false
|
facet.useProjectSettings = false
|
||||||
facet.compilerArguments = K2JVMCompilerArguments().apply {
|
facet.compilerArguments = K2JVMCompilerArguments().apply {
|
||||||
pluginClasspaths = arrayOf(module1Lib.absolutePath)
|
// Add both libraries inside and outside project
|
||||||
|
pluginClasspaths = arrayOf(module1Lib.absolutePath, libraryJar.absolutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
it.container.setChild(
|
it.container.setChild(
|
||||||
|
|||||||
+1
-2
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinCompileContext
|
import org.jetbrains.kotlin.jps.build.KotlinCompileContext
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
||||||
import org.jetbrains.kotlin.jps.build.ModuleBuildTarget
|
import org.jetbrains.kotlin.jps.build.ModuleBuildTarget
|
||||||
@@ -40,7 +39,7 @@ class KotlinCommonModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModu
|
|||||||
get() = COMMON_BUILD_META_INFO_FILE_NAME
|
get() = COMMON_BUILD_META_INFO_FILE_NAME
|
||||||
|
|
||||||
override val buildMetaInfo: CommonBuildMetaInfo
|
override val buildMetaInfo: CommonBuildMetaInfo
|
||||||
get() = CommonBuildMetaInfo(kotlinContext.fileToPathConverter as? RelativeFileToPathConverter)
|
get() = CommonBuildMetaInfo()
|
||||||
|
|
||||||
override val globalLookupCacheId: String
|
override val globalLookupCacheId: String
|
||||||
get() = "metadata-compiler"
|
get() = "metadata-compiler"
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
|||||||
import org.jetbrains.kotlin.incremental.js.IncrementalDataProviderFromCache
|
import org.jetbrains.kotlin.incremental.js.IncrementalDataProviderFromCache
|
||||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
||||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
|
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
|
||||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinCompileContext
|
import org.jetbrains.kotlin.jps.build.KotlinCompileContext
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
||||||
import org.jetbrains.kotlin.jps.build.ModuleBuildTarget
|
import org.jetbrains.kotlin.jps.build.ModuleBuildTarget
|
||||||
@@ -57,7 +56,7 @@ class KotlinJsModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleBu
|
|||||||
get() = JS_BUILD_META_INFO_FILE_NAME
|
get() = JS_BUILD_META_INFO_FILE_NAME
|
||||||
|
|
||||||
override val buildMetaInfo: JsBuildMetaInfo
|
override val buildMetaInfo: JsBuildMetaInfo
|
||||||
get() = JsBuildMetaInfo(kotlinContext.fileToPathConverter as? RelativeFileToPathConverter)
|
get() = JsBuildMetaInfo()
|
||||||
|
|
||||||
val isFirstBuild: Boolean
|
val isFirstBuild: Boolean
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.config.IncrementalCompilation
|
|||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
import org.jetbrains.kotlin.incremental.*
|
import org.jetbrains.kotlin.incremental.*
|
||||||
import org.jetbrains.kotlin.incremental.components.*
|
import org.jetbrains.kotlin.incremental.components.*
|
||||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinCompileContext
|
import org.jetbrains.kotlin.jps.build.KotlinCompileContext
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
import org.jetbrains.kotlin.jps.build.KotlinDirtySourceFilesHolder
|
||||||
@@ -66,7 +65,7 @@ class KotlinJvmModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleB
|
|||||||
get() = JVM_BUILD_META_INFO_FILE_NAME
|
get() = JVM_BUILD_META_INFO_FILE_NAME
|
||||||
|
|
||||||
override val buildMetaInfo: JvmBuildMetaInfo
|
override val buildMetaInfo: JvmBuildMetaInfo
|
||||||
get() = JvmBuildMetaInfo(kotlinContext.fileToPathConverter as? RelativeFileToPathConverter)
|
get() = JvmBuildMetaInfo()
|
||||||
|
|
||||||
override val targetId: TargetId
|
override val targetId: TargetId
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
Reference in New Issue
Block a user