[Build] Fix configuration cache issues (part 3)
* Make IntelliJInstrumentCodeTask compatible with configuration cache * Make CoreXmlShadingTransformer compatible with configuration cache * Make :kotlin-reflect:relocateCoreSources compatible with configuration cache * Copy some properties to not capture it's owning object into lambda to support configuration cache Relates to #KT-44611
This commit is contained in:
@@ -50,25 +50,34 @@ class CoreXmlShadingTransformer : Transformer {
|
||||
private const val XML_NAME = "META-INF/extensions/core.xml"
|
||||
}
|
||||
|
||||
private val content = StringBuilder()
|
||||
@kotlin.jvm.Transient
|
||||
private var content: StringBuilder? = StringBuilder()
|
||||
|
||||
private fun ensureStringBuilderExist() {
|
||||
if (content == null) {
|
||||
content = StringBuilder()
|
||||
}
|
||||
}
|
||||
|
||||
override fun canTransformResource(element: FileTreeElement): Boolean {
|
||||
return (element.name == XML_NAME)
|
||||
}
|
||||
|
||||
override fun transform(context: TransformerContext) {
|
||||
ensureStringBuilderExist()
|
||||
val text = context.`is`.bufferedReader().lines()
|
||||
.map { it.replace("com.intellij.psi", "org.jetbrains.kotlin.com.intellij.psi") }
|
||||
.collect(Collectors.joining("\n"))
|
||||
content.appendln(text)
|
||||
content!!.appendln(text)
|
||||
context.`is`.close()
|
||||
}
|
||||
|
||||
override fun hasTransformedResource(): Boolean {
|
||||
return content.isNotEmpty()
|
||||
return content?.isNotEmpty() ?: false
|
||||
}
|
||||
|
||||
override fun modifyOutputStream(outputStream: ZipOutputStream, preserveFileTimestamps: Boolean) {
|
||||
if (content == null) return
|
||||
val entry = ZipEntry(XML_NAME)
|
||||
outputStream.putNextEntry(entry)
|
||||
outputStream.write(content.toString().toByteArray())
|
||||
|
||||
Reference in New Issue
Block a user