File tree Expand file tree Collapse file tree 8 files changed +115
-3
lines changed
main/java/org/springframework/modulith/core
org/springframework/modulith/core Expand file tree Collapse file tree 8 files changed +115
-3
lines changed Original file line number Diff line number Diff line change @@ -968,9 +968,13 @@ Violations isValidDependencyWithin(ApplicationModules modules) {
968968
969969 var originModule = getExistingModuleOf (source , modules );
970970 var targetModule = getExistingModuleOf (target , modules );
971+ var violations = Violations .NONE ;
971972
972- DeclaredDependencies declaredDependencies = originModule .getDeclaredDependencies (modules );
973- Violations violations = Violations .NONE ;
973+ if (originModule .equals (targetModule )) {
974+ return violations ;
975+ }
976+
977+ var declaredDependencies = originModule .getDeclaredDependencies (modules );
974978
975979 // Check explicitly defined allowed targets
976980 if (!declaredDependencies .isAllowedDependency (target )) {
Original file line number Diff line number Diff line change 1717
1818import static com .tngtech .archunit .core .domain .JavaClass .Predicates .*;
1919
20+ import java .util .List ;
2021import java .util .function .Supplier ;
2122
2223import org .jmolecules .ddd .annotation .AggregateRoot ;
2829import com .tngtech .archunit .core .domain .JavaClass ;
2930import com .tngtech .archunit .core .domain .JavaClasses ;
3031import com .tngtech .archunit .core .importer .ClassFileImporter ;
32+ import com .tngtech .archunit .core .importer .ImportOption ;
3133
3234/**
3335 * Utilities for testing.
3436 *
3537 * @author Oliver Drotbohm
3638 */
37- class TestUtils {
39+ public class TestUtils {
3840
3941 private static Supplier <JavaClasses > imported = SingletonSupplier .of (() -> new ClassFileImporter () //
4042 .importPackagesOf (ApplicationModules .class , Repository .class , AggregateRoot .class ));
@@ -92,4 +94,9 @@ private static Classes getClasses(String packageName) {
9294 return Classes .of (new ClassFileImporter ()
9395 .importPackages (packageName ));
9496 }
97+
98+ public static ApplicationModules of (String basePackage , String ... ignoredPackages ) {
99+ return new ApplicationModules (ModulithMetadata .of (basePackage ), List .of (basePackage ),
100+ JavaClass .Predicates .resideInAnyPackage (ignoredPackages ), false , new ImportOption .OnlyIncludeTests ());
101+ }
95102}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package reproducers .gh660 .first ;
17+
18+ import org .junit .jupiter .api .Test ;
19+ import org .springframework .modulith .core .TestUtils ;
20+
21+ /**
22+ * @author Oliver Drotbohm
23+ */
24+ class Gh660Tests {
25+
26+ @ Test // GH-660
27+ void doesNotRejectInternalDependencies () {
28+ TestUtils .of ("reproducers.gh660" ).verify ();
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ @ org .springframework .modulith .ApplicationModule (allowedDependencies = {})
2+ package reproducers .gh660 .first ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package reproducers .gh660 .first .repository ;
17+
18+ /**
19+ * @author Oliver Drotbohm
20+ */
21+ public class Product {}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package reproducers .gh660 .first .repository ;
17+
18+ /**
19+ * @author Oliver Drotbohm
20+ */
21+ public interface ProductRepository {
22+ Product save (Product product );
23+ }
Original file line number Diff line number Diff line change 1+ @ org .springframework .modulith .NamedInterface
2+ package reproducers .gh660 .first .repository ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package reproducers .gh660 .second ;
17+
18+ import reproducers .gh660 .first .repository .ProductRepository ;
19+
20+ /**
21+ * @author Oliver Drotbohm
22+ */
23+ public interface ExtendingRepository extends ProductRepository {}
You can’t perform that action at this time.
0 commit comments