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 21
21
import java .util .function .Supplier ;
22
22
import java .util .stream .Stream ;
23
23
24
- import org .jmolecules .ddd .annotation .Module ;
25
24
import org .springframework .modulith .ApplicationModule ;
25
+ import org .springframework .modulith .core .Types .JMoleculesTypes ;
26
26
import org .springframework .util .Assert ;
27
- import org .springframework .util .ClassUtils ;
28
27
import org .springframework .util .StringUtils ;
29
28
30
29
/**
@@ -43,13 +42,11 @@ interface ApplicationModuleInformation {
43
42
*/
44
43
public static ApplicationModuleInformation of (JavaPackage javaPackage ) {
45
44
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 ();
51
46
52
- return new SpringModulithModule (javaPackage );
47
+ return JMoleculesTypes .isPresent () && JMoleculesModule .supports (rootPackage )
48
+ ? new JMoleculesModule (rootPackage )
49
+ : new SpringModulithModule (rootPackage );
53
50
}
54
51
55
52
/**
Original file line number Diff line number Diff line change @@ -50,12 +50,14 @@ static class JMoleculesTypes {
50
50
private static final String ARCHUNIT_RULES = BASE_PACKAGE + ".archunit.JMoleculesDddRules" ;
51
51
private static final String MODULE = ANNOTATION_PACKAGE + ".Module" ;
52
52
53
+ private static final boolean PRESENT = ClassUtils .isPresent (AT_ENTITY , JMoleculesTypes .class .getClassLoader ());
54
+
53
55
static final String AT_DOMAIN_EVENT_HANDLER = BASE_PACKAGE + ".event.annotation.DomainEventHandler" ;
54
56
static final String AT_DOMAIN_EVENT = BASE_PACKAGE + ".event.annotation.DomainEvent" ;
55
57
static final String DOMAIN_EVENT = BASE_PACKAGE + ".event.types.DomainEvent" ;
56
58
57
59
public static boolean isPresent () {
58
- return ClassUtils . isPresent ( AT_ENTITY , JMoleculesTypes . class . getClassLoader ()) ;
60
+ return PRESENT ;
59
61
}
60
62
61
63
@ 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