1
1
package com .alessiodp .libby .transitive ;
2
2
3
+ import com .alessiodp .libby .LibbyTestProperties ;
3
4
import com .alessiodp .libby .Library ;
4
5
import com .alessiodp .libby .LibraryManagerMock ;
5
6
import com .alessiodp .libby .TestUtils ;
8
9
import org .junit .jupiter .api .Test ;
9
10
10
11
import java .nio .file .Path ;
12
+ import java .nio .file .Paths ;
11
13
import java .util .*;
12
14
13
15
import static org .junit .jupiter .api .Assertions .*;
@@ -20,7 +22,7 @@ public class TransitiveDownloadingTest {
20
22
.version ("1.9.15" )
21
23
.resolveTransitiveDependencies (true )
22
24
.build ();
23
- private static final Library EXCLUDED_LIBRARY = TransitiveLibraryResolutionDependency .MAVEN_RESOLVER_API .toLibrary ();
25
+ private static final Library EXCLUDED_LIBRARY = MavenResolverDependencies .MAVEN_RESOLVER_API .toLibrary ();
24
26
private static final Library MAVEN_RESOLVER_SUPPLIER_WITH_EXCLUDED = Library .builder ()
25
27
.groupId (MAVEN_RESOLVER_SUPPLIER .getGroupId ())
26
28
.artifactId (MAVEN_RESOLVER_SUPPLIER .getArtifactId ())
@@ -33,6 +35,7 @@ public class TransitiveDownloadingTest {
33
35
.artifactId ("bungeecord-api" )
34
36
.version ("1.20-R0.2-SNAPSHOT" )
35
37
.repository ("https://oss.sonatype.org/content/repositories/snapshots" )
38
+ .repository ("https://hub.spigotmc.org/nexus/content/groups/public/" )
36
39
.isolatedLoad (true )
37
40
.loaderId ("bungeecord" )
38
41
.resolveTransitiveDependencies (true )
@@ -43,6 +46,8 @@ public class TransitiveDownloadingTest {
43
46
@ BeforeEach
44
47
public void setUp () throws Exception {
45
48
libraryManager = new LibraryManagerMock ();
49
+ // Local repo set up by gradle for libby-maven-resolver
50
+ libraryManager .addRepository (Paths .get (LibbyTestProperties .LIBBY_MAVEN_RESOLVER_REPO ).toUri ().toString ());
46
51
libraryManager .addMavenCentral ();
47
52
}
48
53
@@ -69,29 +74,29 @@ public void snapshotLibraryTransitiveLoad() throws Exception {
69
74
public void transitiveWithExcludedLoad () {
70
75
libraryManager .loadLibrary (MAVEN_RESOLVER_SUPPLIER_WITH_EXCLUDED );
71
76
72
- checkDownloadedDependencies (TransitiveLibraryResolutionDependency .MAVEN_RESOLVER_API );
77
+ checkDownloadedDependencies (MavenResolverDependencies .MAVEN_RESOLVER_API );
73
78
}
74
79
75
80
/**
76
- * Compares the libraries required by maven-resolver-supplier with the ones declared in {@link TransitiveLibraryResolutionDependency }.
81
+ * Compares the libraries required by maven-resolver-supplier with the ones declared in {@link MavenResolverDependencies }.
77
82
*
78
83
* @param excludedDependencies Optionally excluded more dependencies
79
84
*/
80
- private void checkDownloadedDependencies (TransitiveLibraryResolutionDependency ... excludedDependencies ) {
81
- Set <TransitiveLibraryResolutionDependency > excluded = new HashSet <>();
85
+ private void checkDownloadedDependencies (MavenResolverDependencies ... excludedDependencies ) {
86
+ Set <MavenResolverDependencies > excluded = new HashSet <>();
82
87
// Always exclude javax.inject since it is excluded by maven-resolver-supplier
83
- excluded .add (TransitiveLibraryResolutionDependency .JAVAX_INJECT );
88
+ excluded .add (MavenResolverDependencies .JAVAX_INJECT );
84
89
// Always exclude slf4j-nop since it is not included in maven-resolver-supplier
85
- excluded .add (TransitiveLibraryResolutionDependency .SLF4J_NOP );
90
+ excluded .add (MavenResolverDependencies .SLF4J_NOP );
86
91
excluded .addAll (Arrays .asList (excludedDependencies ));
87
92
88
93
List <String > loaded = libraryManager .getLoaded ();
89
94
// Assert that the correct amount of libraries has been loaded
90
- assertEquals (TransitiveLibraryResolutionDependency .values ().length - excluded .size (), loaded .size ());
95
+ assertEquals (MavenResolverDependencies .values ().length - excluded .size (), loaded .size ());
91
96
92
- Arrays .stream (TransitiveLibraryResolutionDependency .values ())
97
+ Arrays .stream (MavenResolverDependencies .values ())
93
98
.filter (dep -> !excluded .contains (dep ))
94
- .map (TransitiveLibraryResolutionDependency ::toLibrary )
99
+ .map (MavenResolverDependencies ::toLibrary )
95
100
.forEach (dep -> {
96
101
Path path = libraryManager .getSaveDirectory ().resolve (dep .getPath ()).toAbsolutePath ();
97
102
assertTrue (loaded .contains (path .toString ()));
0 commit comments