Skip to content

Commit c3ecc3c

Browse files
joerg1985diemol
andauthored
[java] Really drop the prefix created by Bazel (#12264)
Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
1 parent 7c40c11 commit c3ecc3c

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

java/src/dev/selenium/tools/modules/ModuleGenerator.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import java.nio.file.Path;
5757
import java.nio.file.Paths;
5858
import java.nio.file.SimpleFileVisitor;
59+
import java.nio.file.StandardCopyOption;
5960
import java.nio.file.attribute.BasicFileAttributes;
6061
import java.util.Arrays;
6162
import java.util.Collection;
@@ -164,11 +165,28 @@ public static void main(String[] args) throws IOException {
164165
// It doesn't matter what we use for writing to the stream: jdeps doesn't use it. *facepalm*
165166
List<String> jdepsArgs = new LinkedList<>(List.of("--api-only", "--multi-release", "9"));
166167
if (!modulePath.isEmpty()) {
168+
Path tmp = Files.createTempDirectory("automatic_module_jars");
167169
jdepsArgs.addAll(
168170
List.of(
169171
"--module-path",
170172
modulePath.stream()
171-
.map(Object::toString)
173+
.map((s) -> {
174+
String file = s.getFileName().toString();
175+
176+
if (file.startsWith("processed_")) {
177+
Path copy = tmp.resolve(file.substring(10));
178+
179+
try {
180+
Files.copy(s, copy, StandardCopyOption.REPLACE_EXISTING);
181+
} catch (IOException e) {
182+
throw new UncheckedIOException(e);
183+
}
184+
185+
return copy.toString();
186+
}
187+
188+
return s.toString();
189+
})
172190
.collect(Collectors.joining(File.pathSeparator))));
173191
}
174192
jdepsArgs.addAll(List.of("--generate-module-info", temp.toAbsolutePath().toString()));
@@ -467,9 +485,9 @@ private static class MyModuleVisitor extends VoidVisitorAdapter<Void> {
467485
@Override
468486
public void visit(ModuleRequiresDirective n, Void arg) {
469487
String name = n.getNameAsString();
470-
if (name.startsWith("processed_")) {
488+
if (name.startsWith("processed.")) {
471489
// When 'Automatic-Module-Name' is not set, we must derive the module name from the jar file
472-
// name. Therefore, the 'processed_' prefix added by bazel must be removed to get the name.
490+
// name. Therefore, the 'processed.' prefix added by bazel must be removed to get the name.
473491
name = name.substring(10);
474492
}
475493
byteBuddyVisitor.visitRequire(name, getByteBuddyModifier(n.getModifiers()), null);

0 commit comments

Comments
 (0)