Skip to content

Log Error on Empty Scope instead of Failing #687

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2024
Merged
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
16 changes: 8 additions & 8 deletions inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static java.lang.System.Logger.Level.INFO;
import static java.util.Collections.emptySet;

import java.lang.System.Logger.Level;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -272,13 +273,6 @@ public BeanScope build() {
}

final var moduleNames = factoryOrder.orderModules();
if (moduleNames.isEmpty()) {
throw new IllegalStateException(
"Could not find any avaje modules."
+ " Perhaps using Gradle and IDEA but with a setup issue?"
+ " Review IntelliJ Settings / Build / Build tools / Gradle - 'Build and run using' value and set that to 'Gradle'. "
+ " Refer to https://avaje.io/inject#gradle");
}

final var level = propertyPlugin.contains("printModules") ? INFO : DEBUG;
initProfiles();
Expand All @@ -290,9 +284,15 @@ public BeanScope build() {
factory.build(builder);
}

if (moduleNames.isEmpty()) {
log.log(
Level.ERROR,
"Could not find any AvajeModule instances to wire. Possible Causes: \n1. No beans have been defined.\n2. The avaje-inject-generator depedency was not available during compilation\n3. Perhaps using Gradle and a misconfigured IDE? Refer to https://avaje.io/inject#gradle");
}

postConstructList.forEach(builder::addPostConstruct);
postConstructConsumerList.forEach(builder::addPostConstruct);
for (ClosePair closePair : preDestroyList) {
for (var closePair : preDestroyList) {
builder.addPreDestroy(closePair.closeable(), closePair.priority());
}
return builder.build(shutdownHook, start);
Expand Down