Search in sources :

Example 36 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project zeppelin by apache.

the class InterpreterSettingManager method loadFromFile.

private void loadFromFile() {
    if (!Files.exists(interpreterBindingPath)) {
        // nothing to read
        return;
    }
    InterpreterInfoSaving infoSaving;
    try (BufferedReader json = Files.newBufferedReader(interpreterBindingPath, StandardCharsets.UTF_8)) {
        infoSaving = gson.fromJson(json, InterpreterInfoSaving.class);
        for (String k : infoSaving.interpreterSettings.keySet()) {
            InterpreterSetting setting = infoSaving.interpreterSettings.get(k);
            List<InterpreterInfo> infos = setting.getInterpreterInfos();
            // Convert json StringMap to Properties
            StringMap<String> p = (StringMap<String>) setting.getProperties();
            Properties properties = new Properties();
            for (String key : p.keySet()) {
                properties.put(key, p.get(key));
            }
            setting.setProperties(properties);
            // Always use separate interpreter process
            // While we decided to turn this feature on always (without providing
            // enable/disable option on GUI).
            // previously created setting should turn this feature on here.
            setting.getOption().setRemote(true);
            // Update transient information from InterpreterSettingRef
            InterpreterSetting interpreterSettingObject = interpreterSettingsRef.get(setting.getGroup());
            if (interpreterSettingObject == null) {
                logger.warn("can't get InterpreterSetting " + "Information From loaded Interpreter Setting Ref - {} ", setting.getGroup());
                continue;
            }
            String depClassPath = interpreterSettingObject.getPath();
            setting.setPath(depClassPath);
            for (InterpreterInfo info : infos) {
                if (info.getEditor() == null) {
                    Map<String, Object> editor = getEditorFromSettingByClassName(interpreterSettingObject, info.getClassName());
                    info.setEditor(editor);
                }
            }
            setting.setInterpreterGroupFactory(interpreterGroupFactory);
            loadInterpreterDependencies(setting);
            interpreterSettings.put(k, setting);
        }
        interpreterBindings.putAll(infoSaving.interpreterBindings);
        if (infoSaving.interpreterRepositories != null) {
            for (RemoteRepository repo : infoSaving.interpreterRepositories) {
                if (!dependencyResolver.getRepos().contains(repo)) {
                    this.interpreterRepositories.add(repo);
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : StringMap(com.google.gson.internal.StringMap) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) IOException(java.io.IOException) Properties(java.util.Properties) BufferedReader(java.io.BufferedReader)

Example 37 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project storm by apache.

the class DependencyResolver method resolve.

public List<ArtifactResult> resolve(List<Dependency> dependencies) throws MalformedURLException, DependencyResolutionException, ArtifactResolutionException {
    DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME);
    if (dependencies.size() == 0) {
        return Collections.EMPTY_LIST;
    }
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(dependencies.get(0));
    for (int idx = 1; idx < dependencies.size(); idx++) {
        collectRequest.addDependency(dependencies.get(idx));
    }
    for (RemoteRepository repository : remoteRepositories) {
        collectRequest.addRepository(repository);
    }
    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
Also used : DependencyRequest(org.sonatype.aether.resolution.DependencyRequest) DependencyFilter(org.sonatype.aether.graph.DependencyFilter) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) CollectRequest(org.sonatype.aether.collection.CollectRequest)

Example 38 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class IniArtifactDataReader method parse.

private ArtifactDescription parse(Reader reader) throws IOException {
    String line = null;
    State state = State.NONE;
    Map<State, List<String>> sections = new HashMap<State, List<String>>();
    BufferedReader in = new BufferedReader(reader);
    try {
        while ((line = in.readLine()) != null) {
            line = cutComment(line);
            if (isEmpty(line)) {
                continue;
            }
            if (line.startsWith("[")) {
                try {
                    state = State.valueOf(line.substring(1, line.length() - 1).toUpperCase(Locale.ENGLISH));
                    sections.put(state, new ArrayList<String>());
                } catch (IllegalArgumentException e) {
                    throw new IOException("unknown section: " + line);
                }
            } else {
                List<String> lines = sections.get(state);
                if (lines == null) {
                    throw new IOException("missing section: " + line);
                }
                lines.add(line.trim());
            }
        }
    } finally {
        in.close();
    }
    List<Artifact> relocations = relocations(sections.get(State.RELOCATIONS));
    List<Dependency> dependencies = dependencies(sections.get(State.DEPENDENCIES));
    List<Dependency> managedDependencies = dependencies(sections.get(State.MANAGEDDEPENDENCIES));
    List<RemoteRepository> repositories = repositories(sections.get(State.REPOSITORIES));
    ArtifactDescription description = new ArtifactDescription(relocations, dependencies, managedDependencies, repositories);
    return description;
}
Also used : HashMap(java.util.HashMap) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) IOException(java.io.IOException) Dependency(org.sonatype.aether.graph.Dependency) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) List(java.util.List)

Example 39 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class IniArtifactDataReader method repositories.

private List<RemoteRepository> repositories(List<String> list) {
    ArrayList<RemoteRepository> ret = new ArrayList<RemoteRepository>();
    if (list == null) {
        return ret;
    }
    for (String coords : list) {
        String[] split = coords.split(":", 3);
        String id = split[0];
        String type = split[1];
        String url = split[2];
        ret.add(new RemoteRepository(id, type, url));
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) RemoteRepository(org.sonatype.aether.repository.RemoteRepository)

Example 40 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class IniArtifactDataReaderTest method testResource.

@Test
public void testResource() throws IOException {
    ArtifactDescription description = parser.parse("ArtifactDataReaderTest.ini");
    assertEquals(1, description.getRelocations().size());
    Artifact artifact = description.getRelocations().get(0);
    assertEquals("gid", artifact.getGroupId());
    assertEquals("aid", artifact.getArtifactId());
    assertEquals("ver", artifact.getVersion());
    assertEquals("ext", artifact.getExtension());
    assertEquals(1, description.getRepositories().size());
    RemoteRepository repo = description.getRepositories().get(0);
    assertEquals("id", repo.getId());
    assertEquals("type", repo.getContentType());
    assertEquals("protocol://some/url?for=testing", repo.getUrl());
    assertDependencies(description.getDependencies());
    assertDependencies(description.getManagedDependencies());
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Aggregations

RemoteRepository (org.sonatype.aether.repository.RemoteRepository)71 Artifact (org.sonatype.aether.artifact.Artifact)30 Test (org.junit.Test)27 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)18 File (java.io.File)15 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)15 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)13 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)13 Dependency (org.sonatype.aether.graph.Dependency)12 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)12 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)12 LocalArtifactRequest (org.sonatype.aether.repository.LocalArtifactRequest)11 CollectRequest (org.sonatype.aether.collection.CollectRequest)10 LocalArtifactResult (org.sonatype.aether.repository.LocalArtifactResult)10 ArrayList (java.util.ArrayList)8 RepositorySystem (org.sonatype.aether.RepositorySystem)8 IOException (java.io.IOException)7 Before (org.junit.Before)7 Metadata (org.sonatype.aether.metadata.Metadata)7 DependencyRequest (org.sonatype.aether.resolution.DependencyRequest)7