File tree Expand file tree Collapse file tree 5 files changed +70
-10
lines changed
main/java/org/springframework/modulith/core
org/springframework/modulith/core Expand file tree Collapse file tree 5 files changed +70
-10
lines changed Original file line number Diff line number Diff line change 26
26
import org .jmolecules .ddd .annotation .Module ;
27
27
import org .springframework .modulith .ApplicationModule ;
28
28
import org .springframework .modulith .ApplicationModule .Type ;
29
+ import org .springframework .modulith .core .Types .JMoleculesTypes ;
29
30
import org .springframework .util .Assert ;
30
- import org .springframework .util .ClassUtils ;
31
31
import org .springframework .util .StringUtils ;
32
32
33
33
import com .tngtech .archunit .core .domain .JavaClass ;
@@ -48,15 +48,11 @@ interface ApplicationModuleInformation {
48
48
*/
49
49
public static ApplicationModuleInformation of (JavaPackage javaPackage ) {
50
50
51
- var lookup = AnnotationLookup .of (javaPackage , __ -> true );
51
+ var lookup = AnnotationLookup .of (javaPackage . toSingle () , __ -> true );
52
52
53
- if (ClassUtils .isPresent ("org.jmolecules.ddd.annotation.Module" ,
54
- ApplicationModuleInformation .class .getClassLoader ())
55
- && JMoleculesModule .supports (lookup )) {
56
- return new JMoleculesModule (lookup );
57
- }
58
-
59
- return new SpringModulithModule (lookup );
53
+ return JMoleculesTypes .isPresent () && JMoleculesModule .supports (lookup )
54
+ ? new JMoleculesModule (lookup )
55
+ : new SpringModulithModule (lookup );
60
56
}
61
57
62
58
/**
Original file line number Diff line number Diff line change @@ -51,12 +51,14 @@ static class JMoleculesTypes {
51
51
private static final String ARCHUNIT_RULES = BASE_PACKAGE + ".archunit.JMoleculesDddRules" ;
52
52
private static final String MODULE = ANNOTATION_PACKAGE + ".Module" ;
53
53
54
+ private static final boolean PRESENT = ClassUtils .isPresent (AT_ENTITY , JMoleculesTypes .class .getClassLoader ());
55
+
54
56
static final String AT_DOMAIN_EVENT_HANDLER = BASE_PACKAGE + ".event.annotation.DomainEventHandler" ;
55
57
static final String AT_DOMAIN_EVENT = BASE_PACKAGE + ".event.annotation.DomainEvent" ;
56
58
static final String DOMAIN_EVENT = BASE_PACKAGE + ".event.types.DomainEvent" ;
57
59
58
60
public static boolean isPresent () {
59
- return ClassUtils . isPresent ( AT_ENTITY , JMoleculesTypes . class . getClassLoader ()) ;
61
+ return PRESENT ;
60
62
}
61
63
62
64
@ 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