Skip to content

Commit 0376fb9

Browse files
committed
#31 - Throw useful error when Gradle + IDEA setup issue detected
1 parent 71318bc commit 0376fb9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<dependency>
5151
<groupId>io.dinject</groupId>
5252
<artifactId>dinject-generator</artifactId>
53-
<version>1.9</version>
53+
<version>1.10</version>
5454
<scope>test</scope>
5555
</dependency>
5656

src/main/java/io/dinject/BootContext.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ public BeanContext load() {
356356
ServiceLoader.load(BeanContextFactory.class).forEach(factoryOrder::add);
357357

358358
Set<String> moduleNames = factoryOrder.orderFactories();
359+
if (moduleNames.isEmpty()) {
360+
throw new IllegalStateException("No modules found suggests using Gradle and IDEA but with a setup issue?" +
361+
" Review IntelliJ Settings / Build / Build tools / Gradle - 'Build and run using' value and set that to 'Gradle'. " +
362+
" Refer to https://dinject.io/docs/gradle#idea");
363+
}
359364
log.debug("building context with modules {}", moduleNames);
360365

361366
Builder rootBuilder = BuilderFactory.newRootBuilder(suppliedBeans, enrichBeans);

src/test/java/org/example/coffee/BootContextAddTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class BootContextAddTest {
1212

13-
@Test
13+
@Test(expected = IllegalStateException.class)
1414
public void withModules_exludingThisOne() {
1515

1616
TDPump testDoublePump = new TDPump();

0 commit comments

Comments
 (0)