Skip to content

Support a main package called avaje #832

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 3 commits into from
Jun 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ final class ScopeUtil {

static String initName(String name) {
name = name(name);
return "Inject".equals(name) ? "DInject" : name;
if (name == null) {
return null;
}
switch (name) {
case "Inject":
return "DInject";
case "Avaje":
return "AvajeInject";
default:
return name;
}
}

static String name(String name) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.avaje.inject.generator;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

class ScopeUtilTest {

Expand All @@ -12,13 +13,24 @@ void name() {
assertEquals("Example", ScopeUtil.name("org.Example"));
assertEquals("Example", ScopeUtil.name("example"));
assertEquals("Example", ScopeUtil.name("Example"));
assertEquals("Example", ScopeUtil.name("ExampleScope"));
assertEquals("Example", ScopeUtil.name("ExampleModule"));
assertNull(ScopeUtil.name(null));
}

@Test
void initName_inject() {
// resulting module can't be InjectModule as that clashes with @InjectModule
assertEquals("DInject", ScopeUtil.initName("org.example.inject"));
assertEquals("Foo", ScopeUtil.initName("org.example.foo"));
assertNull(ScopeUtil.initName(null));
}

@Test
void initName_avaje() {
// resulting module can't be InjectModule as that clashes with @InjectModule
assertEquals("AvajeInject", ScopeUtil.initName("org.example.avaje"));
assertEquals("Foo", ScopeUtil.initName("org.example.foo"));
}

@Test
Expand Down