CIDR: New way of building CLion and AppCode plugins

- Move `prepare/cidr-plugin`, `prepare/clion-plugin` and `prepare/appcode-plugin` modules from `kotlin` to `kotlin-ultimate` project
- Move `versions.clion.*` and `versions.appcode.*` properties from `kotlin` to `kotlin-ultimate` project
- Drop `cidr183` bunch in `kotlin` project
- Drop useless `cidrPluginDir`, `clionPluginDir`, `clionSandboxDir`, `appcodePluginDir`, `appcodeSandboxDir` Gradle properties in `kotlin` project
- Drop `cidrPlugin` Gradle task in `kotlin` project
- Total: Add ability to build `kotlin-ultimate` both as part of multi-project build with `kotlin` project, and as a standalone build
This commit is contained in:
Dmitriy Dolovov
2019-01-09 21:35:45 +07:00
parent d5507734e8
commit 3df5123d0d
11 changed files with 17 additions and 533 deletions
-124
View File
@@ -1,124 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jk1.tcdeps.KotlinScriptDslAdapter.teamcityServer
import com.github.jk1.tcdeps.KotlinScriptDslAdapter.tc
import org.gradle.kotlin.dsl.support.zipTo
import org.jetbrains.kotlin.cidr.includePatchedJavaXmls
import org.jetbrains.kotlin.cidr.applyCidrVersionRestrictions
apply {
plugin("kotlin")
}
plugins {
id("com.github.jk1.tcdeps") version "0.17"
}
repositories {
teamcityServer {
setUrl("http://buildserver.labs.intellij.net")
credentials {
username = "guest"
password = "guest"
}
}
}
val kotlinVersion = rootProject.extra["kotlinVersion"] as String
val cidrPluginDir: File by rootProject.extra
val appcodePluginDir: File by rootProject.extra
val appcodeVersion = rootProject.extra["versions.appcode"] as String
val appcodeVersionStrict = (rootProject.extra["versions.appcode.strict"] as String).toBoolean()
val appcodeVersionRepo = rootProject.extra["versions.appcode.repo"] as String
val cidrPlugin by configurations.creating
val platformDepsZip by configurations.creating
val pluginXmlPath = "META-INF/plugin.xml"
val platformDepsJarName = "kotlinNative-platformDeps.jar"
val pluginXmlLocation = File(buildDir, "pluginXml")
// Do not rename, used in pill importer
val projectsToShadow by extra(listOf(
":kotlin-ultimate:cidr-native",
":kotlin-ultimate:appcode-native"))
dependencies {
cidrPlugin(project(":prepare:cidr-plugin"))
platformDepsZip(tc("$appcodeVersionRepo:$appcodeVersion:OC-plugins/kotlinNative-platformDeps-$appcodeVersion.zip"))
}
val kotlinPluginXml by tasks.creating {
inputs.files(cidrPlugin)
outputs.files(fileFrom(buildDir, name, "META-INF/KotlinPlugin.xml"))
doFirst {
val pluginXmlText = zipTree(inputs.files.singleFile)
.matching { include(pluginXmlPath) }
.singleFile
.readText()
outputs.files.singleFile.writeText(pluginXmlText)
}
}
val preparePluginXml by task<Copy> {
dependsOn(":kotlin-ultimate:appcode-native:assemble")
val cidrPluginVersion = project.findProperty("cidrPluginVersion") as String? ?: "beta-1"
val appcodePluginVersion = "$kotlinVersion-AppCode-$cidrPluginVersion-$appcodeVersion"
inputs.property("appcodePluginVersion", appcodePluginVersion)
outputs.files(pluginXmlLocation)
from(project(":kotlin-ultimate:appcode-native").mainSourceSet.output.resourcesDir) { include(pluginXmlPath) }
into(pluginXmlLocation)
applyCidrVersionRestrictions(appcodeVersion, appcodeVersionStrict, appcodePluginVersion)
}
val jar = runtimeJar {
archiveName = "kotlin-plugin.jar"
dependsOn(cidrPlugin)
dependsOn(preparePluginXml)
from(kotlinPluginXml) { into("META-INF") }
from {
zipTree(cidrPlugin.singleFile).matching {
exclude(pluginXmlPath)
}
}
for (p in projectsToShadow) {
dependsOn("$p:classes")
from(getSourceSetsFrom(p)["main"].output) {
exclude(pluginXmlPath)
}
}
from(pluginXmlLocation) { include(pluginXmlPath) }
}
val platformDepsJar by task<Zip> {
archiveName = platformDepsJarName
val platformDepsJar = zipTree(platformDepsZip.singleFile).matching { include("**/$platformDepsJarName") }.singleFile
from(zipTree(platformDepsJar)) {
exclude(pluginXmlPath)
includePatchedJavaXmls()
}
}
task<Copy>("appcodePlugin") {
into(appcodePluginDir)
from(cidrPluginDir) { exclude("lib/kotlin-plugin.jar") }
into("lib") {
from(jar)
from(platformDepsJar)
from(zipTree(platformDepsZip.singleFile).files) {
exclude("**/$platformDepsJarName")
}
}
into("templates") {
from(File(project(":kotlin-ultimate:appcode-native").projectDir, "templates"))
}
}
-67
View File
@@ -1,67 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import groovy.lang.Closure
import java.io.FilterReader
description = "Kotlin AppCode & CLion plugin"
apply {
plugin("kotlin")
}
val ideaPluginDir: File by rootProject.extra
val cidrPluginDir: File by rootProject.extra
val kotlinPlugin by configurations.creating
val pluginXmlPath = "META-INF/plugin.xml"
dependencies {
kotlinPlugin(project(":prepare:idea-plugin", configuration = "runtimeJar"))
}
val pluginXml by tasks.creating {
inputs.files(kotlinPlugin)
outputs.files(fileFrom(buildDir, name, pluginXmlPath))
doFirst {
val placeholderRegex = Regex(
"""<!-- CIDR-PLUGIN-PLACEHOLDER-START -->(.*)<!-- CIDR-PLUGIN-PLACEHOLDER-END -->""",
RegexOption.DOT_MATCHES_ALL)
val excludeRegex = Regex(
"""<!-- CIDR-PLUGIN-EXCLUDE-START -->(.*?)<!-- CIDR-PLUGIN-EXCLUDE-END -->""",
RegexOption.DOT_MATCHES_ALL)
val ideaVersionRegex = Regex("""<idea-version[^/>]+/>""".trimMargin())
val versionRegex = Regex("""<version>([^<]+)</version>""")
zipTree(inputs.files.singleFile)
.matching { include(pluginXmlPath) }
.singleFile
.readText()
.replace(placeholderRegex, "<depends>com.intellij.modules.cidr.lang</depends>")
.replace(excludeRegex, "")
.replace(ideaVersionRegex, "") // IDEA version to be specified in CLion or AppCode plugin.xml file.
.replace(versionRegex, "") // Version to be specified in CLion or AppCode plugin.xml file.
.also { pluginXmlText ->
outputs.files.singleFile.writeText(pluginXmlText)
}
}
}
val jar = runtimeJar {
archiveName = "kotlin-plugin.jar"
dependsOn(kotlinPlugin)
from {
zipTree(kotlinPlugin.singleFile).matching {
exclude(pluginXmlPath)
}
}
from(pluginXml) { into("META-INF") }
}
task<Copy>("cidrPlugin") {
into(cidrPluginDir)
from(jar) { into("lib") }
}
-119
View File
@@ -1,119 +0,0 @@
import com.github.jk1.tcdeps.KotlinScriptDslAdapter.teamcityServer
import com.github.jk1.tcdeps.KotlinScriptDslAdapter.tc
import org.jetbrains.kotlin.cidr.includePatchedJavaXmls
import org.jetbrains.kotlin.cidr.applyCidrVersionRestrictions
apply {
plugin("kotlin")
}
plugins {
id("com.github.jk1.tcdeps") version "0.17"
}
repositories {
teamcityServer {
setUrl("http://buildserver.labs.intellij.net")
credentials {
username = "guest"
password = "guest"
}
}
}
val kotlinVersion = rootProject.extra["kotlinVersion"] as String
val cidrPluginDir: File by rootProject.extra
val clionPluginDir: File by rootProject.extra
val clionVersion = rootProject.extra["versions.clion"] as String
val clionVersionStrict = (rootProject.extra["versions.clion.strict"] as String).toBoolean()
val clionVersionRepo = rootProject.extra["versions.clion.repo"] as String
val cidrPlugin by configurations.creating
val platformDepsZip by configurations.creating
val pluginXmlPath = "META-INF/plugin.xml"
val platformDepsJarName = "kotlinNative-platformDeps.jar"
val pluginXmlLocation = File(buildDir, "pluginXml")
// Do not rename, used in pill importer
val projectsToShadow by extra(listOf(
":kotlin-ultimate:cidr-native",
":kotlin-ultimate:clion-native"))
dependencies {
cidrPlugin(project(":prepare:cidr-plugin"))
platformDepsZip(tc("$clionVersionRepo:$clionVersion:CL-plugins/kotlinNative-platformDeps-$clionVersion.zip"))
}
val kotlinPluginXml by tasks.creating {
inputs.files(cidrPlugin)
outputs.files(fileFrom(buildDir, name, "META-INF/KotlinPlugin.xml"))
doFirst {
val pluginXmlText = zipTree(inputs.files.singleFile)
.matching { include(pluginXmlPath) }
.singleFile
.readText()
outputs.files.singleFile.writeText(pluginXmlText)
}
}
val preparePluginXml by task<Copy> {
dependsOn(":kotlin-ultimate:clion-native:assemble")
val cidrPluginVersion = project.findProperty("cidrPluginVersion") as String? ?: "beta-1"
val clionPluginVersion = "$kotlinVersion-CLion-$cidrPluginVersion-$clionVersion"
inputs.property("clionPluginVersion", clionPluginVersion)
outputs.files(pluginXmlLocation)
from(project(":kotlin-ultimate:clion-native").mainSourceSet.output.resourcesDir) { include(pluginXmlPath) }
into(pluginXmlLocation)
applyCidrVersionRestrictions(clionVersion, clionVersionStrict, clionPluginVersion)
}
val jar = runtimeJar {
archiveName = "kotlin-plugin.jar"
dependsOn(cidrPlugin)
dependsOn(preparePluginXml)
from(kotlinPluginXml) { into("META-INF") }
from {
zipTree(cidrPlugin.singleFile).matching {
exclude(pluginXmlPath)
}
}
for (p in projectsToShadow) {
dependsOn("$p:classes")
from(getSourceSetsFrom(p)["main"].output) {
exclude(pluginXmlPath)
}
}
from(pluginXmlLocation) { include(pluginXmlPath) }
}
val platformDepsJar by task<Zip> {
archiveName = platformDepsJarName
val platformDepsJar = zipTree(platformDepsZip.singleFile).matching { include("**/$platformDepsJarName") }.singleFile
from(zipTree(platformDepsJar)) {
exclude(pluginXmlPath)
includePatchedJavaXmls()
}
}
task<Copy>("clionPlugin") {
into(clionPluginDir)
from(cidrPluginDir) { exclude("lib/kotlin-plugin.jar") }
from(jar) { into("lib") }
from(platformDepsJar) { into("lib") }
from(zipTree(platformDepsZip.singleFile).files) {
exclude("**/$platformDepsJarName")
into("lib")
}
from(File(project(":kotlin-ultimate:clion-native").projectDir, "templates")) { into("templates") }
}