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\"")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ 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 org.gradle.kotlin.dsl.support.zipTo
|
import org.gradle.kotlin.dsl.support.zipTo
|
||||||
|
import org.jetbrains.kotlin.cidr.includePatchedJavaXmls
|
||||||
|
|
||||||
apply {
|
apply {
|
||||||
plugin("kotlin")
|
plugin("kotlin")
|
||||||
@@ -78,6 +79,7 @@ val platformDepsJar by task<Zip> {
|
|||||||
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)
|
||||||
|
includePatchedJavaXmls()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
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
|
import org.jetbrains.kotlin.cidr.includePatchedJavaXmls
|
||||||
|
|
||||||
apply {
|
apply {
|
||||||
plugin("kotlin")
|
plugin("kotlin")
|
||||||
@@ -31,8 +31,6 @@ 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")
|
||||||
@@ -106,46 +104,12 @@ 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(
|
includePatchedJavaXmls()
|
||||||
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