Skip to content

Commit d327640

Browse files
authored
Merge pull request #755 from JetBrains/dkrasnov/2.0.20-prepared-to-merge
Merge 2.0.20 to master
2 parents 7c344a3 + f2a4d56 commit d327640

File tree

593 files changed

+1275
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

593 files changed

+1275
-341
lines changed

.github/workflows/collect-samples-cron.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/setup-java@v3
2525
with:
2626
java-version: '17'
27-
distribution: 'adopt'
27+
distribution: 'temurin'
2828
- name: Run a verifier
2929
uses: AlexanderPrendota/kotlin-samples-verifier@master
3030
with:

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
uses: actions/setup-java@v3
1414
with:
1515
java-version: '17'
16-
distribution: 'adopt'
16+
distribution: 'corretto'
1717
- name: Grant execute permission for gradlew
1818
run: chmod +x gradlew
1919
- name: Build with Gradle

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ build/
55
!**/src/test/**
66
src/main/resources/application.properties
77

8+
# compile artifacts
9+
.kotlin/
10+
1.9.*/
11+
2.*/
12+
indexes*.json
13+
*.log
14+
815
### STS ###
916
.apt_generated
1017
.classpath

README.md

Lines changed: 7 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![official JetBrains project](https://jb.gg/badges/official-plastic.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
44
![Build status](https://buildserver.labs.intellij.net/app/rest/builds/buildType:id:Kotlin_KotlinSites_Deployments_PlayKotlinlangOrg_Backend_BuildMaster/statusIcon.svg)
5-
![Java CI](https://github.com/AlexanderPrendota/kotlin-compiler-server/workflows/Java%20CI/badge.svg)
5+
![Java CI](https://github.com/JetBrains/kotlin-compiler-server/workflows/Java%20CI/badge.svg)
66
![TC status](https://img.shields.io/teamcity/build/s/Kotlin_KotlinPlayground_KotlinCompilerServer_Build?label=TeamCity%20build)
77
[![Kotlin](https://img.shields.io/badge/Kotlin-1.7.20-orange.svg) ](https://kotlinlang.org/)
88
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
@@ -52,108 +52,12 @@ remove [aws-serverless-container](https://github.com/awslabs/aws-serverless-java
5252

5353
## API Documentation :page_with_curl:
5454

55-
### Execute Kotlin code on JVM
56-
57-
```shell script
58-
curl -X POST \
59-
http://localhost:8080/api/compiler/run \
60-
-H 'Content-Type: application/json' \
61-
-d '{
62-
"args": "1 2 3",
63-
"files": [
64-
{
65-
"name": "File.kt",
66-
"text": "fun main() {\n println(\"123\")\n}"
67-
}
68-
]
69-
}'
70-
```
71-
72-
### Translate Kotlin code to JavaScript code
73-
74-
```shell script
75-
curl -X POST \
76-
http://localhost:8080/api/compiler/translate \
77-
-H 'Content-Type: application/json' \
78-
-d '{
79-
"args": "1 2 3",
80-
"files": [
81-
{
82-
"name": "File.kt",
83-
"text": "fun main(args: Array<String>) {\n println(args[0])\n }"
84-
}
85-
]
86-
}'
87-
```
88-
89-
### Run Kotlin tests
90-
91-
```shell script
92-
curl -X POST \
93-
http://localhost:8080/api/compiler/test \
94-
-H 'Content-Type: application/json' \
95-
-d '{
96-
"files": [
97-
{
98-
"name": "File.kt",
99-
"text": "fun start(): String = \"OK\""
100-
},
101-
{
102-
"name": "test0.kt",
103-
"text": "import org.junit.Assert\nimport org.junit.Test\n\nclass TestStart {\n @Test fun testOk() {\n Assert.assertEquals(\"OK\", start())\n }\n}"
104-
},
105-
{
106-
"name": "test1.kt",
107-
"text": "package koans.util\n\nfun String.toMessage() = \"The function '\''$this'\'' is implemented incorrectly\"\n\nfun String.toMessageInEquals() = toMessage().inEquals()\n\nfun String.inEquals() = this"
108-
}
109-
]
110-
}'
111-
```
112-
113-
### Get code completions for a specified place in code
114-
115-
```shell script
116-
curl -X POST \
117-
'http://localhost:8080/api/compiler/complete?line=2&ch=15' \
118-
-H 'Content-Type: application/json' \
119-
-d '{
120-
"files": [
121-
{
122-
"name": "File.kt",
123-
"text": "fun main() {\n val sinusoid = \"sinusoid\"\n val s = sin\n}"
124-
}
125-
]
126-
}'
127-
```
128-
129-
### Get code analysis results
130-
131-
```shell script
132-
curl -X POST \
133-
http://localhost:8080/api/compiler/highlight \
134-
-H 'Content-Type: application/json' \
135-
-d '{
136-
"files": [
137-
{
138-
"name": "File.kt",
139-
"text": "fun main() {\n println(\"Hello, world!!!\")ass\n val random = Random\n}"
140-
}
141-
]
142-
}'
143-
```
144-
145-
### Get the current Kotlin version
146-
147-
```shell script
148-
curl -X GET http://localhost:8080/versions
149-
```
150-
151-
The server also supports an [API](https://github.com/JetBrains/kotlin-playground) for the Kotlin Playground library.
55+
Swagger url: http://localhost:8080/swagger-ui/
15256

15357
## How to add your dependencies to kotlin compiler :books:
15458

15559
Just put whatever you need as dependencies
156-
to [build.gradle.kts](https://github.com/AlexanderPrendota/kotlin-compiler-server/blob/master/build.gradle.kts) via a
60+
to [build.gradle.kts](https://github.com/JetBrains/kotlin-compiler-server/blob/master/build.gradle.kts) via a
15761
task called `kotlinDependency`:
15862

15963
```
@@ -163,7 +67,7 @@ task called `kotlinDependency`:
16367
NOTE: If the library you're adding uses reflection, accesses the file system, or performs any other type of
16468
security-sensitive operations, don't forget to
16569
configure
166-
the [executors.policy](https://github.com/AlexanderPrednota/kotlin-compiler-server/blob/master/executors.policy)
70+
the [executor.policy](https://github.com/JetBrains/kotlin-compiler-server/blob/master/executor.policy)
16771
. [Click here](https://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html) for more information
16872
about *Java Security Policy*.
16973

@@ -209,19 +113,19 @@ In case of an unsuccessful execution in the standard output will be the event wi
209113
"level_value": 20000,
210114
"hasErrors": true,
211115
"confType": "JAVA",
212-
"kotlinVersion": "$koltinVersion"
116+
"kotlinVersion": "$kotlinVersion"
213117
}
214118
```
215119

216120
## Kotlin release guide :rocket:
217121

218122
1) Update the kotlin version
219-
in [gradle.properties](https://github.com/AlexanderPrendota/kotlin-compiler-server/blob/master/gradle.properties)
123+
in [libs.versions.toml](https://github.com/JetBrains/kotlin-compiler-server/blob/master/gradle/libs.versions.toml)
220124
2) Make sure everything is going well via the task:
221125

222126
```shell script
223127
$ ./gradlew build
224128
```
225129

226130
3) Save branch with the name of the kotlin version. Pattern: `/^[0-9.]+$/` (optional)
227-
4) Bump version on GitHub [releases](https://github.com/AlexanderPrendota/kotlin-compiler-server/releases) (optional)
131+
4) Bump version on GitHub [releases](https://github.com/JetBrains/kotlin-compiler-server/releases) (optional)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rootProject.name = "build-settings-logic"
2+
3+
dependencyResolutionManagement {
4+
5+
@Suppress("UnstableApiUsage")
6+
repositories {
7+
mavenCentral()
8+
gradlePluginPortal()
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
register("libs").configure {
4+
val kotlinVersion = providers.gradleProperty("kotlinVersion")
5+
if (kotlinVersion.isPresent) {
6+
version("kotlin", kotlinVersion.get())
7+
}
8+
}
9+
}
10+
}

build.gradle.kts

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ import org.springframework.boot.gradle.tasks.bundling.BootJar
77
val policy: String by System.getProperties()
88

99
group = "com.compiler.server"
10-
version = "$kotlinVersion-SNAPSHOT"
11-
java.sourceCompatibility = JavaVersion.VERSION_17
10+
version = "${libs.versions.kotlin.get()}-SNAPSHOT"
1211

1312
val propertyFile = "application.properties"
1413

1514
plugins {
16-
id("org.springframework.boot") version "2.7.10"
17-
id("io.spring.dependency-management") version "1.1.3"
18-
val kotlinVersion by System.getProperties()
19-
kotlin("jvm") version "$kotlinVersion"
20-
kotlin("plugin.spring") version "$kotlinVersion"
15+
alias(libs.plugins.spring.dependency.management)
16+
alias(libs.plugins.spring.boot)
17+
alias(libs.plugins.kotlin.jvm)
18+
alias(libs.plugins.kotlin.plugin.spring)
19+
}
20+
21+
kotlin.jvmToolchain {
22+
languageVersion.set(JavaLanguageVersion.of(17))
23+
vendor.set(JvmVendorSpec.AMAZON)
2124
}
2225

2326
apply<NodeJsRootPlugin>()
@@ -42,7 +45,7 @@ allprojects {
4245
dependencies {
4346
dependencies {
4447
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.15.2")
45-
implementation("org.jetbrains.kotlin:idea:231-$kotlinIdeVersion-$kotlinIdeVersionSuffix") {
48+
implementation(libs.kotlin.idea) {
4649
isTransitive = false
4750
}
4851
}
@@ -59,30 +62,29 @@ dependencies {
5962
annotationProcessor("org.springframework:spring-context-indexer")
6063
implementation("com.google.code.gson:gson")
6164
implementation("org.springframework.boot:spring-boot-starter-web")
62-
implementation("com.amazonaws.serverless:aws-serverless-java-container-springboot2:1.9.3")
63-
implementation("junit:junit:4.13.2")
64-
implementation("net.logstash.logback:logstash-logback-encoder:7.3")
65-
implementation("org.jetbrains.intellij.deps:trove4j:1.0.20221201")
66-
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
67-
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
68-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion")
69-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
70-
implementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
71-
implementation("org.jetbrains.kotlin:kotlin-compiler:$kotlinVersion")
72-
implementation("org.jetbrains.kotlin:kotlin-script-runtime:$kotlinVersion")
73-
implementation("org.jetbrains.kotlin:kotlin-compiler-for-ide:$kotlinIdeVersion"){
65+
implementation(libs.springfox.boot.starter)
66+
implementation(libs.aws.springboot.container)
67+
implementation(libs.junit)
68+
implementation(libs.logback.logstash.encoder)
69+
implementation(libs.intellij.trove4j)
70+
implementation(libs.kotlin.reflect)
71+
implementation(libs.bundles.kotlin.stdlib)
72+
implementation(libs.kotlin.test)
73+
implementation(libs.kotlin.compiler)
74+
implementation(libs.kotlin.script.runtime)
75+
implementation(libs.kotlin.compiler.ide) {
7476
isTransitive = false
7577
}
76-
implementation("org.jetbrains.kotlin:core:231-$kotlinIdeVersion-$kotlinIdeVersionSuffix")
78+
implementation(libs.kotlin.core)
7779
implementation(project(":executors", configuration = "default"))
7880
implementation(project(":common", configuration = "default"))
7981

8082
testImplementation("org.springframework.boot:spring-boot-starter-test") {
8183
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
8284
}
83-
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
85+
testImplementation(libs.kotlinx.coroutines.test)
8486

85-
resourceDependency("org.jetbrains.skiko:skiko-js-wasm-runtime:0.7.90")
87+
resourceDependency(libs.skiko.js.wasm.runtime)
8688
}
8789

8890
fun buildPropertyFile() {
@@ -111,16 +113,9 @@ fun generateProperties(prefix: String = "") = """
111113
server.compression.mime-types=application/json,text/javascript,application/wasm
112114
""".trimIndent()
113115

114-
java {
115-
toolchain {
116-
languageVersion.set(JavaLanguageVersion.of("17"))
117-
}
118-
}
119-
120116
tasks.withType<KotlinCompile> {
121-
kotlinOptions {
122-
freeCompilerArgs = listOf("-Xjsr305=strict")
123-
jvmTarget = "17"
117+
compilerOptions {
118+
freeCompilerArgs.set(listOf("-Xjsr305=strict"))
124119
}
125120
dependsOn(":dependencies:copyDependencies")
126121
dependsOn(":dependencies:copyJSDependencies")
@@ -131,7 +126,7 @@ tasks.withType<KotlinCompile> {
131126
dependsOn(":indexation:run")
132127
buildPropertyFile()
133128
}
134-
println("Using Kotlin compiler $kotlinVersion")
129+
println("Using Kotlin compiler ${libs.versions.kotlin.get()}")
135130

136131
tasks.withType<BootJar> {
137132
requiresUnpack("**/kotlin-*.jar")
@@ -143,7 +138,9 @@ val buildLambda by tasks.creating(Zip::class) {
143138
from(tasks.compileKotlin)
144139
from(tasks.processResources) {
145140
eachFile {
146-
if (name == propertyFile) { file.writeText(generateProperties(lambdaWorkDirectoryPath)) }
141+
if (name == propertyFile) {
142+
file.writeText(generateProperties(lambdaWorkDirectoryPath))
143+
}
147144
}
148145
}
149146
from(policy)
@@ -176,7 +173,7 @@ tasks.withType<Test> {
176173
doFirst {
177174
this@withType.environment(
178175
"kotlin.wasm.node.path",
179-
rootProject.the<NodeJsRootExtension>().requireConfigured().nodeExecutable
176+
rootProject.the<NodeJsRootExtension>().requireConfigured().executable
180177
)
181178
}
182179
}

buildSrc/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ plugins {
44

55
repositories {
66
mavenCentral()
7+
}
8+
9+
// workaround to pass libs into conventions (see https://github.com/gradle/gradle/issues/15383)
10+
dependencies {
11+
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
712
}

buildSrc/settings.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pluginManagement {
2+
includeBuild("../build-settings-logic")
3+
}
4+
5+
dependencyResolutionManagement {
6+
// For buildSrc we need to declare a custom path to the toml file with versions' catalog.
7+
// But for a root project we can't set `from` inside `versionCatalogs` catalog block for the default `libs` catalog.
8+
// (see https://github.com/gradle/gradle/issues/21328)
9+
// That is why it is not fully moved to the dependencyResolutionManagement block in the settings convention plugin.
10+
versionCatalogs {
11+
getByName("libs") {
12+
from(files("../gradle/libs.versions.toml"))
13+
}
14+
}
15+
}
16+
17+
plugins {
18+
id("kotlin-compiler-server-version-catalog")
19+
}

0 commit comments

Comments
 (0)