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) {
968
968
969
969
var originModule = getExistingModuleOf (source , modules );
970
970
var targetModule = getExistingModuleOf (target , modules );
971
+ var violations = Violations .NONE ;
971
972
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 );
974
978
975
979
// Check explicitly defined allowed targets
976
980
if (!declaredDependencies .isAllowedDependency (target )) {
Original file line number Diff line number Diff line change 17
17
18
18
import static com .tngtech .archunit .core .domain .JavaClass .Predicates .*;
19
19
20
+ import java .util .List ;
20
21
import java .util .function .Supplier ;
21
22
22
23
import org .jmolecules .ddd .annotation .AggregateRoot ;
28
29
import com .tngtech .archunit .core .domain .JavaClass ;
29
30
import com .tngtech .archunit .core .domain .JavaClasses ;
30
31
import com .tngtech .archunit .core .importer .ClassFileImporter ;
32
+ import com .tngtech .archunit .core .importer .ImportOption ;
31
33
32
34
/**
33
35
* Utilities for testing.
34
36
*
35
37
* @author Oliver Drotbohm
36
38
*/
37
- class TestUtils {
39
+ public class TestUtils {
38
40
39
41
private static Supplier <JavaClasses > imported = SingletonSupplier .of (() -> new ClassFileImporter () //
40
42
.importPackagesOf (ApplicationModules .class , Repository .class , AggregateRoot .class ));
@@ -92,4 +94,9 @@ private static Classes getClasses(String packageName) {
92
94
return Classes .of (new ClassFileImporter ()
93
95
.importPackages (packageName ));
94
96
}
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
+ }
95
102
}
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