Skip to content

Commit 21503a0

Browse files
authored
Fixing module-info.java files so that gRPC works when using Java modules (helidon-io#4235)
1 parent 13de675 commit 21503a0

7 files changed

Lines changed: 93 additions & 4 deletions

File tree

config/config/src/main/java/module-info.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2022 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,4 +47,6 @@
4747

4848
provides io.helidon.config.spi.ConfigParser with PropertiesConfigParser;
4949

50+
// needed when running with modules - to make private methods accessible
51+
opens io.helidon.config to weld.core.impl, io.helidon.microprofile.cdi;
5052
}

dependencies/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
<version.lib.opentracing>0.33.0</version.lib.opentracing>
138138
<version.lib.opentracing.grpc>0.2.1</version.lib.opentracing.grpc>
139139
<version.lib.opentracing.tracerresolver>0.1.8</version.lib.opentracing.tracerresolver>
140+
<version.lib.perfmark-api>0.23.0</version.lib.perfmark-api>
140141
<version.lib.postgresql>42.3.3</version.lib.postgresql>
141142
<version.lib.prometheus>0.9.0</version.lib.prometheus>
142143
<version.lib.slf4j>1.7.32</version.lib.slf4j>
@@ -494,6 +495,12 @@
494495
<artifactId>gson</artifactId>
495496
<version>${version.lib.gson}</version>
496497
</dependency>
498+
<!-- Dependency convergence. Should align with version used by io.grpc -->
499+
<dependency>
500+
<groupId>io.perfmark</groupId>
501+
<artifactId>perfmark-api</artifactId>
502+
<version>${version.lib.perfmark-api}</version>
503+
</dependency>
497504

498505
<dependency>
499506
<groupId>io.opentracing.contrib</groupId>

grpc/io.grpc/pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,33 @@
4545
<groupId>io.grpc</groupId>
4646
<artifactId>grpc-context</artifactId>
4747
</dependency>
48+
49+
<dependency>
50+
<groupId>com.google.guava</groupId>
51+
<artifactId>guava</artifactId>
52+
<exclusions>
53+
<exclusion>
54+
<artifactId>jsr305</artifactId>
55+
<groupId>com.google.code.findbugs</groupId>
56+
</exclusion>
57+
<exclusion>
58+
<artifactId>error_prone_annotations</artifactId>
59+
<groupId>com.google.errorprone</groupId>
60+
</exclusion>
61+
<exclusion>
62+
<artifactId>j2objc-annotations</artifactId>
63+
<groupId>com.google.j2objc</groupId>
64+
</exclusion>
65+
</exclusions>
66+
</dependency>
67+
<dependency>
68+
<groupId>com.google.code.gson</groupId>
69+
<artifactId>gson</artifactId>
70+
</dependency>
71+
<dependency>
72+
<groupId>io.perfmark</groupId>
73+
<artifactId>perfmark-api</artifactId>
74+
</dependency>
4875
</dependencies>
4976

5077
<build>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2022 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.grpc.util;
18+
19+
import io.grpc.LoadBalancerProvider;
20+
21+
/**
22+
* A dummy class to allow the re-packaging of grpc-java
23+
* with a module-info.java file to work.
24+
* <p>
25+
* This file will be replaced by the real implementation from grpc-java
26+
* as part of the re-packaging process.
27+
*/
28+
public class SecretRoundRobinLoadBalancerProvider {
29+
/**
30+
* A dummy {@link LoadBalancerProvider} implementation to allow
31+
* the provides statement to be added to the module-info file.
32+
*/
33+
public static class Provider
34+
extends LoadBalancerProvider {
35+
}
36+
}

grpc/io.grpc/src/main/java/module-info.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,12 +23,22 @@
2323
exports io.grpc.internal;
2424
exports io.grpc.util;
2525

26+
requires com.google.common;
27+
requires com.google.gson;
2628
requires java.logging;
2729
requires java.naming;
30+
requires perfmark.api;
2831

2932
uses io.grpc.ManagedChannelProvider;
3033
uses io.grpc.NameResolverProvider;
3134
uses io.grpc.ServerProvider;
3235
uses io.grpc.internal.BinaryLogProvider;
3336
uses io.grpc.LoadBalancerProvider;
37+
38+
provides io.grpc.LoadBalancerProvider
39+
with io.grpc.internal.PickFirstLoadBalancerProvider,
40+
io.grpc.util.SecretRoundRobinLoadBalancerProvider.Provider;
41+
42+
provides io.grpc.NameResolverProvider
43+
with io.grpc.internal.DnsNameResolverProvider;
3444
}

microprofile/grpc/client/src/main/java/module-info.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,4 +29,7 @@
2929

3030
provides jakarta.enterprise.inject.spi.Extension
3131
with io.helidon.microprofile.grpc.client.GrpcClientCdiExtension;
32+
33+
// needed when running with modules - to make private methods accessible
34+
opens io.helidon.microprofile.grpc.client to weld.core.impl, io.helidon.microprofile.cdi;
3235
}

microprofile/grpc/server/src/main/java/module-info.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,9 +33,13 @@
3333

3434
requires java.logging;
3535

36+
uses io.helidon.microprofile.grpc.server.spi.GrpcMpExtension;
3637
uses io.helidon.microprofile.grpc.server.GrpcServerCdiExtension;
3738
uses io.helidon.microprofile.grpc.server.AnnotatedServiceConfigurer;
3839

3940
provides jakarta.enterprise.inject.spi.Extension
4041
with io.helidon.microprofile.grpc.server.GrpcServerCdiExtension;
42+
43+
// needed when running with modules - to make private methods accessible
44+
opens io.helidon.microprofile.grpc.server to weld.core.impl, io.helidon.microprofile.cdi;
4145
}

0 commit comments

Comments
 (0)