mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[libraries] IJPL-204102 Reuse grpc libraries where possible
GitOrigin-RevId: e548ed89f4f9e1d0240472930f940ef3cdfcc5d4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c017cf9b49
commit
6532f67231
@@ -9,12 +9,17 @@ jvm_resources(
|
||||
|
||||
jvm_library(
|
||||
name = "grpc-netty-shaded",
|
||||
module_name = "intellij.libraries.grpc.netty.shaded",
|
||||
visibility = ["//visibility:public"],
|
||||
srcs = glob([], allow_empty = True),
|
||||
exports = ["@lib//:grpc-netty-shaded"],
|
||||
runtime_deps = [
|
||||
":grpc-netty-shaded_resources",
|
||||
srcs = glob(["src/**/*.kt", "src/**/*.java", "src/**/*.form"], allow_empty = True),
|
||||
deps = [
|
||||
"@lib//:grpc-netty-shaded",
|
||||
]
|
||||
"@lib//:kotlin-stdlib",
|
||||
"//platform/util",
|
||||
"//platform/core-api:core",
|
||||
"//libraries/grpc",
|
||||
],
|
||||
exports = ["@lib//:grpc-netty-shaded"],
|
||||
runtime_deps = [":grpc-netty-shaded_resources"]
|
||||
)
|
||||
### auto-generated section `build intellij.libraries.grpc.netty.shaded` end
|
||||
@@ -4,9 +4,14 @@
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="grpc-netty-shaded" level="project" />
|
||||
<orderEntry type="library" name="kotlin-stdlib" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core" />
|
||||
<orderEntry type="module" module-name="intellij.libraries.grpc" />
|
||||
</component>
|
||||
</module>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.intellij.libraries.grpc.netty.shaded
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.service
|
||||
import io.grpc.ManagedChannelRegistry
|
||||
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* [ManagedChannelRegistry.getDefaultRegistry] has the ability to discover available [io.grpc.ManagedChannelProvider] subclasses.
|
||||
* However, [ManagedChannelRegistry] uses a classloader that has no access to [NettyChannelProvider],
|
||||
* because intellij.libraries.grpc module does not depend on intellij.libraries.grpc.netty.shaded,
|
||||
* so automatic discovery fails.
|
||||
*/
|
||||
@Service(Service.Level.APP)
|
||||
@ApiStatus.Experimental
|
||||
class NettyChannelProviderRegistrationService : Disposable {
|
||||
private val registry = ManagedChannelRegistry.getDefaultRegistry()
|
||||
private val channelProvider = NettyChannelProvider()
|
||||
|
||||
init {
|
||||
registry.register(channelProvider)
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
registry.deregister(channelProvider)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun ensureChannelProviderRegistered() {
|
||||
service<NettyChannelProviderRegistrationService>()
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-32
@@ -4,17 +4,13 @@ package com.intellij.execution.process.mediator.client.launcher
|
||||
import com.intellij.execution.process.mediator.client.ProcessMediatorClient
|
||||
import com.intellij.execution.process.mediator.common.DaemonClientCredentials
|
||||
import com.intellij.execution.process.mediator.daemon.ProcessMediatorServerDaemon
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.libraries.grpc.netty.shaded.NettyChannelProviderRegistrationService
|
||||
import com.intellij.util.io.MultiCloseable
|
||||
import com.intellij.util.io.runClosingOnFailure
|
||||
import io.grpc.ManagedChannel
|
||||
import io.grpc.ManagedChannelBuilder
|
||||
import io.grpc.ManagedChannelRegistry
|
||||
import io.grpc.inprocess.InProcessChannelBuilder
|
||||
import io.grpc.inprocess.InProcessServerBuilder
|
||||
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider
|
||||
import io.grpc.stub.MetadataUtils
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import java.io.Closeable
|
||||
@@ -80,30 +76,3 @@ private class ConnectionImpl(
|
||||
) : ProcessMediatorConnection, Closeable, AutoCloseable by cleanup {
|
||||
override fun toString(): String = "Connection(client=$client)"
|
||||
}
|
||||
|
||||
/**
|
||||
* [ManagedChannelRegistry.getDefaultRegistry] has the ability to discover available [io.grpc.ManagedChannelProvider] subclasses.
|
||||
* However, [ManagedChannelRegistry]
|
||||
* uses a classloader that has no access to [NettyChannelProvider],
|
||||
* because intellij.libraries.grpc module does not depend on intellij.libraries.grpc.netty.shaded,
|
||||
* so automatic discovery fails.
|
||||
*/
|
||||
@Service(Service.Level.APP)
|
||||
private class NettyChannelProviderRegistrationService : Disposable {
|
||||
private val registry = ManagedChannelRegistry.getDefaultRegistry()
|
||||
private val channelProvider = NettyChannelProvider()
|
||||
|
||||
init {
|
||||
registry.register(channelProvider)
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
registry.deregister(channelProvider)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun ensureChannelProviderRegistered() {
|
||||
service<NettyChannelProviderRegistrationService>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@
|
||||
|
||||
<module name="intellij.platform.langInjection"/>
|
||||
<module name="intellij.platform.langInjection.backend"/>
|
||||
|
||||
<module name="intellij.libraries.grpc"/>
|
||||
<module name="intellij.libraries.grpc.netty.shaded"/>
|
||||
</content>
|
||||
|
||||
<xi:include href="/META-INF/grid-core-modules.xml"/>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<idea-plugin>
|
||||
<content>
|
||||
<module name="intellij.libraries.grpc"/>
|
||||
<module name="intellij.libraries.grpc.netty.shaded"/>
|
||||
<module name="intellij.execution.process.elevation"/>
|
||||
<module name="intellij.execution.process.mediator.client"/>
|
||||
<module name="intellij.execution.process.mediator.common"/>
|
||||
|
||||
@@ -46,28 +46,6 @@
|
||||
- name: intellij.grazie.properties
|
||||
- name: intellij.grazie.xml
|
||||
- name: intellij.grazie.yaml
|
||||
- name: lib/grpc-core.jar
|
||||
library: grpc-core
|
||||
files:
|
||||
- name: $MAVEN_REPOSITORY$/io/grpc/grpc-core/1/grpc-core-1.jar
|
||||
- name: $MAVEN_REPOSITORY$/io/grpc/grpc-api/1/grpc-api-1.jar
|
||||
- name: $MAVEN_REPOSITORY$/com/google/android/annotations/4/annotations-4.jar
|
||||
- name: $MAVEN_REPOSITORY$/org/codehaus/mojo/animal-sniffer-annotations/1/animal-sniffer-annotations-1.jar
|
||||
- name: $MAVEN_REPOSITORY$/io/perfmark/perfmark-api/0/perfmark-api-0.jar
|
||||
- name: $MAVEN_REPOSITORY$/io/grpc/grpc-context/1/grpc-context-1.jar
|
||||
reason: <- intellij.grazie.core
|
||||
- name: lib/grpc-protobuf.jar
|
||||
library: grpc-protobuf
|
||||
files:
|
||||
- name: $MAVEN_REPOSITORY$/io/grpc/grpc-protobuf/1/grpc-protobuf-1.jar
|
||||
- name: $MAVEN_REPOSITORY$/com/google/api/grpc/proto-google-common-protos/2/proto-google-common-protos-2.jar
|
||||
- name: $MAVEN_REPOSITORY$/io/grpc/grpc-protobuf-lite/1/grpc-protobuf-lite-1.jar
|
||||
reason: <- intellij.grazie.core
|
||||
- name: lib/grpc-stub.jar
|
||||
library: grpc-stub
|
||||
files:
|
||||
- name: $MAVEN_REPOSITORY$/io/grpc/grpc-stub/1/grpc-stub-1.jar
|
||||
reason: <- intellij.grazie.core
|
||||
- name: lib/javax.measure-unit-api.jar
|
||||
library: javax.measure:unit-api:1.0
|
||||
module: intellij.grazie.core
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<module name="intellij.libraries.ai.grazie.spell.gec.engine.local"/>
|
||||
<module name="intellij.spellchecker"/>
|
||||
<module name="intellij.platform.vcs.impl"/>
|
||||
<module name="intellij.libraries.grpc"/>
|
||||
</dependencies>
|
||||
|
||||
<content>
|
||||
|
||||
@@ -73,6 +73,7 @@ jvm_library(
|
||||
"//platform/util/coroutines",
|
||||
"//platform/util/progress",
|
||||
"//platform/util/text-matching",
|
||||
"//libraries/grpc",
|
||||
],
|
||||
exports = [
|
||||
"@lib//:grazie-core-org-jetbrains-intellij-deps-languagetool-languagetool-core",
|
||||
@@ -86,9 +87,6 @@ jvm_library(
|
||||
"@lib//:guava",
|
||||
"@lib//:jetbrains-annotations",
|
||||
"@lib//:commons-lang3",
|
||||
"@lib//:grpc-core",
|
||||
"@lib//:grpc-protobuf",
|
||||
"@lib//:grpc-stub",
|
||||
]
|
||||
)
|
||||
### auto-generated section `build intellij.grazie.core` end
|
||||
@@ -407,10 +407,8 @@
|
||||
<orderEntry type="library" name="kotlinx-html-jvm" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="commons-lang3" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="grpc-core" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="grpc-protobuf" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="grpc-stub" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.progress" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.text.matching" />
|
||||
<orderEntry type="module" module-name="intellij.libraries.grpc" />
|
||||
</component>
|
||||
</module>
|
||||
Reference in New Issue
Block a user