Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM openjdk:11.0.16-jdk as build

ENV KOTLIN_LIB=1.8.10
ENV KOTLIN_LIB_JS=1.8.10-js
ENV KOTLIN_LIB=1.8.20
ENV KOTLIN_LIB_JS=1.8.20-js

RUN mkdir -p /kotlin-compiler-server
WORKDIR /kotlin-compiler-server
Expand Down
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ val kotlinJsDependency: Configuration by configurations.creating {
)
attribute(
KotlinJsCompilerAttribute.jsCompilerAttribute,
KotlinJsCompilerAttribute.legacy
KotlinJsCompilerAttribute.ir
)
}
}
Expand All @@ -46,13 +46,14 @@ val copyJSDependencies by tasks.creating(Copy::class) {
plugins {
id("org.springframework.boot") version "2.7.9"
id("io.spring.dependency-management") version "1.1.0"
kotlin("jvm") version "1.8.10"
kotlin("plugin.spring") version "1.8.10"
kotlin("jvm") version "1.8.20"
kotlin("plugin.spring") version "1.8.20"
}

allprojects {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://repo.spring.io/snapshot")
maven("https://repo.spring.io/milestone")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide")
Expand Down
5 changes: 5 additions & 0 deletions common/src/main/kotlin/component/KotlinEnvironment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ class KotlinEnvironment(
put(JVMConfigurationKeys.DO_NOT_CLEAR_BINDING_CONTEXT, true)

configureJdkClasspathRoots()
val jdkHome = get(JVMConfigurationKeys.JDK_HOME)
if (jdkHome == null) {
val javaHome = File(System.getProperty("java.home"))
put(JVMConfigurationKeys.JDK_HOME, javaHome)
}
}
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
systemProp.kotlinVersion=1.8.10
systemProp.kotlinIdeVersion=1.8.10-release-430
systemProp.kotlinVersion=1.8.20
systemProp.kotlinIdeVersion=1.8.20-release-327
systemProp.policy=executor.policy
systemProp.indexes=indexes.json
systemProp.indexesJs=indexesJs.json
7 changes: 7 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ rootProject.name = "kotlin-compiler-server"
include(":executors")
include(":indexation")
include(":common")

pluginManagement{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is problem on gradle plugin portal's side with release artifacts, so now it's needed to specify repo explicitly. It will be described in documentation

repositories{
gradlePluginPortal()
mavenCentral()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import component.KotlinEnvironment
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.ir.backend.js.CompilerResult
import org.jetbrains.kotlin.ir.backend.js.WholeWorldStageController
import org.jetbrains.kotlin.ir.backend.js.compile
import org.jetbrains.kotlin.ir.backend.js.prepareAnalyzedSourceModule
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformer
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.TranslationMode
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImplForJsIC
import org.jetbrains.kotlin.js.config.JsConfig
import org.jetbrains.kotlin.js.facade.K2JSTranslator
import org.jetbrains.kotlin.js.facade.MainCallParameters
Expand All @@ -29,12 +31,12 @@ class KotlinToJSTranslator(
private const val JS_CODE_FLUSH = "kotlin.kotlin.io.output.flush();\n"
private const val JS_CODE_BUFFER = "\nkotlin.kotlin.io.output.buffer;\n"

private const val JS_IR_CODE_BUFFER = "moduleId.output._buffer;\n"
private const val JS_IR_CODE_BUFFER = "moduleId.output.buffer_1;\n"

private val JS_IR_OUTPUT_REWRITE = """
if (kotlin.isRewrite) {
init_properties_console_kt_6h8hpf();
output = new BufferedOutput_0()
_init_properties_console_kt__rfg7jv();
output = new BufferedOutput()
}
""".trimIndent()

Expand Down Expand Up @@ -115,19 +117,20 @@ class KotlinToJSTranslator(
val ir = compile(
sourceModule,
kotlinEnvironment.jsIrPhaseConfig,
irFactory = IrFactoryImpl
irFactory = IrFactoryImplForJsIC(WholeWorldStageController())
)
val transformer = IrModuleToJsTransformer(
ir.context,
arguments,
fullJs = true,
dceJs = false,
multiModule = false,
relativeRequirePath = true,
arguments
)

val compiledModule: CompilerResult = transformer.generateModule(ir.allModules)
val jsCode = compiledModule.outputs.values.single().jsCode
val compiledModule: CompilerResult = transformer.generateModule(
modules = ir.allModules,
modes = setOf(TranslationMode.FULL_PROD),
relativeRequirePath = false
)

val jsCode = getJsCodeFromModule(compiledModule)

val listLines = jsCode
.lineSequence()
Expand All @@ -139,4 +142,15 @@ class KotlinToJSTranslator(

return TranslationJSResult(listLines.joinToString("\n"))
}

private fun getJsCodeFromModule(compiledModule: CompilerResult): String {
val jsCodeObject = compiledModule.outputs.values.single()

val jsCodeClass = jsCodeObject.javaClass
val jsCode = jsCodeClass.getDeclaredField("rawJsCode").let {
it.isAccessible = true
it.get(jsCodeObject) as String
}
return jsCode
}
}
6 changes: 3 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# this file is autogenerated by build.gradle.kts
kotlin.version=1.8.10
kotlin.version=1.8.20
policy.file=executor.policy
indexes.file=indexes.json
indexesJs.file=indexesJs.json
libraries.folder.jvm=1.8.10
libraries.folder.js=1.8.10-js
libraries.folder.jvm=1.8.20
libraries.folder.js=1.8.20-js
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
6 changes: 3 additions & 3 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"version": "1.7.21"
},
{
"version": "1.8.10",
"latestStable": true
"version": "1.8.10"
},
{
"version": "1.8.20-RC2"
"version": "1.8.20",
"latestStable": true
}
]