sijie closed pull request #1135: Specify repo in MavenClassLoader
URL: https://github.com/apache/bookkeeper/pull/1135
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/MavenClassLoader.java
 
b/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/MavenClassLoader.java
index 6f31f5c76..a7091bec1 100644
--- 
a/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/MavenClassLoader.java
+++ 
b/tests/integration-tests-utils/src/main/java/org/apache/bookkeeper/tests/MavenClassLoader.java
@@ -31,6 +31,7 @@
 import java.util.List;
 import java.util.Optional;
 
+import org.jboss.shrinkwrap.resolver.api.maven.ConfigurableMavenResolverSystem;
 import org.jboss.shrinkwrap.resolver.api.maven.Maven;
 import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
 import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependencies;
@@ -48,8 +49,18 @@ private MavenClassLoader(URLClassLoader cl) {
 
     private final URLClassLoader classloader;
 
+    public static MavenClassLoader forArtifact(String repo, String 
mainArtifact) throws Exception {
+        return 
createClassLoader(Maven.configureResolver().withRemoteRepo("custom", repo, 
"default"),
+                                 mainArtifact);
+    }
+
     public static MavenClassLoader forArtifact(String mainArtifact) throws 
Exception {
-        Optional<String> slf4jVersion = 
Arrays.stream(Maven.resolver().resolve(mainArtifact)
+        return createClassLoader(Maven.configureResolver(), mainArtifact);
+    }
+
+    private static MavenClassLoader 
createClassLoader(ConfigurableMavenResolverSystem resolver,
+                                                      String mainArtifact) 
throws Exception {
+        Optional<String> slf4jVersion = 
Arrays.stream(resolver.resolve(mainArtifact)
                                                       
.withTransitivity().asResolvedArtifact())
             .filter((a) -> a.getCoordinate().getGroupId().equals("org.slf4j")
                     && 
a.getCoordinate().getArtifactId().equals("slf4j-log4j12"))
@@ -66,7 +77,7 @@ public static MavenClassLoader forArtifact(String 
mainArtifact) throws Exception
                                                         ScopeType.COMPILE, 
false));
         }
 
-        File[] files = Maven.resolver().addDependencies(deps.toArray(new 
MavenDependency[0]))
+        File[] files = resolver.addDependencies(deps.toArray(new 
MavenDependency[0]))
             .resolve().withTransitivity().asFile();
         URLClassLoader cl = AccessController.doPrivileged(
                 new PrivilegedAction<URLClassLoader>() {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to