Skip to content

Commit a3a4410

Browse files
authored
Log Error on Empty Scope instead of Failing (#687)
* log an error on empty instead of failing * Update DBeanScopeBuilder.java
1 parent 2872bdd commit a3a4410

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static java.lang.System.Logger.Level.INFO;
55
import static java.util.Collections.emptySet;
66

7+
import java.lang.System.Logger.Level;
78
import java.lang.reflect.Type;
89
import java.util.ArrayList;
910
import java.util.Arrays;
@@ -272,13 +273,6 @@ public BeanScope build() {
272273
}
273274

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

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

287+
if (moduleNames.isEmpty()) {
288+
log.log(
289+
Level.ERROR,
290+
"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");
291+
}
292+
293293
postConstructList.forEach(builder::addPostConstruct);
294294
postConstructConsumerList.forEach(builder::addPostConstruct);
295-
for (ClosePair closePair : preDestroyList) {
295+
for (var closePair : preDestroyList) {
296296
builder.addPreDestroy(closePair.closeable(), closePair.priority());
297297
}
298298
return builder.build(shutdownHook, start);

0 commit comments

Comments
 (0)