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.config.*
|
||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
||||
|
||||
abstract class BuildMetaInfo(val converter: RelativeFileToPathConverter?) {
|
||||
abstract class BuildMetaInfo {
|
||||
enum class CustomKeys {
|
||||
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
|
||||
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
|
||||
|
||||
return resultMap
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
package org.jetbrains.kotlin.build
|
||||
|
||||
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.jvm.deserialization.JvmMetadataVersion
|
||||
|
||||
class CommonBuildMetaInfo(converter: RelativeFileToPathConverter?) : BuildMetaInfo(converter) {
|
||||
class CommonBuildMetaInfo : BuildMetaInfo() {
|
||||
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
||||
when (key) {
|
||||
CustomKeys.METADATA_VERSION_STRING.name -> {
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
package org.jetbrains.kotlin.build
|
||||
|
||||
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.utils.JsMetadataVersion
|
||||
|
||||
class JsBuildMetaInfo(converter: RelativeFileToPathConverter?) : BuildMetaInfo(converter) {
|
||||
class JsBuildMetaInfo : BuildMetaInfo() {
|
||||
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
||||
when (key) {
|
||||
CustomKeys.METADATA_VERSION_STRING.name -> {
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
package org.jetbrains.kotlin.build
|
||||
|
||||
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.jvm.deserialization.JvmMetadataVersion
|
||||
|
||||
class JvmBuildMetaInfo(converter: RelativeFileToPathConverter?) : BuildMetaInfo(converter) {
|
||||
class JvmBuildMetaInfo : BuildMetaInfo() {
|
||||
override fun checkIfPlatformSpecificCompilerArgumentWasChanged(key: String, currentValue: String, previousValue: String): Boolean? {
|
||||
when (key) {
|
||||
CustomKeys.METADATA_VERSION_STRING.name -> {
|
||||
|
||||
@@ -5,24 +5,23 @@
|
||||
|
||||
package org.jetbrains.kotlin.build
|
||||
|
||||
import org.jetbrains.kotlin.incremental.storage.RelativeFileToPathConverter
|
||||
import java.io.File
|
||||
import java.security.DigestInputStream
|
||||
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 {
|
||||
fun deserializeWithHashes(str: String): List<Pair<String, String>> =
|
||||
str.split(":")
|
||||
.filter(String::isNotBlank)
|
||||
.map { Pair(File(it.substringBeforeLast("-")).name, it.substringAfterLast("-")) }
|
||||
.map { Pair(it.substringBeforeLast("-"), it.substringAfterLast("-")) }
|
||||
}
|
||||
|
||||
fun serialize() = classpath?.mapNotNull { it ->
|
||||
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()
|
||||
"$jarPath-$jarHash"
|
||||
"$jarName-$jarHash"
|
||||
}?.joinToString(":") ?: ""
|
||||
|
||||
private fun File.sha256(): String {
|
||||
|
||||
Reference in New Issue
Block a user