diff --git a/buildSrc/src/main/kotlin/cidr/cidrTasks.kt b/buildSrc/src/main/kotlin/cidr/cidrTasks.kt index f803584ca5c..57147ce35c8 100644 --- a/buildSrc/src/main/kotlin/cidr/cidrTasks.kt +++ b/buildSrc/src/main/kotlin/cidr/cidrTasks.kt @@ -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\"") ) ) -} \ No newline at end of file +} + +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("", + "") + .replace("", + "$pluginVersion") + } +} diff --git a/prepare/appcode-plugin/build.gradle.kts b/prepare/appcode-plugin/build.gradle.kts index 50c0637db94..b34b44d12e1 100644 --- a/prepare/appcode-plugin/build.gradle.kts +++ b/prepare/appcode-plugin/build.gradle.kts @@ -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 { + 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 { diff --git a/prepare/clion-plugin/build.gradle.kts b/prepare/clion-plugin/build.gradle.kts index 7e6fb9e51fb..5cf3f37cd94 100644 --- a/prepare/clion-plugin/build.gradle.kts +++ b/prepare/clion-plugin/build.gradle.kts @@ -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 { 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("", - "") - .replace("", - "$clionPluginVersion") - } + applyCidrVersionRestrictions(clionVersion, clionVersionStrict, clionPluginVersion) } val jar = runtimeJar { diff --git a/versions.properties.cidr183 b/versions.properties.cidr183 index 55c6fa23f2c..85c013b7f69 100644 --- a/versions.properties.cidr183 +++ b/versions.properties.cidr183 @@ -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