Skip to content

Commit f09188d

Browse files
committed
support a main package called avaje
now generated module classes will not have the name `AvajeModule` when the package is `avaje`, which clashes with the class of the same name that it extends
1 parent 1256800 commit f09188d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

inject-generator/src/main/java/io/avaje/inject/generator/ScopeUtil.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ final class ScopeUtil {
44

55
static String initName(String name) {
66
name = name(name);
7-
return "Inject".equals(name) ? "DInject" : name;
7+
8+
if (name == null) {
9+
return null;
10+
}
11+
12+
switch (name) {
13+
case "Inject":
14+
return "DInject";
15+
case "Avaje":
16+
return "AvajeInject";
17+
default:
18+
return name;
19+
}
820
}
921

1022
static String name(String name) {

inject-generator/src/test/java/io/avaje/inject/generator/ScopeUtilTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.avaje.inject.generator;
22

3-
import org.junit.jupiter.api.Test;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
44

5-
import static org.junit.jupiter.api.Assertions.*;
5+
import org.junit.jupiter.api.Test;
66

77
class ScopeUtilTest {
88

@@ -21,6 +21,13 @@ void initName_inject() {
2121
assertEquals("Foo", ScopeUtil.initName("org.example.foo"));
2222
}
2323

24+
@Test
25+
void initName_avaje() {
26+
// resulting module can't be InjectModule as that clashes with @InjectModule
27+
assertEquals("AvajeInject", ScopeUtil.initName("org.example.avaje"));
28+
assertEquals("Foo", ScopeUtil.initName("org.example.foo"));
29+
}
30+
2431
@Test
2532
void name_withSpace() {
2633
assertEquals("ExAmple", ScopeUtil.name("org.ex ample"));

0 commit comments

Comments
 (0)