diff --git a/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModule.java b/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModule.java index 625a2759..bbb1ea51 100644 --- a/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModule.java +++ b/spring-modulith-core/src/main/java/org/springframework/modulith/core/ApplicationModule.java @@ -1007,9 +1007,13 @@ public class ApplicationModule { var originModule = getExistingModuleOf(source, modules); var targetModule = getExistingModuleOf(target, modules); + var violations = Violations.NONE; + + if (originModule.equals(targetModule)) { + return violations; + } var declaredDependencies = originModule.getDeclaredDependencies(modules); - var violations = Violations.NONE; // Check explicitly defined allowed targets if (!declaredDependencies.isAllowedDependency(target)) { diff --git a/spring-modulith-core/src/test/java/org/springframework/modulith/core/TestUtils.java b/spring-modulith-core/src/test/java/org/springframework/modulith/core/TestUtils.java index f1e8ce83..98bdd3f1 100644 --- a/spring-modulith-core/src/test/java/org/springframework/modulith/core/TestUtils.java +++ b/spring-modulith-core/src/test/java/org/springframework/modulith/core/TestUtils.java @@ -35,7 +35,7 @@ import com.tngtech.archunit.core.importer.ImportOption; * * @author Oliver Drotbohm */ -class TestUtils { +public class TestUtils { private static Supplier imported = SingletonSupplier.of(() -> new ClassFileImporter() // .importPackagesOf(ApplicationModules.class, Repository.class, AggregateRoot.class)); diff --git a/spring-modulith-core/src/test/java/reproducers/gh660/first/Gh660Tests.java b/spring-modulith-core/src/test/java/reproducers/gh660/first/Gh660Tests.java new file mode 100644 index 00000000..d3fb4cac --- /dev/null +++ b/spring-modulith-core/src/test/java/reproducers/gh660/first/Gh660Tests.java @@ -0,0 +1,30 @@ +/* + * Copyright 2024 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 reproducers.gh660.first; + +import org.junit.jupiter.api.Test; +import org.springframework.modulith.core.TestUtils; + +/** + * @author Oliver Drotbohm + */ +class Gh660Tests { + + @Test // GH-660 + void doesNotRejectInternalDependencies() { + TestUtils.of("reproducers.gh660").verify(); + } +} diff --git a/spring-modulith-core/src/test/java/reproducers/gh660/first/package-info.java b/spring-modulith-core/src/test/java/reproducers/gh660/first/package-info.java new file mode 100644 index 00000000..5a63dd3a --- /dev/null +++ b/spring-modulith-core/src/test/java/reproducers/gh660/first/package-info.java @@ -0,0 +1,2 @@ +@org.springframework.modulith.ApplicationModule(allowedDependencies = {}) +package reproducers.gh660.first; diff --git a/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/Product.java b/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/Product.java new file mode 100644 index 00000000..0c18dfd6 --- /dev/null +++ b/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/Product.java @@ -0,0 +1,21 @@ +/* + * Copyright 2024 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 reproducers.gh660.first.repository; + +/** + * @author Oliver Drotbohm + */ +public class Product {} diff --git a/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/ProductRepository.java b/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/ProductRepository.java new file mode 100644 index 00000000..50b74f5d --- /dev/null +++ b/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/ProductRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright 2024 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 reproducers.gh660.first.repository; + +/** + * @author Oliver Drotbohm + */ +public interface ProductRepository { + Product save(Product product); +} diff --git a/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/package-info.java b/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/package-info.java new file mode 100644 index 00000000..65180dd6 --- /dev/null +++ b/spring-modulith-core/src/test/java/reproducers/gh660/first/repository/package-info.java @@ -0,0 +1,2 @@ +@org.springframework.modulith.NamedInterface +package reproducers.gh660.first.repository; diff --git a/spring-modulith-core/src/test/java/reproducers/gh660/second/ExtendingRepository.java b/spring-modulith-core/src/test/java/reproducers/gh660/second/ExtendingRepository.java new file mode 100644 index 00000000..1f2c4ded --- /dev/null +++ b/spring-modulith-core/src/test/java/reproducers/gh660/second/ExtendingRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright 2024 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 reproducers.gh660.second; + +import reproducers.gh660.first.repository.ProductRepository; + +/** + * @author Oliver Drotbohm + */ +public interface ExtendingRepository extends ProductRepository {}