From 169cf671282ee0ab7ed6ba1b26e80dd0556207f2 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Tue, 5 Nov 2024 16:16:07 +0100 Subject: [PATCH] =?UTF-8?q?Generally=20ignore=20generated=20code=20(annota?= =?UTF-8?q?ted=20with=20@=E2=80=A6.Generated).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modulith/core/ApplicationModules.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 e71db887..fd41f75b 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 @@ -44,8 +44,10 @@ import org.springframework.util.ClassUtils; import org.springframework.util.function.SingletonSupplier; import com.tngtech.archunit.base.DescribedPredicate; +import com.tngtech.archunit.core.domain.JavaAnnotation; import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaClasses; +import com.tngtech.archunit.core.domain.JavaType; import com.tngtech.archunit.core.domain.properties.CanBeAnnotated; import com.tngtech.archunit.core.domain.properties.HasName; import com.tngtech.archunit.core.importer.ClassFileImporter; @@ -67,12 +69,17 @@ 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; + private static final DescribedPredicate IS_AOT_TYPE, IS_GENERATED; private static final DescribedPredicate IS_SPRING_CGLIB_PROXY = nameContaining("$$SpringCGLIB$$"); static { + IS_AOT_TYPE = ClassUtils.isPresent("org.springframework.aot.generate.Generated", ApplicationModules.class.getClassLoader()) ? getAtGenerated() : DescribedPredicate.alwaysFalse(); + + IS_GENERATED = annotatedWith(JavaClass.Predicates.simpleName("Generated") + .onResultOf(JavaType::toErasure) + .onResultOf(JavaAnnotation::getType)); } @Nullable