File tree Expand file tree Collapse file tree 5 files changed +70
-9
lines changed
main/java/org/springframework/modulith/core
org/springframework/modulith/core Expand file tree Collapse file tree 5 files changed +70
-9
lines changed Original file line number Diff line number Diff line change 2121import java .util .function .Supplier ;
2222import java .util .stream .Stream ;
2323
24- import org .jmolecules .ddd .annotation .Module ;
2524import org .springframework .modulith .ApplicationModule ;
25+ import org .springframework .modulith .core .Types .JMoleculesTypes ;
2626import org .springframework .util .Assert ;
27- import org .springframework .util .ClassUtils ;
2827import org .springframework .util .StringUtils ;
2928
3029/**
@@ -43,13 +42,11 @@ interface ApplicationModuleInformation {
4342 */
4443 public static ApplicationModuleInformation of (JavaPackage javaPackage ) {
4544
46- if (ClassUtils .isPresent ("org.jmolecules.ddd.annotation.Module" ,
47- ApplicationModuleInformation .class .getClassLoader ())
48- && JMoleculesModule .supports (javaPackage )) {
49- return new JMoleculesModule (javaPackage );
50- }
45+ var rootPackage = javaPackage .toSingle ();
5146
52- return new SpringModulithModule (javaPackage );
47+ return JMoleculesTypes .isPresent () && JMoleculesModule .supports (rootPackage )
48+ ? new JMoleculesModule (rootPackage )
49+ : new SpringModulithModule (rootPackage );
5350 }
5451
5552 /**
Original file line number Diff line number Diff line change @@ -50,12 +50,14 @@ static class JMoleculesTypes {
5050 private static final String ARCHUNIT_RULES = BASE_PACKAGE + ".archunit.JMoleculesDddRules" ;
5151 private static final String MODULE = ANNOTATION_PACKAGE + ".Module" ;
5252
53+ private static final boolean PRESENT = ClassUtils .isPresent (AT_ENTITY , JMoleculesTypes .class .getClassLoader ());
54+
5355 static final String AT_DOMAIN_EVENT_HANDLER = BASE_PACKAGE + ".event.annotation.DomainEventHandler" ;
5456 static final String AT_DOMAIN_EVENT = BASE_PACKAGE + ".event.annotation.DomainEvent" ;
5557 static final String DOMAIN_EVENT = BASE_PACKAGE + ".event.types.DomainEvent" ;
5658
5759 public static boolean isPresent () {
58- return ClassUtils . isPresent ( AT_ENTITY , JMoleculesTypes . class . getClassLoader ()) ;
60+ return PRESENT ;
5961 }
6062
6163 @ Nullable
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 org .springframework .modulith .core ;
17+
18+ import static org .assertj .core .api .Assertions .*;
19+
20+ import reproducers .gh764 .Entry ;
21+
22+ import org .junit .jupiter .api .Test ;
23+
24+ /**
25+ * Unit tests for {@link ApplicationModuleInformation}.
26+ *
27+ * @author Oliver Drotbohm
28+ */
29+ class ApplicationModuleInformationUnitTests {
30+
31+ @ Test // GH-764
32+ void doesNotConsiderAnnotationOnNestedPackageInfos () {
33+
34+ var pkg = TestUtils .getPackage (Entry .class );
35+ var info = ApplicationModuleInformation .of (pkg );
36+
37+ assertThat (info .getDisplayName ()).isEmpty ();
38+ }
39+ }
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 .gh764 ;
17+
18+ /**
19+ * @author Oliver Drotbohm
20+ */
21+ public class Entry {}
Original file line number Diff line number Diff line change 1+ @ org .springframework .modulith .ApplicationModule (displayName = "Nested" )
2+ package reproducers .gh764 .nested ;
You can’t perform that action at this time.
0 commit comments