< prev index next >

test/lib/jdk/test/lib/artifacts/JibArtifactManager.java

Print this page

        

@@ -28,24 +28,25 @@
 import java.nio.file.Path;
 import java.util.HashMap;
 import java.util.Map;
 
 public class JibArtifactManager implements ArtifactManager {
+    private static final String JIB_SERVICE_FACTORY = "com.oracle.jib.api.JibServiceFactory";
     private static String jibVersion = "1.0";
     private Object installerObject;
 
     private JibArtifactManager(Object o) {
         installerObject = o;
     }
 
     public static JibArtifactManager newInstance() throws ClassNotFoundException {
         try {
-            Class jibServiceFactory = Class.forName("com.oracle.jib.api.JibServiceFactory");
+            Class jibServiceFactory = Class.forName(JIB_SERVICE_FACTORY);
             Object jibArtifactInstaller = jibServiceFactory.getMethod("createJibArtifactInstaller").invoke(null);
             return new JibArtifactManager(jibArtifactInstaller);
         } catch (Exception e) {
-            throw new ClassNotFoundException();
+            throw new ClassNotFoundException("Could not resolve " + JIB_SERVICE_FACTORY, e);
         }
     }
 
     private Path download(String jibVersion, HashMap<String, Object> artifactDescription) throws Exception {
         return invokeInstallerMethod("download", jibVersion, artifactDescription);

@@ -59,17 +60,17 @@
         Method m = Class.forName("com.oracle.jib.api.JibArtifactInstaller").getMethod(methodName, String.class, Map.class);
         return (Path)m.invoke(installerObject, jibVersion, artifactDescription);
     }
 
     @Override
-    public Path resolve(Artifact artifact) throws FileNotFoundException {
+    public Path resolve(Artifact artifact) throws ArtifactResolverException {
         Path path;
         // Use the DefaultArtifactManager to enable users to override locations
         try {
             ArtifactManager manager = new DefaultArtifactManager();
             path = manager.resolve(artifact);
-        } catch (FileNotFoundException e) {
+        } catch (ArtifactResolverException e) {
             // Location hasn't been overridden, continue to automatically try to resolve the dependency
             try {
                 HashMap<String, Object> artifactDescription = new HashMap<>();
                 artifactDescription.put("module", artifact.name());
                 artifactDescription.put("organization", artifact.organization());

@@ -81,12 +82,12 @@
 
                 path = download(jibVersion, artifactDescription);
                 if (artifact.unpack()) {
                     path = install(jibVersion, artifactDescription);
                 }
-            } catch (Exception exception) {
-                throw new FileNotFoundException("Failed to resolve the artifact " + artifact);
+            } catch (Exception e2) {
+                throw new ArtifactResolverException("Failed to resolve the artifact " + artifact, e2);
             }
         }
         return path;
    }
 }
< prev index next >