11package io .avaje .prism .internal ;
22
33import java .io .PrintWriter ;
4- import java .util .regex .Pattern ;
54
65public class ModuleInfoReaderWriter {
76 private ModuleInfoReaderWriter () {}
@@ -212,7 +211,7 @@ public static void write(PrintWriter out, String packageName) {
212211 + " * @param providesType the provides directive to check\n "
213212 + " * @param implementations the implementations to verify the presence of\n "
214213 + " */\n "
215- + " public void validateServices(String providesType, Collection<String> implementations) {\n "
214+ + " public void validateServices(String providesType, Collection<String> implementations) {\n "
216215 + " if (buildPluginAvailable() || moduleElement.isUnnamed() || APContext.isTestCompilation()) {\n "
217216 + " return;\n "
218217 + " }\n "
@@ -232,7 +231,7 @@ public static void write(PrintWriter out, String packageName) {
232231 + " } catch (Exception e) {\n "
233232 + " // not a critical error\n "
234233 + " }\n "
235- + " final var missingImpls = implSet.stream().map(this::replace$).collect(toSet());\n "
234+ + " final var missingImpls = implSet.stream().map(this::replace$).filter(this::isSameModule). collect(toSet());\n "
236235 + "\n "
237236 + " provides()\n "
238237 + " .forEach(\n "
@@ -255,6 +254,15 @@ public static void write(PrintWriter out, String packageName) {
255254 + " }\n "
256255 + " }\n "
257256 + "\n "
257+ + " private boolean isSameModule(String type) {\n "
258+ + " var element = APContext.typeElement(type);\n "
259+ + " return element != null\n "
260+ + " && APContext.elements()\n "
261+ + " .getModuleOf(element)\n "
262+ + " .getSimpleName()\n "
263+ + " .contentEquals(moduleElement.getSimpleName());\n "
264+ + " }\n "
265+ + "\n "
258266 + " private static boolean buildPluginAvailable() {\n "
259267 + " return isPresent(\" avaje-plugin-exists.txt\" );\n "
260268 + " }\n "
0 commit comments