|
1 | 1 | package io.avaje.inject.generator;
|
2 | 2 |
|
3 |
| -import java.net.URI; |
4 |
| -import java.nio.file.Files; |
5 |
| -import java.nio.file.Paths; |
| 3 | +import java.io.BufferedReader; |
| 4 | +import java.io.IOException; |
| 5 | +import java.io.InputStream; |
| 6 | +import java.io.InputStreamReader; |
| 7 | +import java.net.URL; |
6 | 8 | import java.util.HashSet;
|
7 | 9 | import java.util.LinkedHashSet;
|
8 | 10 | import java.util.ServiceLoader;
|
@@ -59,31 +61,37 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
|
59 | 61 | void loadProvidedFiles(Filer filer) {
|
60 | 62 |
|
61 | 63 | try {
|
62 |
| - final var resource = |
63 |
| - filer |
| 64 | + var resource = |
| 65 | + filer |
64 | 66 | .getResource(StandardLocation.CLASS_OUTPUT, "", "target/avaje-plugin-provides.txt")
|
65 | 67 | .toUri()
|
66 | 68 | .toString()
|
67 | 69 | .replace("/target/classes", "");
|
68 |
| - try (var lines = Files.lines(Paths.get(new URI(resource)))) { |
69 |
| - lines.forEach(pluginFileProvided::add); |
| 70 | + try (InputStream inputStream = new URL(resource).openStream(); |
| 71 | + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { |
| 72 | + String line; |
| 73 | + while ((line = reader.readLine()) != null) { |
| 74 | + pluginFileProvided.add(line); |
| 75 | + } |
70 | 76 | }
|
71 |
| - } catch (final Exception e) { |
72 |
| - // could not find avaje-plugin-provides.txt |
| 77 | + } catch (IOException e2) { |
73 | 78 | }
|
74 | 79 |
|
75 | 80 | try {
|
76 |
| - final var resource = |
77 |
| - filer |
| 81 | + var resource = |
| 82 | + filer |
78 | 83 | .getResource(StandardLocation.CLASS_OUTPUT, "", "target/avaje-module-provides.txt")
|
79 | 84 | .toUri()
|
80 | 85 | .toString()
|
81 | 86 | .replace("/target/classes", "");
|
82 |
| - try (var lines = Files.lines(Paths.get(new URI(resource)))) { |
83 |
| - lines.forEach(pluginFileProvided::add); |
| 87 | + try (InputStream inputStream = new URL(resource).openStream(); |
| 88 | + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { |
| 89 | + String line; |
| 90 | + while ((line = reader.readLine()) != null) { |
| 91 | + moduleFileProvided.add(line); |
| 92 | + } |
84 | 93 | }
|
85 |
| - } catch (final Exception e2) { |
86 |
| - // could not find avaje-module-provides.txt |
| 94 | + } catch (IOException e2) { |
87 | 95 | }
|
88 | 96 | }
|
89 | 97 |
|
|
0 commit comments