AppCode/CLion: patch java plugin xmls in AppCode as well
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.cidr
|
||||
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.bundling.Zip
|
||||
import java.util.regex.Pattern
|
||||
|
||||
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`" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Zip.includePatchedJavaXmls() {
|
||||
val javaPsiXmlPath = "META-INF/JavaPsiPlugin.xml"
|
||||
val javaPluginXmlPath = "META-INF/JavaPlugin.xml"
|
||||
|
||||
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