|
48 | 48 | import com.tngtech.archunit.core.importer.ImportOption;
|
49 | 49 | import com.tngtech.archunit.lang.EvaluationResult;
|
50 | 50 | import com.tngtech.archunit.lang.FailureReport;
|
| 51 | +import com.tngtech.archunit.library.dependencies.SliceAssignment; |
| 52 | +import com.tngtech.archunit.library.dependencies.SliceIdentifier; |
51 | 53 | import com.tngtech.archunit.library.dependencies.SlicesRuleDefinition;
|
52 | 54 |
|
53 | 55 | /**
|
@@ -455,7 +457,7 @@ private ApplicationModules withSharedModules(Set<ApplicationModule> sharedModule
|
455 | 457 | private FailureReport assertNoCyclesFor(JavaPackage rootPackage) {
|
456 | 458 |
|
457 | 459 | var result = SlicesRuleDefinition.slices() //
|
458 |
| - .matching(rootPackage.getName().concat(".(*)..")) // |
| 460 | + .assignedFrom(new ApplicationModulesSliceAssignment()) |
459 | 461 | .should().beFreeOfCycles() //
|
460 | 462 | .evaluate(allClasses.that(resideInAPackage(rootPackage.getName().concat(".."))));
|
461 | 463 |
|
@@ -728,4 +730,29 @@ private static List<String> topologicallySortModules(ApplicationModules modules)
|
728 | 730 | }
|
729 | 731 | }
|
730 | 732 | }
|
| 733 | + |
| 734 | + private class ApplicationModulesSliceAssignment implements SliceAssignment { |
| 735 | + |
| 736 | + /* |
| 737 | + * (non-Javadoc) |
| 738 | + * @see com.tngtech.archunit.library.dependencies.SliceAssignment#getIdentifierOf(com.tngtech.archunit.core.domain.JavaClass) |
| 739 | + */ |
| 740 | + @Override |
| 741 | + public SliceIdentifier getIdentifierOf(JavaClass javaClass) { |
| 742 | + |
| 743 | + return getModuleByType(javaClass) |
| 744 | + .map(ApplicationModule::getName) |
| 745 | + .map(SliceIdentifier::of) |
| 746 | + .orElse(SliceIdentifier.ignore()); |
| 747 | + } |
| 748 | + |
| 749 | + /* |
| 750 | + * (non-Javadoc) |
| 751 | + * @see com.tngtech.archunit.base.HasDescription#getDescription() |
| 752 | + */ |
| 753 | + @Override |
| 754 | + public String getDescription() { |
| 755 | + return "Appliction module slices " + ApplicationModules.this.modules.keySet(); |
| 756 | + } |
| 757 | + } |
731 | 758 | }
|
0 commit comments