Skip to content

Commit 62e5a04

Browse files
committed
KTL-724 Added compiler arguments support
We are using `kotlin-compiler-arguments-description` maven dependency for extracting all known compiler arguments for the current kotlin version. We've added an endpoint for getting all known compiler dependencies by the given platform. We've extended `run` and `translate` endpoints with the user's compiler args.
1 parent cc3dc49 commit 62e5a04

38 files changed

+9600
-170
lines changed

build-settings-logic/src/main/kotlin/kotlin-compiler-server-version-catalog.settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pluginManagement {
1212
}
1313
maven("https://redirector.kotlinlang.org/maven/dev")
1414
mavenLocal()
15+
maven("https://redirector.kotlinlang.org/maven/dev")
1516
}
1617
}
1718

@@ -30,6 +31,7 @@ dependencyResolutionManagement {
3031
}
3132
maven("https://redirector.kotlinlang.org/maven/dev")
3233
mavenLocal()
34+
maven("https://redirector.kotlinlang.org/maven/dev")
3335
}
3436

3537
versionCatalogs {

build.gradle.kts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ version = "${libs.versions.kotlin.get()}-SNAPSHOT"
1212
val propertyFile = "application.properties"
1313

1414
plugins {
15-
alias(libs.plugins.spring.dependency.management)
1615
alias(libs.plugins.spring.boot)
16+
alias(libs.plugins.spring.dependency.management)
1717
alias(libs.plugins.kotlin.plugin.spring)
1818
id("base-kotlin-jvm-conventions")
1919
}
@@ -36,11 +36,15 @@ val resourceDependency: Configuration by configurations.creating {
3636
}
3737

3838
dependencies {
39-
annotationProcessor("org.springframework:spring-context-indexer")
40-
implementation("com.google.code.gson:gson")
39+
annotationProcessor(libs.spring.context.indexer)
4140
implementation("org.springframework.boot:spring-boot-starter-web")
42-
implementation(libs.springdoc)
41+
implementation("org.springframework.boot:spring-boot-starter-validation")
4342
implementation(libs.aws.springboot.container)
43+
implementation(libs.springdoc)
44+
implementation(libs.gson)
45+
implementation(libs.kotlinx.serialization.json)
46+
implementation(libs.kotlin.compiler.arguments.description)
47+
implementation(libs.kotlin.tooling.core)
4448
implementation(libs.junit)
4549
implementation(libs.logback.logstash.encoder)
4650
implementation(libs.kotlin.reflect)
@@ -70,6 +74,8 @@ fun buildPropertyFile() {
7074

7175
fun generateProperties(prefix: String = "") = """
7276
# this file is autogenerated by build.gradle.kts
77+
server.error.include-message=always
78+
server.error.include-binding-errors=always
7379
kotlin.version=${kotlinVersion}
7480
policy.file=${prefix + policy}
7581
libraries.folder.jvm=${prefix + libJVM}
@@ -147,4 +153,13 @@ tasks.withType<Test> {
147153
doFirst {
148154
this@withType.environment("kotlin.wasm.node.path", executablePath)
149155
}
156+
157+
// We disable this on TeamCity, because we don't want to fail this test,
158+
// when compiler server's test run as a K2 user project.
159+
// But for our pull requests we still need to run this test, so we add it to our GitHub action.
160+
if (System.getenv("TEAMCITY_VERSION") != null) {
161+
filter {
162+
excludeTestsMatching("com.compiler.server.CompilerArguments*")
163+
}
164+
}
150165
}

gradle/libs.versions.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-
2626
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" }
2727
kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin" }
2828
kotlin-compiler = { group = "org.jetbrains.kotlin", name = "kotlin-compiler", version.ref = "kotlin" }
29+
kotlin-tooling-core = { group = "org.jetbrains.kotlin", name = "kotlin-tooling-core", version.ref = "kotlin" }
30+
kotlin-compiler-arguments-description = { group = "org.jetbrains.kotlin", name = "kotlin-compiler-arguments-description", version.ref = "kotlin" }
2931
kotlin-script-runtime = { group = "org.jetbrains.kotlin", name = "kotlin-script-runtime", version.ref = "kotlin" }
3032
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
3133
kotlin-dom-api-compat = { group = "org.jetbrains.kotlin", name = "kotlin-dom-api-compat", version.ref = "kotlin" }
@@ -35,10 +37,9 @@ kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-cor
3537
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" }
3638
kotlinx-io-bytestring = { group = "org.jetbrains.kotlinx", name = "kotlinx-io-bytestring", version.ref = "kotlinx-io" }
3739
kotlinx-io-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-io-core", version.ref = "kotlinx-io" }
40+
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
3841
kotlinx-serialization-json-jvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json-jvm", version.ref = "kotlinx-serialization" }
3942
kotlinx-serialization-core-jvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core-jvm", version.ref = "kotlinx-serialization" }
40-
springdoc = { group = "org.springdoc", name = "springdoc-openapi-starter-webmvc-ui", version.ref = "springdoc" }
41-
aws-springboot-container = { group = "com.amazonaws.serverless", name = "aws-serverless-java-container-springboot3", version.ref = "aws-serverless-java-container-springboot3" }
4243
junit = { group = "junit", name = "junit", version.ref = "junit" }
4344
logback-logstash-encoder = { group = "net.logstash.logback", name = "logstash-logback-encoder", version.ref = "logstash-logback-encoder" }
4445
skiko-js-wasm-runtime = { group = "org.jetbrains.skiko", name = "skiko-js-wasm-runtime", version.ref = "skiko" }
@@ -57,6 +58,12 @@ compose-material3 = { group = "org.jetbrains.compose.material3", name = "materia
5758
compose-components-resources = { group = "org.jetbrains.compose.components", name = "components-resources", version.ref = "compose" }
5859
kotlin-serialization-plugin = {group= "org.jetbrains.kotlin", name="kotlin-serialization-compiler-plugin", version.ref = "kotlin"}
5960
gradle-develocity = {group = "com.gradle", name= "develocity-gradle-plugin", version.ref = "gradle-develocity"}
61+
gson = { group = "com.google.code.gson", name = "gson"}
62+
63+
#spring stack dependencies
64+
aws-springboot-container = { group = "com.amazonaws.serverless", name = "aws-serverless-java-container-springboot3", version.ref = "aws-serverless-java-container-springboot3" }
65+
spring-context-indexer = { group = "org.springframework", name = "spring-context-indexer"}
66+
springdoc = { group = "org.springdoc", name = "springdoc-openapi-starter-webmvc-ui", version.ref = "springdoc" }
6067

6168
[bundles]
6269
jackson = ["jackson-databind", "jackson-core", "jackson-annotations"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.compiler.server.api
2+
3+
import com.compiler.server.model.ExtendedCompilerArgumentValue
4+
import com.fasterxml.jackson.annotation.JsonTypeInfo
5+
6+
data class CompilerArgumentResponse(val compilerArguments: Set<CompilerArgument>) {
7+
8+
data class CompilerArgument(
9+
val name: String,
10+
val shortName: String?,
11+
val description: String?,
12+
@field:JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "type")
13+
val type: ExtendedCompilerArgumentValue<*>,
14+
val disabled: Boolean,
15+
val predefinedValues: Any?
16+
)
17+
}
18+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.compiler.server.api
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
4+
5+
@JsonIgnoreProperties(ignoreUnknown = true)
6+
data class ProjectFileRequestDto(val text: String = "", val name: String = "")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.compiler.server.api
2+
3+
import com.compiler.server.model.ProjectType
4+
import com.compiler.server.validation.CompilerArgumentsConstraint
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
data class RunRequest(
9+
val args: String = "",
10+
val files: List<ProjectFileRequestDto> = listOf(),
11+
@CompilerArgumentsConstraint(ProjectType.JAVA)
12+
val compilerArguments: Map<String, Any> = emptyMap()
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.compiler.server.api
2+
3+
import com.compiler.server.model.ProjectType
4+
import com.compiler.server.validation.CompilerArgumentsConstraint
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
data class TestRequest(
9+
val args: String = "",
10+
val files: List<ProjectFileRequestDto> = listOf(),
11+
@CompilerArgumentsConstraint(ProjectType.JAVA)
12+
val compilerArguments: Map<String, Any> = emptyMap()
13+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.compiler.server.api
2+
3+
import com.compiler.server.model.ProjectType
4+
import com.compiler.server.validation.CompilerArgumentsConstraint
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
class TranslateComposeWasmRequest(
9+
val args: String = "",
10+
val files: List<ProjectFileRequestDto> = listOf(),
11+
@CompilerArgumentsConstraint(ProjectType.COMPOSE_WASM)
12+
val firstPhaseCompilerArguments: Map<String, Any> = emptyMap(),
13+
@CompilerArgumentsConstraint(ProjectType.COMPOSE_WASM)
14+
val secondPhaseCompilerArguments: Map<String, Any> = emptyMap()
15+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.compiler.server.api
2+
3+
import com.compiler.server.model.ProjectType
4+
import com.compiler.server.validation.CompilerArgumentsConstraint
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
data class TranslateJsRequest(
9+
val args: String = "",
10+
val files: List<ProjectFileRequestDto> = listOf(),
11+
@CompilerArgumentsConstraint(ProjectType.JS)
12+
val firstPhaseCompilerArguments: Map<String, Any> = emptyMap(),
13+
@CompilerArgumentsConstraint(ProjectType.JS)
14+
val secondPhaseCompilerArguments: Map<String, Any> = emptyMap()
15+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.compiler.server.api
2+
3+
import com.compiler.server.model.ProjectType
4+
import com.compiler.server.validation.CompilerArgumentsConstraint
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
class TranslateWasmRequest(
9+
val args: String = "",
10+
val files: List<ProjectFileRequestDto> = listOf(),
11+
@CompilerArgumentsConstraint(ProjectType.WASM)
12+
val firstPhaseCompilerArguments: Map<String, Any> = emptyMap(),
13+
@CompilerArgumentsConstraint(ProjectType.WASM)
14+
val secondPhaseCompilerArguments: Map<String, Any> = emptyMap()
15+
)

0 commit comments

Comments
 (0)