diff --git a/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModuleInformation.java b/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModuleInformation.java index 1a19ab2f..56dc066e 100644 --- a/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModuleInformation.java +++ b/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModuleInformation.java @@ -50,7 +50,7 @@ public static ApplicationModuleInformation of(JavaPackage javaPackage) { var lookup = AnnotationLookup.of(javaPackage.toSingle(), __ -> true); - return JMoleculesTypes.isPresent() && JMoleculesModule.supports(lookup) + return JMoleculesTypes.isModulePresent() && JMoleculesModule.supports(lookup) ? new JMoleculesModule(lookup) : new SpringModulithModule(lookup); } diff --git a/spring-modulith-core/src/main/java/org/springframework/modulith/core/Types.java b/spring-modulith-core/src/main/java/org/springframework/modulith/core/Types.java index 0a7d5b80..661a1418 100644 --- a/spring-modulith-core/src/main/java/org/springframework/modulith/core/Types.java +++ b/spring-modulith-core/src/main/java/org/springframework/modulith/core/Types.java @@ -52,21 +52,35 @@ static class JMoleculesTypes { private static final String MODULE = ANNOTATION_PACKAGE + ".Module"; private static final boolean PRESENT = ClassUtils.isPresent(AT_ENTITY, JMoleculesTypes.class.getClassLoader()); + private static final boolean MODULE_PRESENT = ClassUtils.isPresent(MODULE, JMoleculesTypes.class.getClassLoader()); static final String AT_DOMAIN_EVENT_HANDLER = BASE_PACKAGE + ".event.annotation.DomainEventHandler"; static final String AT_DOMAIN_EVENT = BASE_PACKAGE + ".event.annotation.DomainEvent"; static final String DOMAIN_EVENT = BASE_PACKAGE + ".event.types.DomainEvent"; + /** + * Returns whether jMolecules is generally present. + * + * @see #isModulePresent() + */ public static boolean isPresent() { return PRESENT; } + /** + * Returns whether the jMolecules {@link Module} type is present. We need to guard for this explicitly as the Kotlin + * variant of jMolecules DDD does not ship that type. + */ + public static boolean isModulePresent() { + return MODULE_PRESENT; + } + @Nullable @SuppressWarnings("unchecked") public static Class getModuleAnnotationTypeIfPresent() { try { - return isPresent() + return isModulePresent() ? (Class) ClassUtils.forName(MODULE, JMoleculesTypes.class.getClassLoader()) : null; } catch (Exception o_O) {