GH-170 - Improve log output for ApplicationModule.
We now consider whether a type is exposed by a module to determine whether it is reported as public (+) or contained (o) type.
This commit is contained in:
@@ -362,7 +362,7 @@ public class ApplicationModule {
|
||||
|
||||
builder.append("> Spring beans:\n");
|
||||
beans.forEach(it -> builder.append(" ") //
|
||||
.append(Classes.format(it, basePackage.getName()))//
|
||||
.append(Classes.format(it, basePackage.getName(), isExposed(it)))//
|
||||
.append('\n'));
|
||||
}
|
||||
|
||||
|
||||
@@ -442,7 +442,10 @@ public class ApplicationModules implements Iterable<ApplicationModule> {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.stream().map(ApplicationModule::toString).collect(Collectors.joining("\n"));
|
||||
|
||||
return this.stream()
|
||||
.map(it -> it.toString(this))
|
||||
.collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
private ApplicationModules withSharedModules(Set<ApplicationModule> sharedModules) {
|
||||
|
||||
@@ -241,12 +241,27 @@ class Classes implements DescribedIterable<JavaClass> {
|
||||
Assert.notNull(type, "Type must not be null!");
|
||||
Assert.notNull(basePackage, "Base package must not be null!");
|
||||
|
||||
var prefix = type.getModifiers().contains(JavaModifier.PUBLIC) ? "+" : "o";
|
||||
return format(type, basePackage, type.getModifiers().contains(JavaModifier.PUBLIC));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given {@link JavaClass} into a {@link String}, potentially abbreviating the given base package.
|
||||
*
|
||||
* @param type must not be {@literal null}.
|
||||
* @param basePackage must not be {@literal null}.
|
||||
* @param exposed whether the given type is considered exposed or not.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
static String format(JavaClass type, String basePackage, boolean exposed) {
|
||||
|
||||
Assert.notNull(type, "Type must not be null!");
|
||||
Assert.notNull(basePackage, "Base package must not be null!");
|
||||
|
||||
var name = StringUtils.hasText(basePackage) //
|
||||
? type.getName().replace(basePackage, "…") //
|
||||
: type.getName();
|
||||
|
||||
return String.format("%s %s", prefix, name);
|
||||
return String.format("%s %s", exposed ? "+" : "o", name);
|
||||
}
|
||||
|
||||
private static String format(JavaClass type) {
|
||||
|
||||
Reference in New Issue
Block a user