Search in sources :

Example 1 with MavenRepositoryInfo

use of org.jetbrains.idea.maven.model.MavenRepositoryInfo in project intellij-community by JetBrains.

the class ArtifactoryRepositoryService method getRepositories.

@NotNull
@Override
public List<MavenRepositoryInfo> getRepositories(@NotNull String url) throws IOException {
    try {
        final Gson gson = new Gson();
        final InputStreamReader stream = new InputStreamReader(new Endpoint.Repositories(url).getRepositoryDetailsListJson(null).getInputStream());
        final ArtifactoryModel.RepositoryType[] repos = gson.fromJson(stream, ArtifactoryModel.RepositoryType[].class);
        final List<MavenRepositoryInfo> result = new ArrayList<>(repos.length);
        for (ArtifactoryModel.RepositoryType repo : repos) {
            result.add(convert(repo));
        }
        return result;
    } catch (JsonSyntaxException e) {
        return Collections.emptyList();
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) MavenRepositoryInfo(org.jetbrains.idea.maven.model.MavenRepositoryInfo) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) IOException(java.io.IOException) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) JsonSyntaxException(com.google.gson.JsonSyntaxException) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with MavenRepositoryInfo

use of org.jetbrains.idea.maven.model.MavenRepositoryInfo in project intellij-community by JetBrains.

the class NexusRepositoryService method getRepositories.

@NotNull
@Override
public List<MavenRepositoryInfo> getRepositories(@NotNull String url) throws IOException {
    try {
        List<RepositoryType> repos = new Endpoint.Repositories(url).getRepolistAsRepositories().getData().getRepositoriesItem();
        List<MavenRepositoryInfo> result = new ArrayList<>(repos.size());
        for (RepositoryType repo : repos) {
            if (!"maven2".equals(repo.getProvider()))
                continue;
            result.add(convertRepositoryInfo(repo));
        }
        return result;
    } catch (UnmarshalException e) {
        return Collections.emptyList();
    } catch (JAXBException e) {
        throw new IOException(e);
    }
}
Also used : UnmarshalException(javax.xml.bind.UnmarshalException) MavenRepositoryInfo(org.jetbrains.idea.maven.model.MavenRepositoryInfo) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with MavenRepositoryInfo

use of org.jetbrains.idea.maven.model.MavenRepositoryInfo in project intellij-community by JetBrains.

the class RepositoryAttachDialog method getRepositories.

@NotNull
public List<MavenRepositoryInfo> getRepositories() {
    final Pair<MavenArtifactInfo, MavenRepositoryInfo> artifactAndRepo = myCoordinates.get(getCoordinateText());
    final MavenRepositoryInfo repository = artifactAndRepo == null ? null : artifactAndRepo.second;
    return repository != null ? Collections.singletonList(repository) : ContainerUtil.findAll(myRepositories.values(), Condition.NOT_NULL);
}
Also used : MavenRepositoryInfo(org.jetbrains.idea.maven.model.MavenRepositoryInfo) MavenArtifactInfo(org.jetbrains.idea.maven.model.MavenArtifactInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with MavenRepositoryInfo

use of org.jetbrains.idea.maven.model.MavenRepositoryInfo in project intellij-community by JetBrains.

the class JUnit4IntegrationTest method before.

@Before
public void before() throws Throwable {
    EdtTestUtil.runInEdtAndWait(() -> {
        setUp();
        Module module = createEmptyModule();
        String communityPath = PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/');
        String methodName = myNameRule.getMethodName();
        methodName = methodName.substring(0, methodName.indexOf("["));
        String testDataPath = communityPath + File.separator + "plugins" + File.separator + "junit5_rt_tests" + File.separator + "testData" + File.separator + "integration" + File.separator + methodName;
        MavenId mavenId = new MavenId("junit", "junit", myJUnitVersion);
        MavenRepositoryInfo repositoryInfo = new MavenRepositoryInfo("maven", "maven", "http://maven.labs.intellij.net/repo1");
        RepositoryAttachHandler.doResolveInner(getProject(), mavenId, Collections.emptyList(), Collections.singleton(repositoryInfo), artifacts -> {
            for (MavenArtifact artifact : artifacts) {
                ModuleRootModificationUtil.addModuleLibrary(module, VfsUtilCore.pathToUrl(artifact.getPath()));
            }
            return true;
        }, new DumbProgressIndicator());
        ModuleRootModificationUtil.setModuleSdk(module, JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk());
        ModuleRootModificationUtil.updateModel(module, model -> {
            ContentEntry contentEntry = model.addContentEntry(VfsUtilCore.pathToUrl(testDataPath));
            contentEntry.addSourceFolder(VfsUtilCore.pathToUrl(testDataPath + File.separator + "test"), true);
            CompilerModuleExtension moduleExtension = model.getModuleExtension(CompilerModuleExtension.class);
            moduleExtension.inheritCompilerOutputPath(false);
            moduleExtension.setCompilerOutputPathForTests(VfsUtilCore.pathToUrl(testDataPath + File.separator + "out"));
        });
    });
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) ContentEntry(com.intellij.openapi.roots.ContentEntry) MavenRepositoryInfo(org.jetbrains.idea.maven.model.MavenRepositoryInfo) Module(com.intellij.openapi.module.Module) DumbProgressIndicator(com.intellij.openapi.progress.DumbProgressIndicator) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact) CompilerModuleExtension(com.intellij.openapi.roots.CompilerModuleExtension) Before(org.junit.Before)

Aggregations

MavenRepositoryInfo (org.jetbrains.idea.maven.model.MavenRepositoryInfo)4 NotNull (org.jetbrains.annotations.NotNull)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Gson (com.google.gson.Gson)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 Module (com.intellij.openapi.module.Module)1 DumbProgressIndicator (com.intellij.openapi.progress.DumbProgressIndicator)1 CompilerModuleExtension (com.intellij.openapi.roots.CompilerModuleExtension)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1 InputStreamReader (java.io.InputStreamReader)1 JAXBException (javax.xml.bind.JAXBException)1 UnmarshalException (javax.xml.bind.UnmarshalException)1 MavenArtifact (org.jetbrains.idea.maven.model.MavenArtifact)1 MavenArtifactInfo (org.jetbrains.idea.maven.model.MavenArtifactInfo)1 MavenId (org.jetbrains.idea.maven.model.MavenId)1 Before (org.junit.Before)1