diff --git a/.idea/runConfigurations/Kotlin_Coop__Publish_Compiler_JARs.xml b/.idea/runConfigurations/Kotlin_Coop__Publish_Compiler_JARs.xml
new file mode 100644
index 000000000000..7a2745b8abf5
--- /dev/null
+++ b/.idea/runConfigurations/Kotlin_Coop__Publish_Compiler_JARs.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Kotlin_Coop__Publish_compiler_for_ide_JARs.xml b/.idea/runConfigurations/Kotlin_Coop__Publish_compiler_for_ide_JARs.xml
deleted file mode 100644
index 9ea8e4cecbf3..000000000000
--- a/.idea/runConfigurations/Kotlin_Coop__Publish_compiler_for_ide_JARs.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
- false
- false
- false
-
-
-
\ No newline at end of file
diff --git a/plugins/kotlin/util/project-model-updater/resources/model.properties b/plugins/kotlin/util/project-model-updater/resources/model.properties
index f65f343e880c..884c02c078da 100644
--- a/plugins/kotlin/util/project-model-updater/resources/model.properties
+++ b/plugins/kotlin/util/project-model-updater/resources/model.properties
@@ -11,5 +11,8 @@ jpsPluginArtifactsMode=MAVEN
# within this Kotlin Gradle Plugin
kotlinGradlePluginVersion=2.2.0-dev-15683
+# The path to the Kotlin compiler repository. The value might be both relative (to the IntelliJ repo root) and absolute
+kotlinCompilerRepoPath=..
+
# Use a local.properties file to override the values above locally without committing them to the repository
# The file should be located in the same directory as this file
\ No newline at end of file
diff --git a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/KotlinTestsDependenciesUtil.kt b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/KotlinTestsDependenciesUtil.kt
index d87758f36dda..111433435f45 100644
--- a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/KotlinTestsDependenciesUtil.kt
+++ b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/KotlinTestsDependenciesUtil.kt
@@ -66,6 +66,12 @@ object KotlinTestsDependenciesUtil {
error("cannot detect community root path for class $aClassLocation")
}
+ val monorepoRoot: Path?
+ get() = communityRoot.parent?.takeIf { it.resolve(ULTIMATE_MARKER).exists() }
+
+ val projectRoot: Path
+ get() = monorepoRoot ?: communityRoot
+
private val httpClient = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.NEVER).build()
data class DownloadFile(
diff --git a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/Main.kt b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/Main.kt
index 7f8cc56b740e..534ac8cffa5e 100644
--- a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/Main.kt
+++ b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/Main.kt
@@ -15,6 +15,8 @@ class GeneratorPreferences(properties: Properties) : Preferences(properties) {
val applicationMode: ApplicationMode? by OptionalPreference(ApplicationMode::valueOf)
+ val kotlinCompilerRepoPath: String by MandatoryPreference()
+
/**
* Represents modes of the application. [PROJECT_MODEL_UPDATER] is the default one.
*/
@@ -27,6 +29,14 @@ class GeneratorPreferences(properties: Properties) : Preferences(properties) {
* @see updateProjectModel
*/
PROJECT_MODEL_UPDATER,
+
+ /**
+ * Runs the compiler artifacts publication, so they might be consumed by [PROJECT_MODEL_UPDATER]
+ * mode later
+ *
+ * @see publishCompiler
+ */
+ COMPILER_PUBLICATION,
;
}
@@ -73,5 +83,6 @@ fun main(args: Array) {
val preferences = GeneratorPreferences.parse(args)
when (preferences.applicationMode) {
null, ApplicationMode.PROJECT_MODEL_UPDATER -> updateProjectModel(preferences)
+ ApplicationMode.COMPILER_PUBLICATION -> publishCompiler(preferences)
}
}
diff --git a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/compilerPublication.kt b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/compilerPublication.kt
new file mode 100644
index 000000000000..8fff0f49f67a
--- /dev/null
+++ b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/compilerPublication.kt
@@ -0,0 +1,54 @@
+// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
+package org.jetbrains.tools.model.updater
+
+import kotlin.io.path.absolute
+import kotlin.io.path.isDirectory
+import kotlin.system.exitProcess
+
+internal fun publishCompiler(preferences: GeneratorPreferences) {
+ val kotlinCompilerRepoPath = preferences.kotlinCompilerRepoPath
+ val root = KotlinTestsDependenciesUtil.projectRoot
+ val kotlinRepoRoot = root.resolve(kotlinCompilerRepoPath)
+ .also {
+ if (!it.isDirectory()) {
+ error("Kotlin compiler repo path does not exist or is not a directory: $it")
+ }
+ }
+ .absolute()
+ .normalize()
+
+ println("Kotlin compiler repo: $kotlinRepoRoot")
+ val kotlinSnapshotPath = KotlinTestsDependenciesUtil.communityRoot
+ .resolve("lib")
+ .resolve("kotlin-snapshot")
+ .absolute()
+ .normalize()
+
+ println("Artifacts path: $kotlinSnapshotPath")
+
+ val exitCode = ProcessBuilder(
+ gradleWrapperExecutable,
+ "publishIdeArtifacts",
+ ":prepare:ide-plugin-dependencies:kotlin-dist-for-ide:publish",
+ "-Ppublish.ide.plugin.dependencies=true",
+ "-PdeployVersion=$BOOTSTRAP_VERSION",
+ "-Pbuild.number=$BOOTSTRAP_VERSION",
+ "-Pkotlin.build.deploy-path=$kotlinSnapshotPath",
+ )
+ .directory(kotlinRepoRoot.toFile())
+ .inheritIO()
+ .start()
+ .waitFor()
+
+ if (exitCode != 0) {
+ exitProcess(exitCode)
+ }
+
+ println("Successfully published to $kotlinSnapshotPath")
+}
+
+private val gradleWrapperExecutable: String
+ get() {
+ val isWindows = System.getProperty("os.name").startsWith("Windows", ignoreCase = true)
+ return if (isWindows) "gradlew.bat" else "./gradlew"
+ }
diff --git a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/projectModelUpdater.kt b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/projectModelUpdater.kt
index a7e6363c7fe9..16e2e34510ca 100644
--- a/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/projectModelUpdater.kt
+++ b/plugins/kotlin/util/project-model-updater/src/org/jetbrains/tools/model/updater/projectModelUpdater.kt
@@ -5,7 +5,12 @@ import org.jetbrains.tools.model.updater.impl.JpsLibrary
import org.jetbrains.tools.model.updater.impl.JpsResolverSettings
import org.jetbrains.tools.model.updater.impl.readJpsResolverSettings
import java.nio.file.Path
-import kotlin.io.path.*
+import kotlin.io.path.Path
+import kotlin.io.path.deleteExisting
+import kotlin.io.path.isDirectory
+import kotlin.io.path.listDirectoryEntries
+import kotlin.io.path.readText
+import kotlin.io.path.writeText
internal fun updateProjectModel(preferences: GeneratorPreferences) {
copyBootstrapArtifactsToMavenRepositoryIfExists()
@@ -46,10 +51,8 @@ internal fun updateProjectModel(preferences: GeneratorPreferences) {
processRoot(communityRoot, isCommunity = true)
updateLatestGradlePluginVersion(communityRoot, preferences.kotlinGradlePluginVersion)
updateKGPVersionForKotlinNativeTests(communityRoot, preferences.kotlinGradlePluginVersion)
- updateCoopRunConfiguration(monorepoRoot, communityRoot)
}
-
private fun regenerateProjectLibraries(dotIdea: Path, newLibraries: List, resolverSettings: JpsResolverSettings) {
val librariesDir = dotIdea.resolve("libraries")
val oldLibraries = librariesDir.listDirectoryEntries("kotlinc_*").toMutableSet()
@@ -74,29 +77,6 @@ private fun regenerateProjectLibraries(dotIdea: Path, newLibraries: List
- "${matchResult.groupValues[1]}$BOOTSTRAP_VERSION${matchResult.groupValues[4]}"
- }
-
- communityRunConfigurationFile.writeText(communityResultText)
-
- val monorepoResultText = communityResultText.replace(Regex.fromLiteral("-Pkotlin.build.deploy-path=intellij/")) { matchResult ->
- matchResult.groupValues[0] + "community/"
- }
-
- require(monorepoResultText != communityResultText)
-
- val monorepoRunConfigurationFile = monorepoRoot?.resolve(runConfigurationFilePath)
- monorepoRunConfigurationFile?.writeText(monorepoResultText)
-}
-
-private val bootstrapVersionRegex = Regex("(-P(deployVersion|build\\.number)=)(.+?)([ \"])")
-
internal val kotlinCompilerCliVersionRegex: Regex = Regex("""kotlinCompilerCliVersion\s*=\s*"(\S+)"""")
internal val kotlincKotlinJpsPluginTestsVersionRegex: Regex = Regex("""kotlincKotlinJpsPluginTestsVersion\s*=\s*"(\S+)"""")