diff --git a/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModules.java b/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModules.java index ca9758ced..c3e11919f 100644 --- a/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModules.java +++ b/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModules.java @@ -67,7 +67,7 @@ public class ApplicationModules implements Iterable { private static final ImportOption IMPORT_OPTION = new ImportOption.DoNotIncludeTests(); private static final boolean JGRAPHT_PRESENT = ClassUtils.isPresent("org.jgrapht.Graph", ApplicationModules.class.getClassLoader()); - private static final DescribedPredicate IS_AOT_TYPE = annotatedWith(Generated.class); + private static final DescribedPredicate IS_AOT_TYPE; private static final DescribedPredicate IS_SPRING_CGLIB_PROXY = nameContaining("$$SpringCGLIB$$"); static { @@ -85,6 +85,14 @@ public class ApplicationModules implements Iterable { DETECTION_STRATEGY = loadFactories.isEmpty() ? ApplicationModuleDetectionStrategies.DIRECT_SUB_PACKAGES : loadFactories.get(0); + + IS_AOT_TYPE = ClassUtils.isPresent("org.springframework.aot.generate.Generated", + ApplicationModules.class.getClassLoader()) ? getAtGenerated() : DescribedPredicate.alwaysFalse(); + } + + @Nullable + private static DescribedPredicate getAtGenerated() { + return annotatedWith(Generated.class); } private final ModulithMetadata metadata;