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 3310d107..1575e989 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 @@ -17,6 +17,7 @@ package org.springframework.modulith.core; import static com.tngtech.archunit.base.DescribedPredicate.*; import static com.tngtech.archunit.core.domain.JavaClass.Predicates.*; +import static com.tngtech.archunit.core.domain.properties.HasName.Predicates.*; import static java.util.stream.Collectors.*; import java.util.*; @@ -45,6 +46,7 @@ import org.springframework.util.ClassUtils; import com.tngtech.archunit.base.DescribedPredicate; import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaClasses; +import com.tngtech.archunit.core.domain.properties.HasName; import com.tngtech.archunit.core.importer.ClassFileImporter; import com.tngtech.archunit.core.importer.ImportOption; import com.tngtech.archunit.lang.EvaluationResult; @@ -64,6 +66,8 @@ 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 = nameContaining("__") + .or(nameContaining("$$SpringCGLIB$$")); static { @@ -98,7 +102,7 @@ public class ApplicationModules implements Iterable { this.allClasses = new ClassFileImporter() // .withImportOption(option) // .importPackages(packages) // - .that(not(ignored)); + .that(not(ignored.or(IS_AOT_TYPE))); Classes classes = Classes.of(allClasses); diff --git a/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/Some$$SpringCGLIB$$Proxy.java b/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/Some$$SpringCGLIB$$Proxy.java new file mode 100644 index 00000000..37fff7e6 --- /dev/null +++ b/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/Some$$SpringCGLIB$$Proxy.java @@ -0,0 +1,24 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.acme.myproject.aot; + +/** + * + * @author Oliver Drotbohm + */ +public class Some$$SpringCGLIB$$Proxy { + +} diff --git a/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/Spring__Aot.java b/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/Spring__Aot.java new file mode 100644 index 00000000..7ab49fd5 --- /dev/null +++ b/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/Spring__Aot.java @@ -0,0 +1,24 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.acme.myproject.aot; + +/** + * + * @author Oliver Drotbohm + */ +public class Spring__Aot { + +} diff --git a/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/package-info.java b/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/package-info.java new file mode 100644 index 00000000..ab2626ed --- /dev/null +++ b/spring-modulith-integration-test/src/main/java/com/acme/myproject/aot/package-info.java @@ -0,0 +1 @@ +package com.acme.myproject.aot; diff --git a/spring-modulith-integration-test/src/test/java/org/springframework/modulith/core/ApplicationModulesIntegrationTest.java b/spring-modulith-integration-test/src/test/java/org/springframework/modulith/core/ApplicationModulesIntegrationTest.java index a0e85d42..7dc42b70 100644 --- a/spring-modulith-integration-test/src/test/java/org/springframework/modulith/core/ApplicationModulesIntegrationTest.java +++ b/spring-modulith-integration-test/src/test/java/org/springframework/modulith/core/ApplicationModulesIntegrationTest.java @@ -30,6 +30,8 @@ import java.util.stream.Stream; import org.junit.jupiter.api.Test; import com.acme.myproject.Application; +import com.acme.myproject.aot.Some$$SpringCGLIB$$Proxy; +import com.acme.myproject.aot.Spring__Aot; import com.acme.myproject.complex.internal.FirstTypeBasedPort; import com.acme.myproject.complex.internal.SecondTypeBasePort; import com.acme.myproject.moduleA.ServiceComponentA; @@ -185,6 +187,15 @@ class ApplicationModulesIntegrationTest { assertThat(third.getDeclaredDependencies(modules).isAllowedDependency(Fourth.class)).isTrue(); } + @Test // GH-408 + void excludesSpringAOTGeneratedTypes() { + + assertThat(modules.getModuleByName("aot")).hasValueSatisfying(it -> { + assertThat(it.contains(Spring__Aot.class)).isFalse(); + assertThat(it.contains(Some$$SpringCGLIB$$Proxy.class)).isFalse(); + }); + } + private static void verifyNamedInterfaces(NamedInterfaces interfaces, String name, Class... types) { Stream.of(types).forEach(type -> {