Skip to content

Commit 6e12327

Browse files
committed
GH-816 - 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 2ae6e6a commit 6e12327

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
@@ -52,21 +52,35 @@ static class JMoleculesTypes {
5252
private static final String MODULE = ANNOTATION_PACKAGE + ".Module";
5353

5454
private static final boolean PRESENT = ClassUtils.isPresent(AT_ENTITY, JMoleculesTypes.class.getClassLoader());
55+
private static final boolean MODULE_PRESENT = ClassUtils.isPresent(MODULE, JMoleculesTypes.class.getClassLoader());
5556

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

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

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

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

0 commit comments

Comments
 (0)