diff --git a/spring-modulith-core/src/main/java/org/springframework/modulith/core/NamedInterfaces.java b/spring-modulith-core/src/main/java/org/springframework/modulith/core/NamedInterfaces.java index 5c10be27..180a67bc 100644 --- a/spring-modulith-core/src/main/java/org/springframework/modulith/core/NamedInterfaces.java +++ b/spring-modulith-core/src/main/java/org/springframework/modulith/core/NamedInterfaces.java @@ -250,7 +250,7 @@ public class NamedInterfaces implements Iterable { .filter(it -> !JavaPackage.isPackageInfoType(it)) // .forEach(it -> { - if (!it.isAnnotatedWith(org.springframework.modulith.NamedInterface.class)) { + if (!it.isMetaAnnotatedWith(org.springframework.modulith.NamedInterface.class)) { return; } diff --git a/spring-modulith-core/src/test/java/example/metani/Exposed.java b/spring-modulith-core/src/test/java/example/metani/Exposed.java new file mode 100644 index 00000000..161085af --- /dev/null +++ b/spring-modulith-core/src/test/java/example/metani/Exposed.java @@ -0,0 +1,22 @@ +/* + * Copyright 2025 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 example.metani; + +/** + * @author Oliver Drotbohm + */ +@ModuleApi +public class Exposed {} diff --git a/spring-modulith-core/src/test/java/example/metani/ModuleApi.java b/spring-modulith-core/src/test/java/example/metani/ModuleApi.java new file mode 100644 index 00000000..8afc6b3b --- /dev/null +++ b/spring-modulith-core/src/test/java/example/metani/ModuleApi.java @@ -0,0 +1,32 @@ +/* + * Copyright 2025 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 example.metani; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.*; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.springframework.modulith.NamedInterface; + +/** + * @author Oliver Drotbohm + */ +@Retention(RUNTIME) +@Target({ TYPE }) +@NamedInterface("api") +public @interface ModuleApi {} diff --git a/spring-modulith-core/src/test/java/org/springframework/modulith/core/ApplicationModulesUnitTests.java b/spring-modulith-core/src/test/java/org/springframework/modulith/core/ApplicationModulesUnitTests.java index 2eee5a3a..c1cb9438 100644 --- a/spring-modulith-core/src/test/java/org/springframework/modulith/core/ApplicationModulesUnitTests.java +++ b/spring-modulith-core/src/test/java/org/springframework/modulith/core/ApplicationModulesUnitTests.java @@ -37,6 +37,7 @@ class ApplicationModulesUnitTests { .containsExactlyInAnyOrder( "invalid", "customId", + "metani", "ni", "ni.nested", "ni.nested.b.first", diff --git a/spring-modulith-core/src/test/java/org/springframework/modulith/core/NamedInterfacesUnitTests.java b/spring-modulith-core/src/test/java/org/springframework/modulith/core/NamedInterfacesUnitTests.java index 2dec5abe..428a6be5 100644 --- a/spring-modulith-core/src/test/java/org/springframework/modulith/core/NamedInterfacesUnitTests.java +++ b/spring-modulith-core/src/test/java/org/springframework/modulith/core/NamedInterfacesUnitTests.java @@ -98,6 +98,18 @@ class NamedInterfacesUnitTests { .containsExactlyInAnyOrder("spi", "kpi"); } + @Test // GH-1139 + void discoveredNamedInterfaceOnComposedAnnotation() { + + var pkg = TestUtils.getPackage(example.metani.Exposed.class); + + var result = NamedInterfaces.discoverNamedInterfaces(pkg); + + assertThat(result).hasSize(2) + .extracting(NamedInterface::getName) + .containsExactlyInAnyOrder(NamedInterface.UNNAMED_NAME, "api"); + } + private static void assertInterfaceContains(NamedInterfaces interfaces, String name, Class... types) { var classNames = Arrays.stream(types).map(Class::getName).toArray(String[]::new);