private Dependency resolveDependency(Collection parents, Dependency dependency, Stack<Dependency> parentStack) throws MissingDependencyException { Artifact artifact = dependency.getArtifact(); // if it is already resolved we are done if (artifact.isResolved()) { return dependency; } // we need an artifact resolver at this point if (artifactResolver == null) { throw new MissingDependencyException("Artifact is not resolved and there no artifact resolver available: " + artifact); } // resolve the artifact try { artifact = artifactResolver.resolveInClassLoader(artifact, parents); } catch (MissingDependencyException e) { // I'm throwing away the original error as the new message is lost on the stack as // most folks will drill down to the message on the bottom of the stack. StringBuffer sb = new StringBuffer(); sb.append(e.getMessage().trim()+"\n"+" Parent stack:\n"); boolean first = true; for (Dependency d : parentStack) { sb.append(" "+d.getArtifact().toString().trim()+(first?" (top)":"")+"\n"); first = false; } throw new MissingDependencyException(sb.toString()); } // build a new dependency object to contain the resolved artifact Dependency resolvedDependency = new Dependency(artifact, dependency.getImportType()); return resolvedDependency; }
public static void printResults(ConsoleReader consoleReader, DownloadResults results, int time) throws IOException, DeploymentException { consoleReader.printNewline(); if (!results.isFailed()) { DeployUtils.println("**** Installation Complete!", 0, consoleReader); for (MissingDependencyException e : results.getSkippedPlugins()) { DeployUtils.println(e.getMessage(), 0, consoleReader); } for (Artifact uri: results.getDependenciesPresent()) { DeployUtils.println("Used existing: " + uri, 0, consoleReader); } for (Artifact uri: results.getDependenciesInstalled()) { DeployUtils.println("Installed new: " + uri, 0, consoleReader); } consoleReader.printNewline(); if (results.getTotalDownloadBytes() > 0 && time > 0) { DeployUtils.println( "Downloaded " + (results.getTotalDownloadBytes() / 1024) + " kB in " + time + "s (" + results.getTotalDownloadBytes() / (1024 * time) + " kB/s)", 0, consoleReader); } } } }