CIDR: Ability to relax upper limit of product version in K/N plugin
Issue #KT-29006:fixed
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cidr
|
||||
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.bundling.Zip
|
||||
import java.util.regex.Pattern
|
||||
|
||||
@@ -47,4 +47,34 @@ fun Zip.includePatchedJavaXmls() {
|
||||
javaPluginXmlPath to listOf("implementation=\"com.intellij.spi.SPIFileTypeFactory\"")
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun Copy.applyCidrVersionRestrictions(
|
||||
productVersion: String,
|
||||
strictProductVersionLimitation: Boolean,
|
||||
pluginVersion: String
|
||||
) {
|
||||
val dotsCount = productVersion.count { it == '.' }
|
||||
check(dotsCount >= 1 && dotsCount <= 2) {
|
||||
"Wrong CIDR product version format: $productVersion"
|
||||
}
|
||||
|
||||
val sinceBuild = if (dotsCount == 1)
|
||||
productVersion
|
||||
else
|
||||
productVersion.substringBeforeLast('.')
|
||||
|
||||
val untilBuild = if (strictProductVersionLimitation)
|
||||
// if strict then restrict plugin to the same single version of CLion or AppCode
|
||||
sinceBuild + ".*"
|
||||
else
|
||||
productVersion.substringBefore('.') + ".*"
|
||||
|
||||
filter {
|
||||
it
|
||||
.replace("<!--idea_version_placeholder-->",
|
||||
"<idea-version since-build=\"$sinceBuild\" until-build=\"$untilBuild\"/>")
|
||||
.replace("<!--version_placeholder-->",
|
||||
"<version>$pluginVersion</version>")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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")
|
||||
@@ -22,16 +23,21 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
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 Boolean
|
||||
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 JPS importer
|
||||
val projectsToShadow by extra(listOf(
|
||||
@@ -57,9 +63,25 @@ val kotlinPluginXml by tasks.creating {
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -70,8 +92,11 @@ val jar = runtimeJar {
|
||||
|
||||
for (p in projectsToShadow) {
|
||||
dependsOn("$p:classes")
|
||||
from(getSourceSetsFrom(p)["main"].output)
|
||||
from(getSourceSetsFrom(p)["main"].output) {
|
||||
exclude(pluginXmlPath)
|
||||
}
|
||||
}
|
||||
from(pluginXmlLocation) { include(pluginXmlPath) }
|
||||
}
|
||||
|
||||
val platformDepsJar by task<Zip> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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")
|
||||
@@ -25,6 +26,7 @@ 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 Boolean
|
||||
val clionVersionRepo = rootProject.extra["versions.clion.repo"] as String
|
||||
|
||||
val cidrPlugin by configurations.creating
|
||||
@@ -66,21 +68,12 @@ val preparePluginXml by task<Copy> {
|
||||
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)
|
||||
|
||||
val sinceBuild =
|
||||
if (clionVersion.matches(Regex("\\d+\\.\\d+"))) clionVersion else clionVersion.substring(0, clionVersion.lastIndexOf('.'))
|
||||
val untilBuild = clionVersion.substring(0, clionVersion.lastIndexOf('.')) + ".*"
|
||||
|
||||
filter {
|
||||
it
|
||||
.replace("<!--idea_version_placeholder-->",
|
||||
"<idea-version since-build=\"$sinceBuild\" until-build=\"$untilBuild\"/>")
|
||||
.replace("<!--version_placeholder-->",
|
||||
"<version>$clionPluginVersion</version>")
|
||||
}
|
||||
applyCidrVersionRestrictions(clionVersion, clionVersionStrict, clionPluginVersion)
|
||||
}
|
||||
|
||||
val jar = runtimeJar {
|
||||
|
||||
@@ -3,8 +3,10 @@ versions.androidBuildTools=r23.0.1
|
||||
versions.idea.NodeJS=181.3494.12
|
||||
# TODO: select appropriate 183 base build for AppCode
|
||||
versions.appcode=191.1411
|
||||
versions.appcode.strict=true
|
||||
versions.appcode.repo=ijplatform_master_CIDR_AppCode_Installers
|
||||
versions.clion=183.4886.39
|
||||
versions.clion.strict=false
|
||||
versions.clion.repo=ijplatform_IjPlatform183_Cidr_CLion_PublicInstallers
|
||||
versions.jar.guava=25.1-jre
|
||||
versions.jar.groovy-all=2.4.15
|
||||
|
||||
Reference in New Issue
Block a user