Skip to content

Commit d26fe1f

Browse files
committed
[java] Adding information about used services to generated module info file
1 parent e89b7d4 commit d26fe1f

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

java/client/src/org/openqa/selenium/remote/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ java_export(
6060
],
6161
maven_coordinates = "org.seleniumhq.selenium:selenium-remote-driver:%s" % SE_VERSION,
6262
pom_template = "//java/client/src/org/openqa/selenium:template-pom",
63+
module_uses_services = [
64+
"io.opentracing.Tracer",
65+
"org.openqa.selenium.remote.session.CapabilitiesFilter",
66+
"org.openqa.selenium.remote.session.CapabilityTransform",
67+
"org.openqa.selenium.remote.service.DriverService$Builder",
68+
],
6369
visibility = ["//visibility:public"],
6470
exports = [
6571
":api",
@@ -80,7 +86,6 @@ java_export(
8086
"//java/client/src/org/openqa/selenium/io",
8187
"//java/client/src/org/openqa/selenium/os",
8288
"//java/client/src/org/openqa/selenium/remote/http/okhttp",
83-
"//java/client/src/org/openqa/selenium/remote/http/netty",
8489
"//third_party/java/bytebuddy:byte-buddy",
8590
"//third_party/java/guava",
8691
],

java/client/src/org/openqa/selenium/tools/modules/ModuleGenerator.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public static void main(String[] args) throws IOException {
8888
String modulePath = null;
8989
String coordinates = null;
9090
Set<Pattern> excludes = new HashSet<>();
91+
Set<String> uses = new HashSet<>();
9192

9293
for (int i = 0; i < args.length; i++) {
9394
String flag = args[i];
@@ -97,6 +98,10 @@ public static void main(String[] args) throws IOException {
9798
coordinates = next;
9899
break;
99100

101+
case "--uses":
102+
uses.add(next);
103+
break;
104+
100105
case "--exclude":
101106
excludes.add(Pattern.compile(next));
102107
break;
@@ -190,7 +195,10 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
190195
ModuleDeclaration moduleDeclaration = unit.getModule()
191196
.orElseThrow(() -> new RuntimeException("No module declaration in " + moduleInfo.get()));
192197

193-
moduleDeclaration = moduleDeclaration.setName(moduleName);
198+
moduleDeclaration.setName(moduleName);
199+
200+
uses.forEach(
201+
service -> moduleDeclaration.addDirective(new ModuleUsesDirective(new Name(service))));
194202

195203
// Prepare a classloader to help us find classes.
196204
ClassLoader classLoader;

java/private/export.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def java_export(
77
name,
88
maven_coordinates,
99
pom_template,
10+
module_uses_services = [],
1011
module_exclude_patterns = [
1112
".*\\.internal.*",
1213
],
@@ -26,6 +27,7 @@ def java_export(
2627
name = name,
2728
tags = actual_tags,
2829
maven_coordinates = maven_coordinates,
30+
module_uses_services = module_uses_services,
2931
module_exclude_patterns = module_exclude_patterns,
3032
target = "%s-base-lib" % name,
3133
binjar = "%s-binary.jar" % name,

java/private/maven_artifacts.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def _maven_artifacts_impl(ctx):
1818
args.add_all(["--coordinates", ctx.attr.maven_coordinates])
1919
args.add_all(["--in", temp_bin_jar.path])
2020
args.add_all(["--out", module_jar.path])
21+
if len(ctx.attr.module_uses_services) > 0:
22+
args.add_all(ctx.attr.module_uses_services, before_each = "--uses")
2123

2224
paths = [file.path for file in target[GatheredJavaModuleInfo].module_jars.to_list()]
2325
if len(paths) > 0:
@@ -66,6 +68,9 @@ maven_artifacts = rule(
6668
aspects = [has_java_module_deps, has_maven_deps],
6769
providers = [GatheredJavaModuleInfo, JavaInfo],
6870
),
71+
"module_uses_services": attr.string_list(
72+
default = [],
73+
),
6974
"module_exclude_patterns": attr.string_list(
7075
default = [],
7176
),

0 commit comments

Comments
 (0)