Skip to content

Commit dc74b41

Browse files
committed
GH-801 - Properly guard for presence of jMolecules' @module type.
As @module is absent from the Kotlin flavor of jMolecules, code that refers to that is now guarded with a more specific check for that type in particular.
1 parent 1015570 commit dc74b41

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModuleInformation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static ApplicationModuleInformation of(JavaPackage javaPackage) {
5050

5151
var lookup = AnnotationLookup.of(javaPackage.toSingle(), __ -> true);
5252

53-
return JMoleculesTypes.isPresent() && JMoleculesModule.supports(lookup)
53+
return JMoleculesTypes.isModulePresent() && JMoleculesModule.supports(lookup)
5454
? new JMoleculesModule(lookup)
5555
: new SpringModulithModule(lookup);
5656
}

spring-modulith-core/src/main/java/org/springframework/modulith/core/Types.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,35 @@ static class JMoleculesTypes {
5353
private static final String MODULE = ANNOTATION_PACKAGE + ".Module";
5454

5555
private static final boolean PRESENT = ClassUtils.isPresent(AT_ENTITY, JMoleculesTypes.class.getClassLoader());
56+
private static final boolean MODULE_PRESENT = ClassUtils.isPresent(MODULE, JMoleculesTypes.class.getClassLoader());
5657

5758
static final String AT_DOMAIN_EVENT_HANDLER = BASE_PACKAGE + ".event.annotation.DomainEventHandler";
5859
static final String AT_DOMAIN_EVENT = BASE_PACKAGE + ".event.annotation.DomainEvent";
5960
static final String DOMAIN_EVENT = BASE_PACKAGE + ".event.types.DomainEvent";
6061

62+
/**
63+
* Returns whether jMolecules is generally present.
64+
*
65+
* @see #isModulePresent()
66+
*/
6167
public static boolean isPresent() {
6268
return PRESENT;
6369
}
6470

71+
/**
72+
* Returns whether the jMolecules {@link Module} type is present. We need to guard for this explicitly as the Kotlin
73+
* variant of jMolecules DDD does not ship that type.
74+
*/
75+
public static boolean isModulePresent() {
76+
return MODULE_PRESENT;
77+
}
78+
6579
@Nullable
6680
@SuppressWarnings("unchecked")
6781
public static Class<? extends Annotation> getModuleAnnotationTypeIfPresent() {
6882

6983
try {
70-
return isPresent()
84+
return isModulePresent()
7185
? (Class<? extends Annotation>) ClassUtils.forName(MODULE, JMoleculesTypes.class.getClassLoader())
7286
: null;
7387
} catch (Exception o_O) {

0 commit comments

Comments
 (0)