Search in sources :

Example 1 with Repository

use of org.apache.zeppelin.dep.Repository in project zeppelin by apache.

the class SparkDependencyContext method fetchArtifactWithDep.

private List<ArtifactResult> fetchArtifactWithDep(Dependency dep) throws DependencyResolutionException, ArtifactResolutionException {
    Artifact artifact = new DefaultArtifact(SparkDependencyResolver.inferScalaVersion(dep.getGroupArtifactVersion()));
    DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
    PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(SparkDependencyResolver.inferScalaVersion(dep.getExclusions()));
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
    collectRequest.addRepository(mavenCentral);
    collectRequest.addRepository(mavenLocal);
    for (RemoteRepository repo : additionalRepos) {
        collectRequest.addRepository(repo);
    }
    for (Repository repo : repositories) {
        RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
        rr.setPolicy(repo.isSnapshot(), null);
        Authentication auth = repo.getAuthentication();
        if (auth != null) {
            rr.setAuthentication(auth);
        }
        collectRequest.addRepository(rr);
    }
    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
Also used : Repository(org.apache.zeppelin.dep.Repository) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) DependencyRequest(org.sonatype.aether.resolution.DependencyRequest) Authentication(org.sonatype.aether.repository.Authentication) DependencyFilter(org.sonatype.aether.graph.DependencyFilter) PatternExclusionsDependencyFilter(org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) CollectRequest(org.sonatype.aether.collection.CollectRequest) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) PatternExclusionsDependencyFilter(org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter)

Example 2 with Repository

use of org.apache.zeppelin.dep.Repository in project zeppelin by apache.

the class SparkDependencyContext method addRepo.

public Repository addRepo(String name) {
    Repository rep = new Repository(name);
    repositories.add(rep);
    return rep;
}
Also used : Repository(org.apache.zeppelin.dep.Repository) RemoteRepository(org.sonatype.aether.repository.RemoteRepository)

Example 3 with Repository

use of org.apache.zeppelin.dep.Repository in project zeppelin by apache.

the class InterpreterRestApi method addRepository.

/**
 * Add new repository.
 *
 * @param message Repository
 */
@POST
@Path("repository")
@ZeppelinApi
public Response addRepository(String message) {
    try {
        Repository request = Repository.fromJson(message);
        interpreterSettingManager.addRepository(request.getId(), request.getUrl(), request.isSnapshot(), request.getAuthentication(), request.getProxy());
        LOGGER.info("New repository {} added", request.getId());
    } catch (Exception e) {
        LOGGER.error("Exception in InterpreterRestApi while adding repository ", e);
        return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, e.getMessage(), ExceptionUtils.getStackTrace(e)).build();
    }
    return new JsonResponse<>(Status.OK).build();
}
Also used : Repository(org.apache.zeppelin.dep.Repository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) IOException(java.io.IOException) JsonResponse(org.apache.zeppelin.server.JsonResponse) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) POST(javax.ws.rs.POST)

Aggregations

Repository (org.apache.zeppelin.dep.Repository)3 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)2 IOException (java.io.IOException)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)1 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)1 JsonResponse (org.apache.zeppelin.server.JsonResponse)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 Artifact (org.sonatype.aether.artifact.Artifact)1 CollectRequest (org.sonatype.aether.collection.CollectRequest)1 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)1 Authentication (org.sonatype.aether.repository.Authentication)1 DependencyRequest (org.sonatype.aether.resolution.DependencyRequest)1 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)1 PatternExclusionsDependencyFilter (org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter)1