Skip to content

Commit aa63ae4

Browse files
committed
Merge branch 'refs/heads/master' into 2.0.0-beta2-prepare
# Conflicts: # build.gradle.kts # src/main/kotlin/com/compiler/server/compiler/components/ErrorAnalyzer.kt
2 parents 3925e65 + 6abd1a1 commit aa63ae4

35 files changed

+496
-176
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ RUN if [ -z "$KOTLIN_VERSION" ]; then \
1010
ENV KOTLIN_LIB=$KOTLIN_VERSION
1111
ENV KOTLIN_LIB_JS=${KOTLIN_VERSION}-js
1212
ENV KOTLIN_LIB_WASM=${KOTLIN_VERSION}-wasm
13+
ENV KOTLIN_LIB_COMPOSE_WASM=${KOTLIN_VERSION}-compose-wasm
14+
ENV KOTLIN_COMPOSE_WASM_COMPILER_PLUGINS=${KOTLIN_VERSION}-compose-wasm-compiler-plugins
1315

1416
RUN mkdir -p /kotlin-compiler-server
1517
WORKDIR /kotlin-compiler-server
@@ -29,6 +31,8 @@ COPY --from=build /build/libs/BOOT-INF/classes /kotlin-compiler-server
2931
COPY --from=build /kotlin-compiler-server/${KOTLIN_LIB} /kotlin-compiler-server/${KOTLIN_LIB}
3032
COPY --from=build /kotlin-compiler-server/${KOTLIN_LIB_JS} /kotlin-compiler-server/${KOTLIN_LIB_JS}
3133
COPY --from=build /kotlin-compiler-server/${KOTLIN_LIB_WASM} /kotlin-compiler-server/${KOTLIN_LIB_WASM}
34+
COPY --from=build /kotlin-compiler-server/${KOTLIN_LIB_COMPOSE_WASM} /kotlin-compiler-server/${KOTLIN_LIB_COMPOSE_WASM}
35+
COPY --from=build /kotlin-compiler-server/${KOTLIN_COMPOSE_WASM_COMPILER_PLUGINS} /kotlin-compiler-server/${KOTLIN_COMPOSE_WASM_COMPILER_PLUGINS}
3236
COPY --from=build /kotlin-compiler-server/executor.policy /kotlin-compiler-server/
3337
COPY --from=build /kotlin-compiler-server/indexes.json /kotlin-compiler-server/
3438
COPY --from=build /kotlin-compiler-server/indexesJs.json /kotlin-compiler-server/

build.gradle.kts

Lines changed: 15 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,15 @@
1-
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2-
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
31
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
42
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
53
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
64
import org.springframework.boot.gradle.tasks.bundling.BootJar
75

8-
val kotlinVersion = rootProject.properties["systemProp.kotlinVersion"] ?: throw IllegalStateException("kotlinVersion is not specified")
9-
val kotlinIdeVersion: String by System.getProperties()
10-
val kotlinIdeVersionSuffix: String by System.getProperties()
116
val policy: String by System.getProperties()
12-
val indexes: String by System.getProperties()
13-
val indexesJs: String by System.getProperties()
14-
val indexesWasm: String by System.getProperties()
157

168
group = "com.compiler.server"
179
version = "$kotlinVersion-SNAPSHOT"
1810
java.sourceCompatibility = JavaVersion.VERSION_17
1911

20-
val kotlinDependency: Configuration by configurations.creating {
21-
isTransitive = false
22-
}
23-
val kotlinJsDependency: Configuration by configurations.creating {
24-
isTransitive = false
25-
attributes {
26-
attribute(
27-
KotlinPlatformType.attribute,
28-
KotlinPlatformType.js
29-
)
30-
attribute(
31-
KotlinJsCompilerAttribute.jsCompilerAttribute,
32-
KotlinJsCompilerAttribute.ir
33-
)
34-
}
35-
}
36-
37-
val kotlinWasmDependency: Configuration by configurations.creating {
38-
isTransitive = false
39-
attributes {
40-
attribute(
41-
KotlinPlatformType.attribute,
42-
KotlinPlatformType.wasm
43-
)
44-
}
45-
}
46-
47-
val libJSFolder = "$kotlinVersion-js"
48-
val libWasmFolder = "$kotlinVersion-wasm"
49-
val libJVMFolder = kotlinVersion
5012
val propertyFile = "application.properties"
51-
val jacksonVersionKotlinDependencyJar = "2.14.0" // don't forget to update version in `executor.policy` file.
52-
53-
val copyDependencies by tasks.creating(Copy::class) {
54-
from(kotlinDependency)
55-
into(libJVMFolder)
56-
}
57-
val copyJSDependencies by tasks.creating(Copy::class) {
58-
from(kotlinJsDependency)
59-
into(libJSFolder)
60-
}
61-
62-
val copyWasmDependencies by tasks.creating(Copy::class) {
63-
from(kotlinWasmDependency)
64-
into(libWasmFolder)
65-
}
6613

