@@ -37,22 +37,32 @@ public enum MavenLevel {
37
37
true ,
38
38
false ,
39
39
new BuildScopeMatrix (
40
- Arrays .asList (CommonBuilds .PROJECT_PATH_MAIN , CommonBuilds .PROJECT_PATH_TEST ),
41
- Arrays .asList (CommonBuilds .BUILD_PATH_COMPILE , CommonBuilds .BUILD_PATH_RUNTIME ))),
40
+ Collections .singletonList (CommonBuilds .PROJECT_PATH_MAIN ),
41
+ Arrays .asList (CommonBuilds .BUILD_PATH_COMPILE , CommonBuilds .BUILD_PATH_RUNTIME ),
42
+ CommonBuilds .MAVEN_TEST_BUILD_SCOPE )),
42
43
Maven3 (
43
44
true ,
44
45
false ,
45
46
true ,
46
47
false ,
47
48
new BuildScopeMatrix (
48
- Arrays .asList (CommonBuilds .PROJECT_PATH_MAIN , CommonBuilds .PROJECT_PATH_TEST ),
49
- Arrays .asList (CommonBuilds .BUILD_PATH_COMPILE , CommonBuilds .BUILD_PATH_RUNTIME ))),
50
- Maven4 (
49
+ Collections .singletonList (CommonBuilds .PROJECT_PATH_MAIN ),
50
+ Arrays .asList (CommonBuilds .BUILD_PATH_COMPILE , CommonBuilds .BUILD_PATH_RUNTIME ),
51
+ CommonBuilds .MAVEN_TEST_BUILD_SCOPE )),
52
+ Maven4WithoutSystem (
51
53
false ,
52
54
false ,
53
55
false ,
54
56
true ,
55
57
new BuildScopeMatrix (
58
+ Arrays .asList (CommonBuilds .PROJECT_PATH_MAIN , CommonBuilds .PROJECT_PATH_TEST ),
59
+ Arrays .asList (CommonBuilds .BUILD_PATH_COMPILE , CommonBuilds .BUILD_PATH_RUNTIME ))),
60
+ Maven4WithSystem (
61
+ true ,
62
+ false ,
63
+ false ,
64
+ true ,
65
+ new BuildScopeMatrix (
56
66
Arrays .asList (CommonBuilds .PROJECT_PATH_MAIN , CommonBuilds .PROJECT_PATH_TEST ),
57
67
Arrays .asList (CommonBuilds .BUILD_PATH_COMPILE , CommonBuilds .BUILD_PATH_RUNTIME )));
58
68
@@ -146,7 +156,7 @@ private Map<String, JavaDependencyScope> buildDependencyScopes() {
146
156
false ,
147
157
buildScopeMatrix .union (
148
158
buildScopeMatrix .byBuildPath (CommonBuilds .BUILD_PATH_COMPILE ),
149
- buildScopeMatrix .singleton (
159
+ buildScopeMatrix .select (
150
160
CommonBuilds .PROJECT_PATH_TEST , CommonBuilds .BUILD_PATH_RUNTIME ))));
151
161
result .put (
152
162
DS_TEST ,
@@ -262,7 +272,7 @@ private Map<String, JavaResolutionScope> buildResolutionScopes() {
262
272
RS_TEST_COMPILE ,
263
273
this ,
264
274
ResolutionScope .Mode .ELIMINATE ,
265
- buildScopeMatrix .singleton (CommonBuilds .PROJECT_PATH_TEST , CommonBuilds .BUILD_PATH_COMPILE ),
275
+ buildScopeMatrix .select (CommonBuilds .PROJECT_PATH_TEST , CommonBuilds .BUILD_PATH_COMPILE ),
266
276
Collections .singletonList (dependencyScopes .get (DS_SYSTEM )),
267
277
nonTransitiveScopes ));
268
278
result .put (
@@ -271,7 +281,7 @@ private Map<String, JavaResolutionScope> buildResolutionScopes() {
271
281
RS_TEST_RUNTIME ,
272
282
this ,
273
283
ResolutionScope .Mode .ELIMINATE ,
274
- buildScopeMatrix .singleton (CommonBuilds .PROJECT_PATH_TEST , CommonBuilds .BUILD_PATH_RUNTIME ),
284
+ buildScopeMatrix .select (CommonBuilds .PROJECT_PATH_TEST , CommonBuilds .BUILD_PATH_RUNTIME ),
275
285
Collections .singletonList (dependencyScopes .get (DS_SYSTEM )),
276
286
nonTransitiveScopes ));
277
287
return result ;
@@ -337,7 +347,8 @@ private Optional<BuildScope> getMainProjectBuildScope(JavaDependencyScope javaDe
337
347
.sorted (Comparator .comparing (BuildPath ::order ))
338
348
.collect (Collectors .toList ())) {
339
349
for (BuildScope buildScope : javaDependencyScope .getPresence ()) {
340
- if (buildScope .getProjectPath () == projectPath && buildScope .getBuildPath () == buildPath ) {
350
+ if (buildScope .getProjectPaths ().contains (projectPath )
351
+ && buildScope .getBuildPaths ().contains (buildPath )) {
341
352
return Optional .of (buildScope );
342
353
}
343
354
}
@@ -418,8 +429,8 @@ private static int calculateWidth(JavaDependencyScope dependencyScope) {
418
429
HashSet <ProjectPath > projectPaths = new HashSet <>();
419
430
HashSet <BuildPath > buildPaths = new HashSet <>();
420
431
dependencyScope .getPresence ().forEach (s -> {
421
- projectPaths .add (s .getProjectPath ());
422
- buildPaths .add (s .getBuildPath ());
432
+ projectPaths .addAll (s .getProjectPaths ());
433
+ buildPaths .addAll (s .getBuildPaths ());
423
434
});
424
435
int result = 0 ;
425
436
if (dependencyScope .isTransitive ()) {
@@ -540,8 +551,9 @@ private JavaResolutionScope(
540
551
this .mode = requireNonNull (mode , "mode" );
541
552
this .wantedPresence = Collections .unmodifiableSet (new HashSet <>(wantedPresence ));
542
553
Set <JavaDependencyScope > included = collectScopes (wantedPresence );
543
- if (explicitlyIncluded != null ) {
544
- included .addAll (explicitlyIncluded );
554
+ // here we may have null elements, based on existence of system scope
555
+ if (explicitlyIncluded != null && !explicitlyIncluded .isEmpty ()) {
556
+ explicitlyIncluded .stream ().filter (Objects ::nonNull ).forEach (included ::add );
545
557
}
546
558
this .directlyIncluded = Collections .unmodifiableSet (included );
547
559
this .transitivelyExcluded = Collections .unmodifiableSet (
@@ -638,7 +650,7 @@ private void dumpDependencyScopes() {
638
650
System .out .println (" Presence: "
639
651
+ s .getPresence ().stream ().map (BuildScope ::getId ).collect (Collectors .toSet ()));
640
652
System .out .println (" Main project scope: "
641
- + s .getMainProjectBuildScope ().get (). getId ( ));
653
+ + s .getMainProjectBuildScope ().map ( BuildScope :: getId ). orElse ( "null" ));
642
654
});
643
655
}
644
656
0 commit comments