You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In pom.xml I have <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.modulith</groupId> <artifactId>spring-modulith-bom</artifactId> <version>${version.spring-modulith-bom}</version> <type>pom</type> <scope>import</scope> </dependency>
I am running test:
`
class ApplicationModularityUnitTest {
ApplicationModules modules = ApplicationModules.of(Application.class);
@Test
void verifiesModularStructure() {
modules.verify();
}`
But error is:
`
java.lang.AssertionError: Rule 'slices assigned from Appliction module slices [] should be free of cycles' failed to check any classes. This means either that no classes have been passed to the rule at all, or that no classes passed to the rule matched the that() clause. To allow rules being evaluated without checking any classes you can either use ArchRule.allowEmptyShould(true) on a single rule or set the configuration property archRule.failOnEmptyShould = false to change the behavior globally.
at com.tngtech.archunit.lang.ArchRule$Factory$SimpleArchRule.verifyNoEmptyShouldIfEnabled(ArchRule.java:201)
at com.tngtech.archunit.lang.ArchRule$Factory$SimpleArchRule.evaluate(ArchRule.java:181)
at com.tngtech.archunit.lang.syntax.ObjectsShouldInternal.evaluate(ObjectsShouldInternal.java:76)
at com.tngtech.archunit.library.dependencies.SliceRule.evaluate(SliceRule.java:99)
at org.springframework.modulith.core.ApplicationModules.assertNoCyclesFor(ApplicationModules.java:462)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:722)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at org.springframework.modulith.core.ApplicationModules.detectViolations(ApplicationModules.java:368)
at org.springframework.modulith.core.ApplicationModules.verify(ApplicationModules.java:346)
at eu.layer.labcontrol.ApplicationModularityUnitTest.verifiesModularStructure(ApplicationModularityUnitTest.java:18)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)`
I changed the Spring Boot version from 3.0.7 to 3.2.3, the Java version from 17 to 21 and
The text was updated successfully, but these errors were encountered:
I have a hard time reproducing this on a standard Spring Boot arrangement, as the Application class you point to should at least be included in the classes to be verified. In other words, there shouldn't be a case in which the set of classes to be inspected should be empty unless you point to a non-existant package in the first place. I can see that the currently thrown exception could be improved, but ultimately, I think that rejecting such a scenario right away is indeed better than just ignoring the problem, as it's definitely an incorrect setup.
I'll put measures in place that will reject the latter case with a better error message. If you can provide a reproducer for the standard bootstrap case (pointing to a Spring Boot application class) I'm happy to look at that, too.
odrotbohm
changed the title
Verify structure
Verification on empty project failing
Mar 5, 2024
I Have Spring boot 3.2.3 project with Java 21.
In pom.xml I have
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.modulith</groupId> <artifactId>spring-modulith-bom</artifactId> <version>${version.spring-modulith-bom}</version> <type>pom</type> <scope>import</scope> </dependency>
<dependency> <groupId>org.springframework.modulith</groupId> <artifactId>spring-modulith-core</artifactId> </dependency>
<dependency> <groupId>org.springframework.modulith</groupId> <artifactId>spring-modulith-starter-test</artifactId> <scope>test</scope> </dependency>
I am running test:
`
class ApplicationModularityUnitTest {
java.lang.AssertionError: Rule 'slices assigned from Appliction module slices [] should be free of cycles' failed to check any classes. This means either that no classes have been passed to the rule at all, or that no classes passed to the rule matched the
that()
clause. To allow rules being evaluated without checking any classes you can either useArchRule.allowEmptyShould(true)
on a single rule or set the configuration propertyarchRule.failOnEmptyShould = false
to change the behavior globally.I changed the Spring Boot version from 3.0.7 to 3.2.3, the Java version from 17 to 21 and
The text was updated successfully, but these errors were encountered: