Skip to content

Commit 6f64bbf

Browse files
committed
Fix JPMS for gRPC (#390)
1 parent 6eab5d9 commit 6f64bbf

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

grpc/grpc-core/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ kotlin {
1414
api(projects.core)
1515
api(projects.utils)
1616
api(libs.coroutines.core)
17+
18+
implementation(libs.atomicfu)
1719
}
1820
}
1921

2022
jvmMain {
2123
dependencies {
24+
api(libs.grpc.api)
2225
api(libs.grpc.util)
2326
api(libs.grpc.stub)
2427
api(libs.grpc.protobuf)
25-
api(libs.grpc.kotlin.stub)
28+
implementation(libs.grpc.kotlin.stub) // causes problems to jpms if api
2629
api(libs.protobuf.java.util)
27-
api(libs.protobuf.kotlin)
30+
implementation(libs.protobuf.kotlin)
2831
}
2932
}
3033
}

jpms-check/build.gradle.kts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
import util.targets.hasJavaModule
@@ -11,9 +11,13 @@ plugins {
1111

1212
description = "Internal module for checking JPMS compliance"
1313

14-
tasks.register("generateModuleInfo") {
14+
val excludedProjects = listOf(
15+
"protobuf-plugin",
16+
)
17+
18+
val generateModuleInfo = tasks.register("generateModuleInfo") {
1519
val modules = project.rootProject.subprojects
16-
.filter { it.hasJavaModule }
20+
.filter { it.applicableForCheck() }
1721
.map { it.javaModuleName() }
1822

1923
val moduleInfoPath = project.projectDir.absolutePath + "/src/main/java/module-info.java"
@@ -33,7 +37,7 @@ tasks.register("generateModuleInfo") {
3337
}
3438

3539
tasks.getByName<JavaCompile>("compileJava") {
36-
dependsOn("generateModuleInfo")
40+
dependsOn(generateModuleInfo)
3741

3842
val projectFiles = project.files()
3943
doFirst {
@@ -58,9 +62,13 @@ dependencies {
5862
.joinToString(":", prefix = ":") { segment -> segment.name }
5963

6064
it.plugins.withId("maven-publish") {
61-
if (it.hasJavaModule) {
65+
if (it.applicableForCheck()) {
6266
api(project(dep))
6367
}
6468
}
6569
}
6670
}
71+
72+
private fun Project.applicableForCheck(): Boolean {
73+
return hasJavaModule && name !in excludedProjects
74+
}

versions-root/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "p
102102
protobuf-java-util = { module = "com.google.protobuf:protobuf-java-util", version.ref = "protobuf" }
103103
protobuf-kotlin = { module = "com.google.protobuf:protobuf-kotlin", version.ref = "protobuf" }
104104
protobuf-gradle-plugin = { module = "com.google.protobuf:protobuf-gradle-plugin", version.ref = "protobuf-gradle" }
105+
grpc-api = { module = "io.grpc:grpc-api", version.ref = "grpc" }
105106
grpc-stub = { module = "io.grpc:grpc-stub", version.ref = "grpc" }
106107
grpc-util = { module = "io.grpc:grpc-util", version.ref = "grpc" }
107108
grpc-netty = { module = "io.grpc:grpc-netty", version.ref = "grpc" }

0 commit comments

Comments
 (0)