|
1 | 1 | package io.avaje.jsonb.generator; |
2 | 2 |
|
3 | 3 | import static io.avaje.jsonb.generator.APContext.filer; |
4 | | -import static io.avaje.jsonb.generator.APContext.getModuleInfoReader; |
5 | 4 | import static io.avaje.jsonb.generator.APContext.getProjectModuleElement; |
6 | 5 | import static io.avaje.jsonb.generator.APContext.jdkVersion; |
7 | 6 | import static io.avaje.jsonb.generator.APContext.logError; |
8 | 7 | import static io.avaje.jsonb.generator.APContext.logWarn; |
9 | | - |
10 | 8 | import java.io.BufferedReader; |
11 | 9 | import java.io.IOException; |
12 | 10 | import java.io.InputStreamReader; |
@@ -86,31 +84,31 @@ private static boolean buildPluginAvailable() { |
86 | 84 |
|
87 | 85 | static void validateModule() { |
88 | 86 | var module = getProjectModuleElement(); |
89 | | - if (module != null && !module.isUnnamed()) { |
90 | | - var injectPresent = CTX.get().injectPresent; |
91 | | - |
92 | | - try (var reader = getModuleInfoReader()) { |
93 | | - var moduleInfo = new ModuleInfoReader(module, reader); |
94 | 87 |
|
95 | | - moduleInfo.validateServices("io.avaje.jsonb.spi.JsonbExtension", CTX.get().services); |
| 88 | + var injectPresent = CTX.get().injectPresent; |
96 | 89 |
|
97 | | - boolean noInjectPlugin = |
98 | | - injectPresent && !moduleInfo.containsOnModulePath("io.avaje.jsonb.plugin"); |
| 90 | + APContext.moduleInfoReader() |
| 91 | + .ifPresent( |
| 92 | + moduleInfo -> { |
| 93 | + moduleInfo.validateServices("io.avaje.jsonb.spi.JsonbExtension", CTX.get().services); |
99 | 94 |
|
100 | | - var buildPluginAvailable = buildPluginAvailable(); |
| 95 | + boolean noInjectPlugin = |
| 96 | + injectPresent && !moduleInfo.containsOnModulePath("io.avaje.jsonb.plugin"); |
101 | 97 |
|
102 | | - final var noDirectJsonb = |
103 | | - moduleInfo.requires().stream() |
104 | | - .noneMatch(r -> r.getDependency().getQualifiedName().contentEquals("io.avaje.jsonb")); |
| 98 | + var buildPluginAvailable = buildPluginAvailable(); |
105 | 99 |
|
106 | | - if (noInjectPlugin && (!buildPluginAvailable || noDirectJsonb)) { |
107 | | - logWarn(module, "`requires io.avaje.jsonb.plugin` must be explicitly added or else avaje-inject may fail to detect and wire the default Jsonb instance"); |
108 | | - } |
| 100 | + final var noDirectJsonb = |
| 101 | + moduleInfo.requires().stream() |
| 102 | + .noneMatch( |
| 103 | + r -> |
| 104 | + r.getDependency().getQualifiedName().contentEquals("io.avaje.jsonb")); |
109 | 105 |
|
110 | | - } catch (Exception e) { |
111 | | - // can't read module |
112 | | - } |
113 | | - } |
| 106 | + if (noInjectPlugin && (!buildPluginAvailable || noDirectJsonb)) { |
| 107 | + logWarn( |
| 108 | + module, |
| 109 | + "`requires io.avaje.jsonb.plugin` must be explicitly added or else avaje-inject may fail to detect and wire the default Jsonb instance"); |
| 110 | + } |
| 111 | + }); |
114 | 112 | } |
115 | 113 |
|
116 | 114 | static void addJsonSpi(String spi) { |
|
0 commit comments