Skip to content

Commit b1fbe51

Browse files
committed
Merge branch 'master' of github.com:avaje/avaje-inject
2 parents bcc192c + 326d0f0 commit b1fbe51

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

inject-generator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<name>avaje inject generator</name>
1414
<description>annotation processor generating source code for avaje-inject dependency injection</description>
1515
<properties>
16-
<avaje.prisms.version>1.32</avaje.prisms.version>
16+
<avaje.prisms.version>1.33</avaje.prisms.version>
1717
<!-- VALHALLA-START ___
1818
<maven.compiler.enablePreview>false</maven.compiler.enablePreview>
1919
____ VALHALLA-END -->

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ final class TypeExtendsReader {
2222
private static final Set<String> ROUTE_TYPES = Set.of(
2323
"io.avaje.http.api.AvajeJavalinPlugin",
2424
"io.helidon.webserver.http.HttpFeature");
25-
26-
private static final String JAVA_LANG_OBJECT = "java.lang.Object";
27-
private static final String JAVA_LANG_RECORD = "java.lang.Record";
2825
private final UType baseUType;
2926
private final TypeElement baseType;
3027
private final TypeExtendsInjection extendsInjection;
@@ -203,7 +200,7 @@ private String initProvidesAspect() {
203200
private void addSuperType(TypeElement element, TypeMirror mirror, boolean proxyBean) {
204201
readInterfaces(element);
205202
final String fullName = mirror.toString();
206-
if (!JAVA_LANG_OBJECT.equals(fullName) && !JAVA_LANG_RECORD.equals(fullName)) {
203+
if (Util.notJavaLang(fullName)) {
207204
final String type = Util.unwrapProvider(fullName);
208205

209206
if (proxyBean || isPublic(element)) {
@@ -226,38 +223,36 @@ private void addSuperType(TypeElement element, TypeMirror mirror, boolean proxyB
226223
}
227224

228225
private void readInterfaces(TypeElement type) {
229-
for (final TypeMirror anInterface : type.getInterfaces()) {
230-
if (isPublic(asElement(anInterface))) {
231-
readInterfacesOf(anInterface);
226+
if (Util.notJavaLang(type.getQualifiedName().toString())) {
227+
for (final TypeMirror anInterface : type.getInterfaces()) {
228+
if (isPublic(asElement(anInterface))) {
229+
readInterfacesOf(anInterface);
230+
}
232231
}
233232
}
234233
}
235234

236235
private void readInterfacesOf(TypeMirror anInterface) {
237-
final String rawType = Util.unwrapProvider(anInterface.toString());
238-
final UType rawUType = Util.unwrapProvider(anInterface);
239-
if (JAVA_LANG_OBJECT.equals(rawType)) {
240-
// we can stop
241-
return;
242-
}
243-
if (rawType.indexOf('.') == -1) {
244-
logWarn("skip when no package on interface " + rawType);
245-
} else if (Constants.AUTO_CLOSEABLE.equals(rawType) || Constants.IO_CLOSEABLE.equals(rawType)) {
236+
final String rawType = Util.unwrapProvider(anInterface.toString());
237+
final UType rawUType = Util.unwrapProvider(anInterface);
238+
if (Constants.AUTO_CLOSEABLE.equals(rawType) || Constants.IO_CLOSEABLE.equals(rawType)) {
246239
closeable = true;
240+
} else if (!Util.notJavaLang(rawType)) {
241+
// return
242+
} else if (rawType.indexOf('.') == -1) {
243+
logWarn("skip when no package on interface " + rawType);
247244
} else {
248245
if (qualifierName == null) {
249246
final String mainType = rawUType.mainType();
250-
final String iShortName = Util.shortName(mainType);
251-
if (beanSimpleName.endsWith(iShortName)) {
247+
final String shortName = Util.shortName(mainType);
248+
if (beanSimpleName.endsWith(shortName)) {
252249
// derived qualifier name based on prefix to interface short name
253-
qualifierName = beanSimpleName.substring(0, beanSimpleName.length() - iShortName.length());
250+
qualifierName = beanSimpleName.substring(0, beanSimpleName.length() - shortName.length());
254251
}
255252
}
256253
interfaceTypes.add(rawUType);
257-
if (Util.notJavaLang(rawType)) {
258-
for (final TypeMirror supertype : types().directSupertypes(anInterface)) {
259-
readInterfacesOf(supertype);
260-
}
254+
for (final TypeMirror supertype : types().directSupertypes(anInterface)) {
255+
readInterfacesOf(supertype);
261256
}
262257
}
263258
}

inject-gradle-plugin/src/main/java/io/avaje/inject/plugin/AvajeInjectPlugin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public class AvajeInjectPlugin implements Plugin<Project> {
3030
public void apply(Project project) {
3131
project.afterEvaluate(
3232
prj -> {
33-
// run it automatically after clean
34-
Task cleanTask = prj.getTasks().getByName("clean");
35-
cleanTask.doLast(it -> writeProvides(project));
33+
// run it automatically before build
34+
Task buildTask = prj.getTasks().getByName("build");
35+
buildTask.doFirst(it -> writeProvides(project));
3636
});
3737
// register a task to run it manually
3838
project.task("discoverModules").doLast(task -> writeProvides(project));
@@ -110,7 +110,7 @@ private static URL[] createClassPath(Project project) {
110110
}
111111

112112
private void writeModuleCSV(ClassLoader classLoader, FileWriter moduleWriter) throws IOException {
113-
113+
114114
final List<AvajeModule> avajeModules = new ArrayList<>();
115115
ServiceLoader.load(Module.class, classLoader).forEach(avajeModules::add);
116116
ServiceLoader.load(InjectExtension.class, classLoader).stream()

inject/src/main/java/io/avaje/inject/spi/DBeanMap.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ private void addSuppliedBean(SuppliedBean supplied) {
6262
qualifiers.add(supplied.name());
6363
DContextEntryBean entryBean = DContextEntryBean.supplied(supplied.source(), supplied.name(), supplied.priority());
6464
beans.computeIfAbsent(suppliedType.getTypeName(), s -> new DContextEntry()).add(entryBean);
65-
for (Class<?> anInterface : supplied.interfaces()) {
66-
beans.computeIfAbsent(anInterface.getTypeName(), s -> new DContextEntry()).add(entryBean);
65+
if (!suppliedType.getTypeName().startsWith("java.lang")) {
66+
for (Class<?> anInterface : supplied.interfaces()) {
67+
beans.computeIfAbsent(anInterface.getTypeName(), s -> new DContextEntry()).add(entryBean);
68+
}
6769
}
6870
}
6971

0 commit comments

Comments
 (0)