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
|
package org.jetbrains.kotlin.cidr
|
||||||
|
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.tasks.Copy
|
||||||
import org.gradle.api.tasks.bundling.Zip
|
import org.gradle.api.tasks.bundling.Zip
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
@@ -48,3 +48,33 @@ fun Zip.includePatchedJavaXmls() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 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
|
import org.jetbrains.kotlin.cidr.includePatchedJavaXmls
|
||||||
|
import org.jetbrains.kotlin.cidr.applyCidrVersionRestrictions
|
||||||
|
|
||||||
apply {
|
apply {
|
||||||
plugin("kotlin")
|
plugin("kotlin")
|
||||||
@@ -22,16 +23,21 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val kotlinVersion = rootProject.extra["kotlinVersion"] as String
|
||||||
|
|
||||||
val cidrPluginDir: File by rootProject.extra
|
val cidrPluginDir: File by rootProject.extra
|
||||||
val appcodePluginDir: File by rootProject.extra
|
val appcodePluginDir: File by rootProject.extra
|
||||||
val appcodeVersion = rootProject.extra["versions.appcode"] as String
|
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 appcodeVersionRepo = rootProject.extra["versions.appcode.repo"] as String
|
||||||
|
|
||||||
val cidrPlugin by configurations.creating
|
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 platformDepsJarName = "kotlinNative-platformDeps.jar"
|
val platformDepsJarName = "kotlinNative-platformDeps.jar"
|
||||||
|
val pluginXmlLocation = File(buildDir, "pluginXml")
|
||||||
|
|
||||||
// Do not rename, used in JPS importer
|
// Do not rename, used in JPS importer
|
||||||
val projectsToShadow by extra(listOf(
|
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 {
|
val jar = runtimeJar {
|
||||||
archiveName = "kotlin-plugin.jar"
|
archiveName = "kotlin-plugin.jar"
|
||||||
dependsOn(cidrPlugin)
|
dependsOn(cidrPlugin)
|
||||||
|
dependsOn(preparePluginXml)
|
||||||
from(kotlinPluginXml) { into("META-INF") }
|
from(kotlinPluginXml) { into("META-INF") }
|
||||||
|
|
||||||
from {
|
from {
|
||||||
@@ -70,8 +92,11 @@ val jar = runtimeJar {
|
|||||||
|
|
||||||
for (p in projectsToShadow) {
|
for (p in projectsToShadow) {
|
||||||
dependsOn("$p:classes")
|
dependsOn("$p:classes")
|
||||||
from(getSourceSetsFrom(p)["main"].output)
|
from(getSourceSetsFrom(p)["main"].output) {
|
||||||
|
exclude(pluginXmlPath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
from(pluginXmlLocation) { include(pluginXmlPath) }
|
||||||
}
|
}
|
||||||
|
|
||||||
val platformDepsJar by task<Zip> {
|
val platformDepsJar by task<Zip> {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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.jetbrains.kotlin.cidr.includePatchedJavaXmls
|
import org.jetbrains.kotlin.cidr.includePatchedJavaXmls
|
||||||
|
import org.jetbrains.kotlin.cidr.applyCidrVersionRestrictions
|
||||||
|
|
||||||
apply {
|
apply {
|
||||||
plugin("kotlin")
|
plugin("kotlin")
|
||||||
@@ -25,6 +26,7 @@ val kotlinVersion = rootProject.extra["kotlinVersion"] as String
|
|||||||
val cidrPluginDir: File by rootProject.extra
|
val cidrPluginDir: File by rootProject.extra
|
||||||
val clionPluginDir: File by rootProject.extra
|
val clionPluginDir: File by rootProject.extra
|
||||||
val clionVersion = rootProject.extra["versions.clion"] as String
|
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 clionVersionRepo = rootProject.extra["versions.clion.repo"] as String
|
||||||
|
|
||||||
val cidrPlugin by configurations.creating
|
val cidrPlugin by configurations.creating
|
||||||
@@ -66,21 +68,12 @@ val preparePluginXml by task<Copy> {
|
|||||||
val clionPluginVersion = "$kotlinVersion-CLion-$cidrPluginVersion-$clionVersion"
|
val clionPluginVersion = "$kotlinVersion-CLion-$cidrPluginVersion-$clionVersion"
|
||||||
|
|
||||||
inputs.property("clionPluginVersion", clionPluginVersion)
|
inputs.property("clionPluginVersion", clionPluginVersion)
|
||||||
|
outputs.files(pluginXmlLocation)
|
||||||
|
|
||||||
from(project(":kotlin-ultimate:clion-native").mainSourceSet.output.resourcesDir) { include(pluginXmlPath) }
|
from(project(":kotlin-ultimate:clion-native").mainSourceSet.output.resourcesDir) { include(pluginXmlPath) }
|
||||||
into(pluginXmlLocation)
|
into(pluginXmlLocation)
|
||||||
|
|
||||||
val sinceBuild =
|
applyCidrVersionRestrictions(clionVersion, clionVersionStrict, clionPluginVersion)
|
||||||
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>")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val jar = runtimeJar {
|
val jar = runtimeJar {
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ versions.androidBuildTools=r23.0.1
|
|||||||
versions.idea.NodeJS=181.3494.12
|
versions.idea.NodeJS=181.3494.12
|
||||||
# TODO: select appropriate 183 base build for AppCode
|
# TODO: select appropriate 183 base build for AppCode
|
||||||
versions.appcode=191.1411
|
versions.appcode=191.1411
|
||||||
|
versions.appcode.strict=true
|
||||||
versions.appcode.repo=ijplatform_master_CIDR_AppCode_Installers
|
versions.appcode.repo=ijplatform_master_CIDR_AppCode_Installers
|
||||||
versions.clion=183.4886.39
|
versions.clion=183.4886.39
|
||||||
|
versions.clion.strict=false
|
||||||
versions.clion.repo=ijplatform_IjPlatform183_Cidr_CLion_PublicInstallers
|
versions.clion.repo=ijplatform_IjPlatform183_Cidr_CLion_PublicInstallers
|
||||||
versions.jar.guava=25.1-jre
|
versions.jar.guava=25.1-jre
|
||||||
versions.jar.groovy-all=2.4.15
|
versions.jar.groovy-all=2.4.15
|
||||||
|
|||||||
Reference in New Issue
Block a user