CLion: Patch some xml's of Java plugin to make it work more stable
To get rid of exceptions while startup and indexing
This commit is contained in:
committed by
Dmitriy Dolovov
parent
2b3b5876aa
commit
8ed63d1c18
@@ -1,6 +1,6 @@
|
|||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
|
||||||
import com.github.jk1.tcdeps.KotlinScriptDslAdapter.teamcityServer
|
import com.github.jk1.tcdeps.KotlinScriptDslAdapter.teamcityServer
|
||||||
import com.github.jk1.tcdeps.KotlinScriptDslAdapter.tc
|
import com.github.jk1.tcdeps.KotlinScriptDslAdapter.tc
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
apply {
|
apply {
|
||||||
plugin("kotlin")
|
plugin("kotlin")
|
||||||
@@ -29,6 +29,9 @@ val cidrPlugin by configurations.creating
|
|||||||
val platformDepsZip by configurations.creating
|
val platformDepsZip by configurations.creating
|
||||||
|
|
||||||
val pluginXmlPath = "META-INF/plugin.xml"
|
val pluginXmlPath = "META-INF/plugin.xml"
|
||||||
|
val javaPsiXmlPath = "META-INF/JavaPsiPlugin.xml"
|
||||||
|
val javaPluginXmlPath = "META-INF/JavaPlugin.xml"
|
||||||
|
|
||||||
val platformDepsJarName = "kotlinNative-platformDeps.jar"
|
val platformDepsJarName = "kotlinNative-platformDeps.jar"
|
||||||
val pluginXmlLocation = File(buildDir, "pluginXml")
|
val pluginXmlLocation = File(buildDir, "pluginXml")
|
||||||
|
|
||||||
@@ -93,11 +96,46 @@ val jar = runtimeJar {
|
|||||||
from(pluginXmlLocation) { include(pluginXmlPath) }
|
from(pluginXmlLocation) { include(pluginXmlPath) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Zip.includePatched(fileToMarkers: Map<String, List<String>>) {
|
||||||
|
|
||||||
|
val notDone = mutableSetOf<Pair<String, String>>()
|
||||||
|
fileToMarkers.forEach { (path, markers) ->
|
||||||
|
for (marker in markers) {
|
||||||
|
notDone += path to marker
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eachFile {
|
||||||
|
val markers = fileToMarkers[this.sourcePath] ?: return@eachFile
|
||||||
|
this.filter {
|
||||||
|
var data = it
|
||||||
|
for (marker in markers) {
|
||||||
|
val newData = data.replace(("^(.*" + Pattern.quote(marker) + ".*)$").toRegex(), "<!-- $1 -->")
|
||||||
|
data = newData
|
||||||
|
notDone -= path to marker
|
||||||
|
}
|
||||||
|
data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
doLast {
|
||||||
|
check(notDone.size == 0) {
|
||||||
|
"Filtering failed for: " +
|
||||||
|
notDone.joinToString(separator = "\n") { (file, marker) -> "file=$file, marker=`$marker`" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val platformDepsJar by task<Zip> {
|
val platformDepsJar by task<Zip> {
|
||||||
archiveName = platformDepsJarName
|
archiveName = platformDepsJarName
|
||||||
val platformDepsJar = zipTree(platformDepsZip.singleFile).matching { include("**/$platformDepsJarName") }.singleFile
|
val platformDepsJar = zipTree(platformDepsZip.singleFile).matching { include("**/$platformDepsJarName") }.singleFile
|
||||||
from(zipTree(platformDepsJar)) {
|
from(zipTree(platformDepsJar)) {
|
||||||
exclude(pluginXmlPath)
|
exclude(pluginXmlPath)
|
||||||
|
includePatched(
|
||||||
|
mapOf(
|
||||||
|
javaPsiXmlPath to listOf("implementation=\"org.jetbrains.uast.java.JavaUastLanguagePlugin\""),
|
||||||
|
javaPluginXmlPath to listOf("implementation=\"com.intellij.spi.SPIFileTypeFactory\"")
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user