Make it possible to attach platforms with different versions to kotlin repo
This commit is contained in:
@@ -18,6 +18,7 @@ plugins {
|
|||||||
val intellijUltimateEnabled: Boolean by rootProject.extra
|
val intellijUltimateEnabled: Boolean by rootProject.extra
|
||||||
val intellijReleaseType: String by rootProject.extra
|
val intellijReleaseType: String by rootProject.extra
|
||||||
val intellijVersion = rootProject.extra["versions.intellijSdk"] as String
|
val intellijVersion = rootProject.extra["versions.intellijSdk"] as String
|
||||||
|
val intellijVersionForIde = rootProject.intellijSdkVersionForIde()
|
||||||
val asmVersion = rootProject.findProperty("versions.jar.asm-all") as String?
|
val asmVersion = rootProject.findProperty("versions.jar.asm-all") as String?
|
||||||
val androidStudioRelease = rootProject.findProperty("versions.androidStudioRelease") as String?
|
val androidStudioRelease = rootProject.findProperty("versions.androidStudioRelease") as String?
|
||||||
val androidStudioBuild = rootProject.findProperty("versions.androidStudioBuild") as String?
|
val androidStudioBuild = rootProject.findProperty("versions.androidStudioBuild") as String?
|
||||||
@@ -25,13 +26,18 @@ val intellijSeparateSdks: Boolean by rootProject.extra
|
|||||||
val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks
|
val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks
|
||||||
val installIntellijUltimate = intellijUltimateEnabled && androidStudioRelease == null
|
val installIntellijUltimate = intellijUltimateEnabled && androidStudioRelease == null
|
||||||
|
|
||||||
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
|
fun checkIntellijVersion(intellijVersion: String) {
|
||||||
if (intellijVersionDelimiterIndex == -1) {
|
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
|
||||||
error("Invalid IDEA version $intellijVersion")
|
if (intellijVersionDelimiterIndex == -1) {
|
||||||
|
error("Invalid IDEA version $intellijVersion")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
checkIntellijVersion(intellijVersion)
|
||||||
|
intellijVersionForIde?.let { checkIntellijVersion(it) }
|
||||||
|
|
||||||
logger.info("intellijUltimateEnabled: $intellijUltimateEnabled")
|
logger.info("intellijUltimateEnabled: $intellijUltimateEnabled")
|
||||||
logger.info("intellijVersion: $intellijVersion")
|
logger.info("intellijVersion: $intellijVersion")
|
||||||
|
logger.info("intellijVersionForIde: $intellijVersionForIde")
|
||||||
logger.info("androidStudioRelease: $androidStudioRelease")
|
logger.info("androidStudioRelease: $androidStudioRelease")
|
||||||
logger.info("androidStudioBuild: $androidStudioBuild")
|
logger.info("androidStudioBuild: $androidStudioBuild")
|
||||||
logger.info("intellijSeparateSdks: $intellijSeparateSdks")
|
logger.info("intellijSeparateSdks: $intellijSeparateSdks")
|
||||||
@@ -71,11 +77,16 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val intellij by configurations.creating
|
val intellij by configurations.creating
|
||||||
|
val intellijForIde by configurations.creating
|
||||||
val intellijUltimate by configurations.creating
|
val intellijUltimate by configurations.creating
|
||||||
|
val intellijUltimateForIde by configurations.creating
|
||||||
val androidStudio by configurations.creating
|
val androidStudio by configurations.creating
|
||||||
val sources by configurations.creating
|
val sources by configurations.creating
|
||||||
|
val sourcesForIde by configurations.creating
|
||||||
val jpsStandalone by configurations.creating
|
val jpsStandalone by configurations.creating
|
||||||
|
val jpsStandaloneForIde by configurations.creating
|
||||||
val intellijCore by configurations.creating
|
val intellijCore by configurations.creating
|
||||||
|
val intellijCoreForIde by configurations.creating
|
||||||
val nodeJSPlugin by configurations.creating
|
val nodeJSPlugin by configurations.creating
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,9 +115,11 @@ dependencies {
|
|||||||
} else {
|
} else {
|
||||||
if (installIntellijCommunity) {
|
if (installIntellijCommunity) {
|
||||||
intellij("com.jetbrains.intellij.idea:ideaIC:$intellijVersion")
|
intellij("com.jetbrains.intellij.idea:ideaIC:$intellijVersion")
|
||||||
|
intellijVersionForIde?.let { intellijForIde("com.jetbrains.intellij.idea:ideaIC:$it") }
|
||||||
}
|
}
|
||||||
if (installIntellijUltimate) {
|
if (installIntellijUltimate) {
|
||||||
intellijUltimate("com.jetbrains.intellij.idea:ideaIU:$intellijVersion")
|
intellijUltimate("com.jetbrains.intellij.idea:ideaIU:$intellijVersion")
|
||||||
|
intellijVersionForIde.let { intellijUltimateForIde("com.jetbrains.intellij.idea:ideaIU:$it") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,102 +128,111 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sources("com.jetbrains.intellij.idea:ideaIC:$intellijVersion:sources@jar")
|
sources("com.jetbrains.intellij.idea:ideaIC:$intellijVersion:sources@jar")
|
||||||
|
intellijVersionForIde?.let { sourcesForIde("com.jetbrains.intellij.idea:ideaIC:$it:sources@jar") }
|
||||||
jpsStandalone("com.jetbrains.intellij.idea:jps-standalone:$intellijVersion")
|
jpsStandalone("com.jetbrains.intellij.idea:jps-standalone:$intellijVersion")
|
||||||
|
intellijVersionForIde?.let { jpsStandaloneForIde("com.jetbrains.intellij.idea:jps-standalone:$it") }
|
||||||
intellijCore("com.jetbrains.intellij.idea:intellij-core:$intellijVersion")
|
intellijCore("com.jetbrains.intellij.idea:intellij-core:$intellijVersion")
|
||||||
|
intellijVersionForIde?.let { intellijCoreForIde("com.jetbrains.intellij.idea:intellij-core:$it") }
|
||||||
if (intellijUltimateEnabled) {
|
if (intellijUltimateEnabled) {
|
||||||
nodeJSPlugin("com.jetbrains.plugins:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}@zip")
|
nodeJSPlugin("com.jetbrains.plugins:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}@zip")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
|
fun prepareDeps(intellij: Configuration, intellijCore: Configuration, sources: Configuration, intellijUltimate: Configuration, jpsStandalone: Configuration, intellijVersion: String) {
|
||||||
|
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
|
||||||
|
|
||||||
val makeIntellijAnnotations by tasks.registering(Copy::class) {
|
val makeIntellijAnnotations = tasks.register("makeIntellijAnnotations${intellij.name.capitalize()}", Copy::class) {
|
||||||
dependsOn(makeIntellijCore)
|
dependsOn(makeIntellijCore)
|
||||||
|
|
||||||
val intellijCoreRepo = CleanableStore[repoDir.resolve("intellij-core").absolutePath][intellijVersion].use()
|
val intellijCoreRepo = CleanableStore[repoDir.resolve("intellij-core").absolutePath][intellijVersion].use()
|
||||||
from(intellijCoreRepo.resolve("artifacts/annotations.jar"))
|
from(intellijCoreRepo.resolve("artifacts/annotations.jar"))
|
||||||
|
|
||||||
val annotationsStore = CleanableStore[repoDir.resolve(intellijRuntimeAnnotations).absolutePath]
|
val annotationsStore = CleanableStore[repoDir.resolve(intellijRuntimeAnnotations).absolutePath]
|
||||||
val targetDir = annotationsStore[intellijVersion].use()
|
val targetDir = annotationsStore[intellijVersion].use()
|
||||||
into(targetDir)
|
into(targetDir)
|
||||||
|
|
||||||
val ivyFile = File(targetDir, "$intellijRuntimeAnnotations.ivy.xml")
|
val ivyFile = File(targetDir, "$intellijRuntimeAnnotations.ivy.xml")
|
||||||
outputs.files(ivyFile)
|
outputs.files(ivyFile)
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
annotationsStore.cleanStore()
|
annotationsStore.cleanStore()
|
||||||
|
}
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
writeIvyXml(
|
||||||
|
customDepsOrg,
|
||||||
|
intellijRuntimeAnnotations,
|
||||||
|
intellijVersion,
|
||||||
|
intellijRuntimeAnnotations,
|
||||||
|
targetDir,
|
||||||
|
targetDir,
|
||||||
|
targetDir,
|
||||||
|
allowAnnotations = true
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doLast {
|
val mergeSources = tasks.create("mergeSources${intellij.name.capitalize()}", Jar::class.java) {
|
||||||
writeIvyXml(
|
dependsOn(sources)
|
||||||
|
isPreserveFileTimestamps = false
|
||||||
|
isReproducibleFileOrder = true
|
||||||
|
isZip64 = true
|
||||||
|
if (!kotlinBuildProperties.isTeamcityBuild) {
|
||||||
|
from(provider { sources.map(::zipTree) })
|
||||||
|
}
|
||||||
|
destinationDirectory.set(File(repoDir, sources.name))
|
||||||
|
archiveBaseName.set("intellij")
|
||||||
|
archiveClassifier.set("sources")
|
||||||
|
archiveVersion.set(intellijVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
val sourcesFile = mergeSources.outputs.files.singleFile
|
||||||
|
|
||||||
|
val makeIde = if (androidStudioBuild != null) {
|
||||||
|
buildIvyRepositoryTask(
|
||||||
|
androidStudio,
|
||||||
customDepsOrg,
|
customDepsOrg,
|
||||||
intellijRuntimeAnnotations,
|
customDepsRepoDir,
|
||||||
intellijVersion,
|
if (androidStudioOs == "mac")
|
||||||
intellijRuntimeAnnotations,
|
::skipContentsDirectory
|
||||||
targetDir,
|
else
|
||||||
targetDir,
|
::skipToplevelDirectory
|
||||||
targetDir,
|
)
|
||||||
allowAnnotations = true
|
} else {
|
||||||
|
val task = if (installIntellijUltimate) {
|
||||||
|
buildIvyRepositoryTask(intellijUltimate, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||||
|
} else {
|
||||||
|
buildIvyRepositoryTask(intellij, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
task.configure {
|
||||||
|
dependsOn(mergeSources)
|
||||||
|
}
|
||||||
|
|
||||||
|
task
|
||||||
|
}
|
||||||
|
|
||||||
|
val buildJpsStandalone = buildIvyRepositoryTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||||
|
|
||||||
|
tasks.named("build") {
|
||||||
|
dependsOn(
|
||||||
|
makeIntellijCore,
|
||||||
|
makeIde,
|
||||||
|
buildJpsStandalone,
|
||||||
|
makeIntellijAnnotations
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val mergeSources by tasks.creating(Jar::class.java) {
|
if (installIntellijUltimate) {
|
||||||
dependsOn(sources)
|
val buildNodeJsPlugin =
|
||||||
isPreserveFileTimestamps = false
|
buildIvyRepositoryTask(nodeJSPlugin, customDepsOrg, customDepsRepoDir, ::skipToplevelDirectory, sourcesFile)
|
||||||
isReproducibleFileOrder = true
|
tasks.named("build") { dependsOn(buildNodeJsPlugin) }
|
||||||
isZip64 = true
|
|
||||||
if (!kotlinBuildProperties.isTeamcityBuild) {
|
|
||||||
from(provider { sources.map(::zipTree) })
|
|
||||||
}
|
}
|
||||||
destinationDirectory.set(File(repoDir, sources.name))
|
|
||||||
archiveBaseName.set("intellij")
|
|
||||||
archiveClassifier.set("sources")
|
|
||||||
archiveVersion.set(intellijVersion)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourcesFile = mergeSources.outputs.files.singleFile
|
prepareDeps(intellij, intellijCore, sources, intellijUltimate, jpsStandalone, intellijVersion)
|
||||||
|
if (intellijVersionForIde != null) {
|
||||||
val makeIde = if (androidStudioBuild != null) {
|
prepareDeps(intellijForIde, intellijCoreForIde, sourcesForIde, intellijUltimateForIde, jpsStandaloneForIde, intellijVersionForIde)
|
||||||
buildIvyRepositoryTask(
|
|
||||||
androidStudio,
|
|
||||||
customDepsOrg,
|
|
||||||
customDepsRepoDir,
|
|
||||||
if (androidStudioOs == "mac")
|
|
||||||
::skipContentsDirectory
|
|
||||||
else
|
|
||||||
::skipToplevelDirectory
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
val task = if (installIntellijUltimate) {
|
|
||||||
buildIvyRepositoryTask(intellijUltimate, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
|
||||||
} else {
|
|
||||||
buildIvyRepositoryTask(intellij, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
task.configure {
|
|
||||||
dependsOn(mergeSources)
|
|
||||||
}
|
|
||||||
|
|
||||||
task
|
|
||||||
}
|
|
||||||
|
|
||||||
val buildJpsStandalone = buildIvyRepositoryTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
|
||||||
|
|
||||||
tasks.named("build") {
|
|
||||||
dependsOn(
|
|
||||||
makeIntellijCore,
|
|
||||||
makeIde,
|
|
||||||
buildJpsStandalone,
|
|
||||||
makeIntellijAnnotations
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installIntellijUltimate) {
|
|
||||||
val buildNodeJsPlugin =
|
|
||||||
buildIvyRepositoryTask(nodeJSPlugin, customDepsOrg, customDepsRepoDir, ::skipToplevelDirectory, sourcesFile)
|
|
||||||
tasks.named("build") { dependsOn(buildNodeJsPlugin) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<Delete>("clean") {
|
tasks.named<Delete>("clean") {
|
||||||
@@ -397,6 +419,11 @@ fun skipToplevelDirectory(path: String) = path.substringAfter('/')
|
|||||||
|
|
||||||
fun skipContentsDirectory(path: String) = path.substringAfter("Contents/")
|
fun skipContentsDirectory(path: String) = path.substringAfter("Contents/")
|
||||||
|
|
||||||
|
fun Project.intellijSdkVersionForIde(): String? {
|
||||||
|
val majorVersion = kotlinBuildProperties.getOrNull("attachedIntellijVersion") as? String ?: return null
|
||||||
|
return rootProject.findProperty("versions.intellijSdk.forIde.$majorVersion") as? String
|
||||||
|
}
|
||||||
|
|
||||||
class XMLWriter(private val outputStreamWriter: OutputStreamWriter) : Closeable {
|
class XMLWriter(private val outputStreamWriter: OutputStreamWriter) : Closeable {
|
||||||
|
|
||||||
private val xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(outputStreamWriter)
|
private val xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(outputStreamWriter)
|
||||||
|
|||||||
@@ -42,9 +42,21 @@ private fun Project.ideModuleName() = when (IdeVersionConfigurator.currentIde.ki
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Project.ideModuleVersion() = when (IdeVersionConfigurator.currentIde.kind) {
|
private fun Project.ideModuleVersion(forIde: Boolean) = when (IdeVersionConfigurator.currentIde.kind) {
|
||||||
Ide.Kind.AndroidStudio -> rootProject.findProperty("versions.androidStudioBuild")
|
Ide.Kind.AndroidStudio -> rootProject.findProperty("versions.androidStudioBuild")
|
||||||
Ide.Kind.IntelliJ -> rootProject.findProperty("versions.intellijSdk")
|
Ide.Kind.IntelliJ -> {
|
||||||
|
if (forIde) {
|
||||||
|
intellijSdkVersionForIde()
|
||||||
|
?: error("Please specify 'attachedIntellijVersion' in your local.properties")
|
||||||
|
} else {
|
||||||
|
rootProject.findProperty("versions.intellijSdk")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.intellijSdkVersionForIde(): String? {
|
||||||
|
val majorVersion = kotlinBuildProperties.getOrNull("attachedIntellijVersion") as? String ?: return null
|
||||||
|
return rootProject.findProperty("versions.intellijSdk.forIde.$majorVersion") as? String
|
||||||
}
|
}
|
||||||
|
|
||||||
fun RepositoryHandler.kotlinBuildLocalRepo(project: Project): IvyArtifactRepository = ivy {
|
fun RepositoryHandler.kotlinBuildLocalRepo(project: Project): IvyArtifactRepository = ivy {
|
||||||
@@ -69,7 +81,8 @@ fun RepositoryHandler.kotlinBuildLocalRepo(project: Project): IvyArtifactReposit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.intellijDep(module: String? = null) = "kotlin.build:${module ?: ideModuleName()}:${ideModuleVersion()}"
|
fun Project.intellijDep(module: String? = null, forIde: Boolean = false) =
|
||||||
|
"kotlin.build:${module ?: ideModuleName()}:${ideModuleVersion(forIde)}"
|
||||||
|
|
||||||
fun Project.intellijCoreDep() = "kotlin.build:intellij-core:${rootProject.extra["versions.intellijSdk"]}"
|
fun Project.intellijCoreDep() = "kotlin.build:intellij-core:${rootProject.extra["versions.intellijSdk"]}"
|
||||||
|
|
||||||
@@ -94,7 +107,7 @@ fun Project.kotlinxCollectionsImmutable() = "org.jetbrains.kotlinx:kotlinx-colle
|
|||||||
*/
|
*/
|
||||||
fun Project.intellijRuntimeAnnotations() = "kotlin.build:intellij-runtime-annotations:${rootProject.extra["versions.intellijSdk"]}"
|
fun Project.intellijRuntimeAnnotations() = "kotlin.build:intellij-runtime-annotations:${rootProject.extra["versions.intellijSdk"]}"
|
||||||
|
|
||||||
fun Project.intellijPluginDep(plugin: String) = intellijDep(plugin)
|
fun Project.intellijPluginDep(plugin: String, forIde: Boolean = false) = intellijDep(plugin, forIde)
|
||||||
|
|
||||||
fun Project.intellijUltimateDep() = intellijDep("ideaIU")
|
fun Project.intellijUltimateDep() = intellijDep("ideaIU")
|
||||||
|
|
||||||
@@ -126,7 +139,7 @@ object IntellijRootUtils {
|
|||||||
fun getIntellijRootDir(project: Project): File = with(project.rootProject) {
|
fun getIntellijRootDir(project: Project): File = with(project.rootProject) {
|
||||||
return File(
|
return File(
|
||||||
getRepositoryRootDir(this),
|
getRepositoryRootDir(this),
|
||||||
"${ideModuleName()}/${ideModuleVersion()}/artifacts"
|
"${ideModuleName()}/${ideModuleVersion(forIde = false)}/artifacts"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ kotlin.build.publishing.attempts=20
|
|||||||
#jpsBuild=true
|
#jpsBuild=true
|
||||||
#cidrPluginsEnabled=true
|
#cidrPluginsEnabled=true
|
||||||
#idea.fir.plugin=true
|
#idea.fir.plugin=true
|
||||||
|
#attachedIntellijVersion=203 (or any other platform version)
|
||||||
|
|
||||||
## Used for compare gradle and jps build
|
## Used for compare gradle and jps build
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
versions.intellijSdk=202.7660.26
|
versions.intellijSdk=202.7660.26
|
||||||
|
versions.intellijSdk.forIde.202=202.7660.26
|
||||||
|
versions.intellijSdk.forIde.203=203.6682.168
|
||||||
versions.idea.NodeJS=193.6494.7
|
versions.idea.NodeJS=193.6494.7
|
||||||
versions.jar.asm-all=8.0.1
|
versions.jar.asm-all=8.0.1
|
||||||
versions.jar.guava=29.0-jre
|
versions.jar.guava=29.0-jre
|
||||||
|
|||||||
+1
-1
@@ -382,7 +382,7 @@ include ":prepare:ide-plugin-dependencies:android-extensions-compiler-plugin-for
|
|||||||
":prepare:ide-plugin-dependencies:compiler-components-for-jps",
|
":prepare:ide-plugin-dependencies:compiler-components-for-jps",
|
||||||
":prepare:ide-plugin-dependencies:kotlin-compiler-tests-for-ide"
|
":prepare:ide-plugin-dependencies:kotlin-compiler-tests-for-ide"
|
||||||
|
|
||||||
if (buildProperties.getBoolean("attachedIntellijVersion", false)) {
|
if (buildProperties.getOrNull("attachedIntellijVersion") != null) {
|
||||||
logger.info("Including kotlin-ide modules in settings.gradle")
|
logger.info("Including kotlin-ide modules in settings.gradle")
|
||||||
new File(rootDir, "kotlin-ide").eachFileRecurse {
|
new File(rootDir, "kotlin-ide").eachFileRecurse {
|
||||||
String fileName = it.name
|
String fileName = it.name
|
||||||
|
|||||||
Reference in New Issue
Block a user