Skip to content

Commit c4debfc

Browse files
committed
GH-817 - 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 13d7618 commit c4debfc

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
@@ -44,7 +44,7 @@ public static ApplicationModuleInformation of(JavaPackage javaPackage) {
4444

4545
var rootPackage = javaPackage.toSingle();
4646

47-
return JMoleculesTypes.isPresent() && JMoleculesModule.supports(rootPackage)
47+
return JMoleculesTypes.isModulePresent() && JMoleculesModule.supports(rootPackage)
4848
? new JMoleculesModule(rootPackage)
4949
: new SpringModulithModule(rootPackage);
5050
}

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

5353
private static final boolean PRESENT = ClassUtils.isPresent(AT_ENTITY, JMoleculesTypes.class.getClassLoader());
54+
private static final boolean MODULE_PRESENT = ClassUtils.isPresent(MODULE, JMoleculesTypes.class.getClassLoader());
5455

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

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

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

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

0 commit comments

Comments
 (0)