Skip to content

Commit d446fdf

Browse files
committed
neat kotlin
1 parent 78c7664 commit d446fdf

File tree

7 files changed

+57
-17
lines changed

7 files changed

+57
-17
lines changed

Diff for: docker/kotlin_build.sh

+19-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,26 @@ cd "$(
66
pwd -P
77
)/" || exit
88

9+
# if os is windows, echo ok, otherwise echo alert.
10+
if [ "$(uname)" == "Darwin" ]; then
11+
echo "macOS detected"
12+
elif [ "$(expr substr "$(uname -s)" 1 5)" == "Linux" ]; then
13+
echo "Linux detected"
14+
else
15+
export JAVA_HOME_8=/d/zoo/java-se-8u44/
16+
export JAVA_HOME_11=/d/zoo/jdk-11.0.23/
17+
export JAVA_HOME_21=/d/zoo/jdk-21.0.3/
18+
export JAVA_HOME_23=/d/zoo/jdk-23/
19+
fi
20+
# if the first input parameter is empty, use JAVA_HOME_21, otherwise use it.
21+
if [ -z "$1" ]; then
22+
export JAVA_HOME=$JAVA_HOME_21
23+
else
24+
export JAVA_HOME="JAVA_HOME_$1"
25+
fi
26+
echo "JAVA_HOME=$JAVA_HOME"
927
gradle --version
10-
28+
#
1129
echo "~~~ build grpc server kotlin ~~~"
1230
cd ../hello-grpc-kotlin
1331
cd server

Diff for: hello-grpc-kotlin/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
```bash
44
# brew install gradle
5+
gradle -v | grep JVM
56
gradle clean installDist --warning-mode all
67
gradle :server:ProtoServer
78
gradle :client:ProtoClient

Diff for: hello-grpc-kotlin/build.gradle.kts

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@ plugins {
88

99
//https://github.com/grpc/grpc/releases
1010
//https://mvnrepository.com/artifact/io.grpc/grpc-netty
11-
ext["grpcVersion"] = "1.61.0"
11+
ext["grpcVersion"] = "1.68.0"
12+
//https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
13+
ext["kotlinxVersion"] = "1.9.0"
1214
//https://github.com/grpc/grpc-kotlin
15+
//https://mvnrepository.com/artifact/io.grpc/grpc-kotlin-stub
16+
//https://mvnrepository.com/artifact/io.grpc/protoc-gen-grpc-kotlin
1317
ext["grpcKotlinVersion"] = "1.4.1"
1418
//https://github.com/protocolbuffers/protobuf/releases
1519
//https://mvnrepository.com/artifact/com.google.protobuf/protobuf-kotlin
16-
ext["protobufVersion"] = "3.25.3"
20+
ext["protobufVersion"] = "4.28.2"
21+
//https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java-util
22+
ext["protobufJavaUtilVersion"] = "4.28.2"
1723
//https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
18-
ext["log4jVersion"] = "2.23.0"
24+
ext["log4jVersion"] = "2.24.0"
25+
//https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api-kotlin
26+
ext["log4jKotlinVersion"] = "1.5.0"
1927
//https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
2028
ext["jacksonVersion"] = "2.16.1"
2129

30+
2231
allprojects {
2332
repositories {
2433
maven {

Diff for: hello-grpc-kotlin/client/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
32

43
plugins {
54
application
@@ -14,6 +13,7 @@ application {
1413

1514
dependencies {
1615
implementation(project(":stub"))
16+
implementation("org.jetbrains.kotlin:kotlin-reflect:${rootProject.ext["kotlinxVersion"]}")
1717
runtimeOnly("io.grpc:grpc-netty:${rootProject.ext["grpcVersion"]}")
1818
}
1919

Diff for: hello-grpc-kotlin/doc/windows_jdk.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Windows JAVA_HOME
2+
3+
```sh
4+
export JAVA_HOME_8=/d/zoo/java-se-8u44/
5+
export JAVA_HOME_11=/d/zoo/jdk-11.0.23/
6+
export JAVA_HOME_21=/d/zoo/jdk-21.0.3/
7+
export JAVA_HOME_23=/d/zoo/jdk-23/
8+
9+
export JAVA_HOME=$JAVA_HOME_21
10+
echo $JAVA_HOME
11+
```

Diff for: hello-grpc-kotlin/stub/build.gradle.kts

+12-11
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,20 @@ dependencies {
1212
protobuf(project(":protos"))
1313
implementation("io.grpc:grpc-stub:${rootProject.ext["grpcVersion"]}")
1414
api(kotlin("stdlib"))
15-
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.3-native-mt")
15+
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.ext["kotlinxVersion"]}")
1616
api("io.grpc:grpc-protobuf:${rootProject.ext["grpcVersion"]}")
1717
api("io.grpc:grpc-netty:${rootProject.ext["grpcVersion"]}")
18-
api("com.google.protobuf:protobuf-java-util:4.28.2")
19-
api("io.grpc:grpc-kotlin-stub:1.4.1")
20-
api("org.apache.logging.log4j:log4j-api-kotlin:1.5.0")
18+
api("com.google.protobuf:protobuf-java-util:${rootProject.ext["protobufJavaUtilVersion"]}")
19+
api("io.grpc:grpc-kotlin-stub:${rootProject.ext["grpcKotlinVersion"]}")
20+
api("org.apache.logging.log4j:log4j-api-kotlin:${rootProject.ext["log4jKotlinVersion"]}")
2121
api("org.apache.logging.log4j:log4j-api:${rootProject.ext["log4jVersion"]}")
2222
api("org.apache.logging.log4j:log4j-core:${rootProject.ext["log4jVersion"]}")
2323
api("com.fasterxml.jackson.core:jackson-databind:${rootProject.ext["jacksonVersion"]}")
2424
api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${rootProject.ext["jacksonVersion"]}")
2525
testImplementation(kotlin("test"))
2626
}
2727

28-
java {
29-
sourceCompatibility = JavaVersion.VERSION_16
30-
}
31-
3228
protobuf {
33-
generatedFilesBaseDir = "$projectDir/src/generated"
3429
protoc {
3530
artifact = "com.google.protobuf:protoc:${rootProject.ext["protobufVersion"]}"
3631
}
@@ -39,6 +34,7 @@ protobuf {
3934
artifact = "io.grpc:protoc-gen-grpc-java:${rootProject.ext["grpcVersion"]}"
4035
}
4136
id("grpckt") {
37+
// https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-kotlin/
4238
artifact = "io.grpc:protoc-gen-grpc-kotlin:${rootProject.ext["grpcKotlinVersion"]}:jdk8@jar"
4339
}
4440
}
@@ -52,10 +48,15 @@ protobuf {
5248
}
5349
}
5450

55-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
56-
kotlinOptions.jvmTarget = "16"
51+
java {
52+
sourceCompatibility = JavaVersion.VERSION_21
5753
}
5854

55+
kotlin {
56+
compilerOptions {
57+
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
58+
}
59+
}
5960
tasks.test {
6061
useJUnitPlatform()
6162
}

Diff for: hello-grpc-kotlin/stub/src/main/kotlin/org/feuyeux/grpc/Utils.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.feuyeux.grpc;
1+
package org.feuyeux.grpc
22

33
import java.util.Map
44

0 commit comments

Comments
 (0)