Search in sources :

Example 1 with DependencyResolutionException

use of org.sonatype.aether.resolution.DependencyResolutionException in project zeppelin by apache.

the class DepInterpreter method interpret.

@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
    PrintStream printStream = new PrintStream(out);
    Console.setOut(printStream);
    out.reset();
    SparkInterpreter sparkInterpreter = getSparkInterpreter();
    if (sparkInterpreter != null && sparkInterpreter.isSparkContextInitialized()) {
        return new InterpreterResult(Code.ERROR, "Must be used before SparkInterpreter (%spark) initialized\n" + "Hint: put this paragraph before any Spark code and " + "restart Zeppelin/Interpreter");
    }
    scala.tools.nsc.interpreter.Results.Result ret = interpret(st);
    Code code = getResultCode(ret);
    try {
        depc.fetch();
    } catch (MalformedURLException | DependencyResolutionException | ArtifactResolutionException e) {
        LOGGER.error("Exception in DepInterpreter while interpret ", e);
        return new InterpreterResult(Code.ERROR, e.toString());
    }
    if (code == Code.INCOMPLETE) {
        return new InterpreterResult(code, "Incomplete expression");
    } else if (code == Code.ERROR) {
        return new InterpreterResult(code, out.toString());
    } else {
        return new InterpreterResult(code, out.toString());
    }
}
Also used : PrintStream(java.io.PrintStream) ArtifactResolutionException(org.sonatype.aether.resolution.ArtifactResolutionException) MalformedURLException(java.net.MalformedURLException) Results(scala.tools.nsc.interpreter.Results) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) DependencyResolutionException(org.sonatype.aether.resolution.DependencyResolutionException) Code(org.apache.zeppelin.interpreter.InterpreterResult.Code)

Example 2 with DependencyResolutionException

use of org.sonatype.aether.resolution.DependencyResolutionException in project sonatype-aether by sonatype.

the class DefaultRepositorySystem method resolveDependencies.

public DependencyResult resolveDependencies(RepositorySystemSession session, DependencyRequest request) throws DependencyResolutionException {
    validateSession(session);
    RequestTrace trace = DefaultRequestTrace.newChild(request.getTrace(), request);
    DependencyResult result = new DependencyResult(request);
    DependencyCollectionException dce = null;
    ArtifactResolutionException are = null;
    if (request.getRoot() != null) {
        result.setRoot(request.getRoot());
    } else if (request.getCollectRequest() != null) {
        CollectResult collectResult;
        try {
            request.getCollectRequest().setTrace(trace);
            collectResult = dependencyCollector.collectDependencies(session, request.getCollectRequest());
        } catch (DependencyCollectionException e) {
            dce = e;
            collectResult = e.getResult();
        }
        result.setRoot(collectResult.getRoot());
        result.setCollectExceptions(collectResult.getExceptions());
    } else {
        throw new IllegalArgumentException("dependency node or collect request missing");
    }
    ArtifactRequestBuilder builder = new ArtifactRequestBuilder(trace);
    DependencyFilter filter = request.getFilter();
    DependencyVisitor visitor = (filter != null) ? new FilteringDependencyVisitor(builder, filter) : builder;
    visitor = new TreeDependencyVisitor(visitor);
    result.getRoot().accept(visitor);
    List<ArtifactRequest> requests = builder.getRequests();
    List<ArtifactResult> results;
    try {
        results = artifactResolver.resolveArtifacts(session, requests);
    } catch (ArtifactResolutionException e) {
        are = e;
        results = e.getResults();
    }
    result.setArtifactResults(results);
    updateNodesWithResolvedArtifacts(results);
    if (dce != null) {
        throw new DependencyResolutionException(result, dce);
    } else if (are != null) {
        throw new DependencyResolutionException(result, are);
    }
    return result;
}
Also used : DependencyCollectionException(org.sonatype.aether.collection.DependencyCollectionException) FilteringDependencyVisitor(org.sonatype.aether.util.graph.FilteringDependencyVisitor) CollectResult(org.sonatype.aether.collection.CollectResult) DependencyResult(org.sonatype.aether.resolution.DependencyResult) DependencyFilter(org.sonatype.aether.graph.DependencyFilter) RequestTrace(org.sonatype.aether.RequestTrace) DefaultRequestTrace(org.sonatype.aether.util.DefaultRequestTrace) ArtifactResult(org.sonatype.aether.resolution.ArtifactResult) ArtifactResolutionException(org.sonatype.aether.resolution.ArtifactResolutionException) ArtifactRequest(org.sonatype.aether.resolution.ArtifactRequest) DependencyVisitor(org.sonatype.aether.graph.DependencyVisitor) FilteringDependencyVisitor(org.sonatype.aether.util.graph.FilteringDependencyVisitor) TreeDependencyVisitor(org.sonatype.aether.util.graph.TreeDependencyVisitor) TreeDependencyVisitor(org.sonatype.aether.util.graph.TreeDependencyVisitor) DependencyResolutionException(org.sonatype.aether.resolution.DependencyResolutionException)

Aggregations

ArtifactResolutionException (org.sonatype.aether.resolution.ArtifactResolutionException)2 DependencyResolutionException (org.sonatype.aether.resolution.DependencyResolutionException)2 PrintStream (java.io.PrintStream)1 MalformedURLException (java.net.MalformedURLException)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1 Code (org.apache.zeppelin.interpreter.InterpreterResult.Code)1 RequestTrace (org.sonatype.aether.RequestTrace)1 CollectResult (org.sonatype.aether.collection.CollectResult)1 DependencyCollectionException (org.sonatype.aether.collection.DependencyCollectionException)1 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)1 DependencyVisitor (org.sonatype.aether.graph.DependencyVisitor)1 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)1 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)1 DependencyResult (org.sonatype.aether.resolution.DependencyResult)1 DefaultRequestTrace (org.sonatype.aether.util.DefaultRequestTrace)1 FilteringDependencyVisitor (org.sonatype.aether.util.graph.FilteringDependencyVisitor)1 TreeDependencyVisitor (org.sonatype.aether.util.graph.TreeDependencyVisitor)1 Results (scala.tools.nsc.interpreter.Results)1