GH-1142 - Detect @NamedInterface on composed annotations.
This commit is contained in:
@@ -250,7 +250,7 @@ public class NamedInterfaces implements Iterable<NamedInterface> {
|
||||
.filter(it -> !JavaPackage.isPackageInfoType(it)) //
|
||||
.forEach(it -> {
|
||||
|
||||
if (!it.isAnnotatedWith(org.springframework.modulith.NamedInterface.class)) {
|
||||
if (!it.isMetaAnnotatedWith(org.springframework.modulith.NamedInterface.class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {}
|
||||
@@ -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 {}
|
||||
@@ -37,6 +37,7 @@ class ApplicationModulesUnitTests {
|
||||
.containsExactlyInAnyOrder(
|
||||
"invalid",
|
||||
"customId",
|
||||
"metani",
|
||||
"ni",
|
||||
"ni.nested",
|
||||
"ni.nested.b.first",
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user