|
56 | 56 | import java.nio.file.Path;
|
57 | 57 | import java.nio.file.Paths;
|
58 | 58 | import java.nio.file.SimpleFileVisitor;
|
| 59 | +import java.nio.file.StandardCopyOption; |
59 | 60 | import java.nio.file.attribute.BasicFileAttributes;
|
60 | 61 | import java.util.Arrays;
|
61 | 62 | import java.util.Collection;
|
@@ -164,11 +165,28 @@ public static void main(String[] args) throws IOException {
|
164 | 165 | // It doesn't matter what we use for writing to the stream: jdeps doesn't use it. *facepalm*
|
165 | 166 | List<String> jdepsArgs = new LinkedList<>(List.of("--api-only", "--multi-release", "9"));
|
166 | 167 | if (!modulePath.isEmpty()) {
|
| 168 | + Path tmp = Files.createTempDirectory("automatic_module_jars"); |
167 | 169 | jdepsArgs.addAll(
|
168 | 170 | List.of(
|
169 | 171 | "--module-path",
|
170 | 172 | 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 | + }) |
172 | 190 | .collect(Collectors.joining(File.pathSeparator))));
|
173 | 191 | }
|
174 | 192 | jdepsArgs.addAll(List.of("--generate-module-info", temp.toAbsolutePath().toString()));
|
@@ -467,9 +485,9 @@ private static class MyModuleVisitor extends VoidVisitorAdapter<Void> {
|
467 | 485 | @Override
|
468 | 486 | public void visit(ModuleRequiresDirective n, Void arg) {
|
469 | 487 | String name = n.getNameAsString();
|
470 |
| - if (name.startsWith("processed_")) { |
| 488 | + if (name.startsWith("processed.")) { |
471 | 489 | // 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. |
473 | 491 | name = name.substring(10);
|
474 | 492 | }
|
475 | 493 | byteBuddyVisitor.visitRequire(name, getByteBuddyModifier(n.getModifiers()), null);
|
|
0 commit comments