Skip to content

Fix Module Validation #740

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions inject-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>avaje inject generator</name>
<description>annotation processor generating source code for avaje-inject dependency injection</description>
<properties>
<avaje.prisms.version>1.35</avaje.prisms.version>
<avaje.prisms.version>1.36</avaje.prisms.version>
<!-- VALHALLA-START ___
<maven.compiler.enablePreview>false</maven.compiler.enablePreview>
____ VALHALLA-END -->
Expand All @@ -39,15 +39,15 @@
<artifactId>avaje-spi-service</artifactId>
<version>2.8</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-api</artifactId>
<version>2.8</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.avaje</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static final class Ctx {
private final List<ModuleData> modules = new ArrayList<>();
private final List<TypeElement> delayQueue = new ArrayList<>();
private final Set<String> spiServices = new TreeSet<>();
private final Set<String> externalSpi = new TreeSet<>();
private boolean strictWiring;
private final boolean mergeServices = APContext.getOption("mergeServices").map(Boolean::valueOf).orElse(true);

Expand All @@ -49,7 +50,7 @@ static void registerProvidedTypes(Set<String> moduleFileProvided) {
private static void addEventSPI() {
try {
if (typeElement(EVENTS_SPI) != null || Class.forName(EVENTS_SPI) != null) {
addInjectSPI(EVENTS_SPI);
addExternalInjectSPI(EVENTS_SPI);
}
} catch (final ClassNotFoundException e) {
// nothing
Expand Down Expand Up @@ -107,7 +108,7 @@ static void addInjectSPI(String type) {

static void addExternalInjectSPI(String type) {
if (CTX.get().mergeServices) {
CTX.get().spiServices.add(type);
CTX.get().externalSpi.add(type);
}
}

Expand Down Expand Up @@ -158,10 +159,11 @@ static void addImportedAspects(Map<String, AspectImportPrism> importedMap) {
}

static void validateModule() {
APContext.moduleInfoReader().ifPresent(reader -> {
CTX.get().spiServices.remove(EVENTS_SPI);
reader.validateServices("io.avaje.inject.spi.InjectExtension", CTX.get().spiServices);
});
APContext.moduleInfoReader()
.ifPresent(
reader ->
reader.validateServices(
"io.avaje.inject.spi.InjectExtension", CTX.get().spiServices));
}

static Optional<AspectImportPrism> getImportedAspect(String type) {
Expand Down Expand Up @@ -220,7 +222,8 @@ static void writeSPIServicesFile() {
FileObject jfo = createMetaInfWriterFor(Constants.META_INF_SPI);
if (jfo != null) {
var writer = new Append(jfo.openWriter());
for (var service : CTX.get().spiServices) {
CTX.get().externalSpi.addAll(CTX.get().spiServices);
for (var service : CTX.get().externalSpi) {
writer.append(service).eol();
}
writer.close();
Expand All @@ -244,7 +247,7 @@ private static void readExistingMetaInfServices() {
line.replaceAll("\\s", "")
.replace(",", "\n")
.lines()
.forEach(ProcessingContext::addInjectSPI);
.forEach(ProcessingContext::addExternalInjectSPI);
}
} catch (Exception e) {
// not a critical error
Expand Down
Loading