From a471ddf059b826d3449f8893d77d58340049ed8c Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Wed, 2 Mar 2022 15:51:15 +0100 Subject: [PATCH] Kotlin JPS: Inject KOTLIN_BUNDLED macro into JPS KTIJ-21292 --- jps/jps-platform-api-signatures/README.md | 8 ++++++++ .../build.gradle.kts | 12 +++++++++++ .../JpsPathMacroContributor.java | 20 +++++++++++++++++++ jps/jps-plugin/build.gradle.kts | 1 + ...odel.serialization.JpsPathMacroContributor | 1 + .../jps/KotlinJpsPathMacrosContributor.kt | 15 ++++++++++++++ settings.gradle | 3 ++- 7 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 jps/jps-platform-api-signatures/README.md create mode 100644 jps/jps-platform-api-signatures/build.gradle.kts create mode 100644 jps/jps-platform-api-signatures/src/org/jetbrains/jps/model/serialization/JpsPathMacroContributor.java create mode 100644 jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.model.serialization.JpsPathMacroContributor create mode 100644 jps/jps-plugin/src/org/jetbrains/kotlin/jps/KotlinJpsPathMacrosContributor.kt diff --git a/jps/jps-platform-api-signatures/README.md b/jps/jps-platform-api-signatures/README.md new file mode 100644 index 00000000000..fb9da2d86ff --- /dev/null +++ b/jps/jps-platform-api-signatures/README.md @@ -0,0 +1,8 @@ +This module contains fake/stub IJ JPS API platform signatures from newer IJ platforms +(newer compared to the IJ platform Kotlin repository currently depends on). + +We need this module to copy-paste necessary IJ JPS API signature definitions into the Kotlin repository. +Copy-pasting signature definitions gives us an ability to use new JPS API which is not yet available +in the platform the Kotlin repository currently depends on. + +This module output SHOULD NOT be packed into Kotlin JPS plugin artifact. \ No newline at end of file diff --git a/jps/jps-platform-api-signatures/build.gradle.kts b/jps/jps-platform-api-signatures/build.gradle.kts new file mode 100644 index 00000000000..a0ce11b936a --- /dev/null +++ b/jps/jps-platform-api-signatures/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + implementation(kotlinStdlib()) +} + +sourceSets { + "main" { projectDefault() } +} diff --git a/jps/jps-platform-api-signatures/src/org/jetbrains/jps/model/serialization/JpsPathMacroContributor.java b/jps/jps-platform-api-signatures/src/org/jetbrains/jps/model/serialization/JpsPathMacroContributor.java new file mode 100644 index 00000000000..d47666c220c --- /dev/null +++ b/jps/jps-platform-api-signatures/src/org/jetbrains/jps/model/serialization/JpsPathMacroContributor.java @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.jps.model.serialization; + +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +/** + * This API exists starting from 221 IDEA + * + * Copy-pasted from https://github.com/JetBrains/intellij-community/blob/master/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsPathMacroContributor.java + */ +public interface JpsPathMacroContributor { + @NotNull + Map getPathMacros(); +} diff --git a/jps/jps-plugin/build.gradle.kts b/jps/jps-plugin/build.gradle.kts index 2f9dc67a4ce..f23e1d74e06 100644 --- a/jps/jps-plugin/build.gradle.kts +++ b/jps/jps-plugin/build.gradle.kts @@ -24,6 +24,7 @@ dependencies { api(project(":daemon-common-new")) api(project(":kotlin-daemon-client")) api(project(":kotlin-daemon")) + compileOnly(project(":jps:jps-platform-api-signatures")) testImplementation(projectTests(":generators:test-generator")) api(project(":compiler:frontend.java")) api(project(":js:js.frontend")) diff --git a/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.model.serialization.JpsPathMacroContributor b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.model.serialization.JpsPathMacroContributor new file mode 100644 index 00000000000..34cfe383a39 --- /dev/null +++ b/jps/jps-plugin/resources/META-INF/services/org.jetbrains.jps.model.serialization.JpsPathMacroContributor @@ -0,0 +1 @@ +org.jetbrains.kotlin.jps.KotlinJpsPathMacrosContributor \ No newline at end of file diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/KotlinJpsPathMacrosContributor.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/KotlinJpsPathMacrosContributor.kt new file mode 100644 index 00000000000..03068b8603e --- /dev/null +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/KotlinJpsPathMacrosContributor.kt @@ -0,0 +1,15 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.jps + +import org.jetbrains.jps.model.serialization.JpsPathMacroContributor + +class KotlinJpsPathMacrosContributor : JpsPathMacroContributor { + override fun getPathMacros(): Map = + System.getProperty("jps.kotlin.home") + ?.let { mapOf("KOTLIN_BUNDLED" to it) } + ?: emptyMap() +} diff --git a/settings.gradle b/settings.gradle index 110a4e7bcf2..bbb2c800420 100644 --- a/settings.gradle +++ b/settings.gradle @@ -526,7 +526,8 @@ if (attachedIntellijVersion == "master") { } include ":jps:jps-common", - ":jps:jps-plugin" + ":jps:jps-plugin", + ":jps:jps-platform-api-signatures" include ":generators:analysis-api-generator", ":analysis",