6714
plugins {
6815
id("org.springframework.boot") version "2.7.10"
@@ -91,6 +38,8 @@ allprojects {
9138
maven("https://www.myget.org/F/rd-snapshots/maven/")
9239
maven("https://kotlin.jetbrains.space/p/kotlin/packages/maven/kotlin-ide")
9340
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
41+
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
42+
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
9443
}
9544
afterEvaluate {
9645
dependencies {
@@ -105,22 +54,6 @@ allprojects {
10554
}
10655

10756
dependencies {
108-
kotlinDependency("junit:junit:4.13.2")
109-
kotlinDependency("org.hamcrest:hamcrest:2.2")
110-
kotlinDependency("com.fasterxml.jackson.core:jackson-databind:$jacksonVersionKotlinDependencyJar")
111-
kotlinDependency("com.fasterxml.jackson.core:jackson-core:$jacksonVersionKotlinDependencyJar")
112-
kotlinDependency("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersionKotlinDependencyJar")
113-
// Kotlin libraries
114-
kotlinDependency("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
115-
kotlinDependency("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion")
116-
kotlinDependency("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
117-
kotlinDependency("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
118-
kotlinDependency("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.3")
119-
kotlinDependency("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
120-
kotlinJsDependency("org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion")
121-
kotlinJsDependency("org.jetbrains.kotlin:kotlin-dom-api-compat:$kotlinVersion")
122-
kotlinWasmDependency("org.jetbrains.kotlin:kotlin-stdlib-wasm-js:$kotlinVersion")
123-
12457
annotationProcessor("org.springframework:spring-context-indexer")
12558
implementation("com.google.code.gson:gson")
12659
implementation("org.springframework.boot:spring-boot-starter-web")
@@ -163,9 +96,12 @@ fun generateProperties(prefix: String = "") = """
16396
indexes.file=${prefix + indexes}
16497
indexesJs.file=${prefix + indexesJs}
16598
indexesWasm.file=${prefix + indexesWasm}
99+
indexesComposeWasm.file=${prefix + indexesComposeWasm}
166100
libraries.folder.jvm=${prefix + libJVMFolder}
167101
libraries.folder.js=${prefix + libJSFolder}
168102
libraries.folder.wasm=${prefix + libWasmFolder}
103+
libraries.folder.compose-wasm=${prefix + libComposeWasmFolder}
104+
libraries.folder.compose-wasm-compiler-plugins=${prefix + libComposeWasmCompilerPluginsFolder}
169105
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
170106
server.compression.enabled=true
171107
server.compression.mime-types=application/json
@@ -182,9 +118,11 @@ tasks.withType<KotlinCompile> {
182118
freeCompilerArgs = listOf("-Xjsr305=strict")
183119
jvmTarget = "17"
184120
}
185-
dependsOn(copyDependencies)
186-
dependsOn(copyJSDependencies)
187-
dependsOn(copyWasmDependencies)
121+
dependsOn(":dependencies:copyDependencies")
122+
dependsOn(":dependencies:copyJSDependencies")
123+
dependsOn(":dependencies:copyWasmDependencies")
124+
dependsOn(":dependencies:copyComposeWasmDependencies")
125+
dependsOn(":dependencies:copyComposeWasmCompilerPlugins")
188126
dependsOn(":executors:jar")
189127
dependsOn(":indexation:run")
190128
buildPropertyFile()
@@ -208,9 +146,11 @@ val buildLambda by tasks.creating(Zip::class) {
208146
from(indexes)
209147
from(indexesJs)
210148
from(indexesWasm)
211-
from(libJSFolder) { into(libJSFolder) }
212-
from(libWasmFolder) { into(libWasmFolder) }
213-
from(libJVMFolder) { into(libJVMFolder) }
149+
from(libJSFolder) { into(libJS) }
150+
from(libWasmFolder) { into(libWasm) }
151+
from(libComposeWasmFolder) { into(libComposeWasm) }
152+
from(libJVMFolder) { into(libJVM) }
153+
from(libComposeWasmCompilerPluginsFolder) { into(libComposeWasmCompilerPlugins) }
214154
into("lib") {
215155
from(configurations.compileClasspath) { exclude("tomcat-embed-*") }
216156
}

buildSrc/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import org.gradle.api.Project
2+
import org.gradle.kotlin.dsl.provideDelegate
3+
4+
val kotlinVersion: String by System.getProperties()
5+
val kotlinIdeVersion: String by System.getProperties()
6+
val kotlinIdeVersionSuffix: String by System.getProperties()
7+
val indexes: String by System.getProperties()
8+
val indexesJs: String by System.getProperties()
9+
val indexesWasm: String by System.getProperties()
10+
val indexesComposeWasm: String by System.getProperties()
11+
12+
val libJS = "$kotlinVersion-js"
13+
val libWasm = "$kotlinVersion-wasm"
14+
val libComposeWasm = "$kotlinVersion-compose-wasm"
15+
val libComposeWasmCompilerPlugins = "$kotlinVersion-compose-wasm-compiler-plugins"
16+
val libJVM = kotlinVersion
17+
18+
val Project.libJSFolder
19+
get() = rootProject.layout.projectDirectory.dir(libJS)
20+
21+
val Project.libWasmFolder
22+
get() = rootProject.layout.projectDirectory.dir(libWasm)
23+
24+
val Project.libComposeWasmFolder
25+
get() = rootProject.layout.projectDirectory.dir(libComposeWasm)
26+
27+
val Project.libComposeWasmCompilerPluginsFolder
28+
get() = rootProject.layout.projectDirectory.dir(libComposeWasmCompilerPlugins)
29+
30+
val Project.libJVMFolder
31+
get() = rootProject.layout.projectDirectory.dir(libJVM)

common/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
val kotlinVersion: String by System.getProperties()
2-
val kotlinIdeVersion: String by System.getProperties()
3-
val kotlinIdeVersionSuffix: String by System.getProperties()
4-
51
plugins {
62
kotlin("jvm")
73
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package component
2+
3+
data class CompilerPluginOption(
4+
val id: String,
5+
val option: String,
6+
val value: String
7+
)

common/src/main/kotlin/component/KotlinEnvironment.kt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
1010
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoots
1111
import org.jetbrains.kotlin.cli.jvm.config.configureJdkClasspathRoots
1212
import org.jetbrains.kotlin.cli.jvm.configureAdvancedJvmOptions
13+
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
1314
import org.jetbrains.kotlin.config.CommonConfigurationKeys
1415
import org.jetbrains.kotlin.config.CompilerConfiguration
1516
import org.jetbrains.kotlin.config.JVMConfigurationKeys
1617
import org.jetbrains.kotlin.config.languageVersionSettings
1718
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
19+
import org.jetbrains.kotlin.library.impl.isKotlinLibrary
1820
import org.jetbrains.kotlin.serialization.js.JsModuleDescriptor
1921
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil
2022
import org.jetbrains.kotlin.serialization.js.ModuleKind
@@ -25,6 +27,9 @@ class KotlinEnvironment(
2527
val classpath: List<File>,
2628
additionalJsClasspath: List<File>,
2729
additionalWasmClasspath: List<File>,
30+
additionalComposeWasmClasspath: List<File>,
31+
composeWasmCompilerPlugins: List<File>,
32+
composeWasmCompilerPluginsOptions: List<CompilerPluginOption>
2833
) {
2934
companion object {
3035
/**
@@ -55,8 +60,20 @@ class KotlinEnvironment(
5560
}
5661
}
5762

58-
val JS_LIBRARIES = additionalJsClasspath.map { it.absolutePath }
59-
val WASM_LIBRARIES = additionalWasmClasspath.map { it.absolutePath }
63+
val JS_LIBRARIES = additionalJsClasspath
64+
.map { it.absolutePath }
65+
.filter { isKotlinLibrary(File(it)) }
66+
val WASM_LIBRARIES = additionalWasmClasspath
67+
.map { it.absolutePath }
68+
.filter { isKotlinLibrary(File(it)) }
69+
val COMPOSE_WASM_LIBRARIES = additionalComposeWasmClasspath
70+
.map { it.absolutePath }
71+
.filter { isKotlinLibrary(File(it)) }
72+
val COMPOSE_WASM_COMPILER_PLUGINS = composeWasmCompilerPlugins
73+
.map { it.absolutePath }
74+
75+
val composeWasmCompilerPluginOptions = composeWasmCompilerPluginsOptions
76+
.map { "plugin:${it.id}:${it.option}=${it.value}" }
6077

6178
@Synchronized
6279
fun <T> environment(f: (KotlinCoreEnvironment) -> T): T {
@@ -77,6 +94,20 @@ class KotlinEnvironment(
7794
put(JSConfigurationKeys.WASM_ENABLE_ASSERTS, false)
7895
}
7996

97+
val composeWasmConfiguration: CompilerConfiguration = configuration.copy().apply {
98+
put(CommonConfigurationKeys.MODULE_NAME, "moduleId")
99+
put(JSConfigurationKeys.LIBRARIES, COMPOSE_WASM_LIBRARIES)
100+
put(JSConfigurationKeys.WASM_ENABLE_ARRAY_RANGE_CHECKS, false)
101+
put(JSConfigurationKeys.WASM_ENABLE_ASSERTS, false)
102+
103+
PluginCliParser.loadPluginsSafe(
104+
COMPOSE_WASM_COMPILER_PLUGINS,
105+
composeWasmCompilerPluginOptions,
106+
emptyList(),
107+
this
108+
)
109+
}
110+
80111
private val environment = KotlinCoreEnvironment.createForProduction(
81112
projectDisposable = Disposer.newDisposable(),
82113
configuration = configuration.copy(),

0 commit comments

Comments
 (0)