Search in sources :

Example 1 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class RepoUsingTool method getModuleNotFoundErrorMessage.

protected String getModuleNotFoundErrorMessage(RepositoryManager repoMgr, String name, String version, String msgkeyNotFound) {
    StringBuilder err = new StringBuilder();
    String descr = version == null ? name : name + "/" + version;
    err.append(Messages.msg(bundle, msgkeyNotFound, descr));
    err.append("\n");
    boolean fullySearchable = true;
    for (CmrRepository repo : repoMgr.getRepositories()) {
        if (version != null || repo.isSearchable()) {
            err.append("    ");
            err.append(repo.getDisplayString());
            err.append("\n");
        } else {
            fullySearchable = false;
        }
    }
    if (version == null && !fullySearchable) {
        err.append(Messages.msg(bundle, "missing.version.suggestion"));
    }
    return err.toString();
}
Also used : CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository)

Example 2 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class RepoUsingTool method findCompiledVersions.

private Collection<ModuleVersionDetails> findCompiledVersions(RepositoryManager repoMgr, String name, Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) throws IOException {
    String outRepo = DefaultToolOptions.getCompilerOutputRepo();
    if (outRepo != null) {
        File outDir = new File(outRepo);
        CmrRepository rep = null;
        List<CmrRepository> repositories = repoMgr.getRepositories();
        for (CmrRepository repository : repositories) {
            OpenNode root = repository.getRoot();
            // it has binaries if it is not a folder
            if (root.isRemote() || root.hasBinaries())
                continue;
            ContentStore service = root.getService(ContentStore.class);
            if (service == null)
                continue;
            ContentHandle content = service.peekContent(root);
            // again skip binaries
            if (content == null || content.hasBinaries())
                continue;
            File repoFile = content.getContentAsFile();
            if (repoFile != null && FileUtil.sameFile(repoFile, outDir)) {
                rep = repository;
                break;
            }
        }
        if (rep != null && rep.isSearchable()) {
            ModuleVersionQuery query = getModuleVersionQuery(null, name, null, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
            ModuleVersionResult result = new ModuleVersionResult(query.getName());
            rep.completeVersions(query, result);
            NavigableMap<String, ModuleVersionDetails> outRepoVersions = result.getVersions();
            if (!outRepoVersions.isEmpty()) {
                return outRepoVersions.values();
            }
        }
    }
    return null;
}
Also used : ModuleVersionResult(org.eclipse.ceylon.cmr.api.ModuleVersionResult) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode) ContentStore(org.eclipse.ceylon.cmr.spi.ContentStore)

Example 3 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class ModuleLoaderTest method testNoDotsFromMavenWithOverrides.

@Test
public void testNoDotsFromMavenWithOverrides() throws ModuleNotFoundException {
    CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
    Overrides ov = RepositoryManagerBuilder.parseOverrides(overrides);
    Assert.assertTrue(ov.getAddedArtifacts().isEmpty());
    RepositoryManager manager = new SimpleRepositoryManager(repository, log, ov);
    Map<String, String> extraModules = new HashMap<>();
    extraModules.put("org.antlr:stringtemplate", "3.2.1");
    // this one has an override that adds aopalliance:aopalliance/1.0
    extraModules.put("org.postgresql:postgresql", "9.4.1208");
    TestableModuleLoader moduleLoader = new TestableModuleLoader(manager, null, extraModules, true);
    moduleLoader.loadModule("com.google.inject:guice", "4.0", ModuleScope.RUNTIME);
    // Check that we got them
    Assert.assertEquals("2.7.7", moduleLoader.getModuleVersion("maven:antlr:antlr"));
    Assert.assertEquals("1.0", moduleLoader.getModuleVersion("maven:aopalliance:aopalliance"));
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) HashMap(java.util.HashMap) Overrides(org.eclipse.ceylon.cmr.api.Overrides) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) Test(org.junit.Test)

Example 4 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class ModuleLoaderTest method testModuleLoader.

@Test
public void testModuleLoader() throws ModuleNotFoundException {
    CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
    RepositoryManager manager = new SimpleRepositoryManager(repository, log);
    Map<String, String> extraModules = new HashMap<>();
    extraModules.put("org.springframework.boot:spring-boot-starter-web", "1.3.5.RELEASE");
    extraModules.put("org.springframework.boot:spring-boot-starter-undertow", "1.3.5.RELEASE");
    extraModules.put("org.springframework.boot:spring-boot-starter-data-jpa", "1.3.5.RELEASE");
    extraModules.put("org.springframework.cloud:spring-cloud-starter-eureka", "1.1.2.RELEASE");
    extraModules.put("org.postgresql:postgresql", "9.4.1208");
    extraModules.put("org.liquibase:liquibase-core", "3.4.2");
    TestableModuleLoader moduleLoader = new TestableModuleLoader(manager, null, extraModules, false);
    moduleLoader.loadModule("org.liquibase:liquibase-core", "3.4.2", ModuleScope.RUNTIME);
    // Check that we got the latest version
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-core"));
    // Check that this one did not get removed
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-context"));
    // Those two should not be there
    Assert.assertNull(moduleLoader.getModuleVersion("javax.servlet:servlet-api"));
    Assert.assertNull(moduleLoader.getModuleVersion("org.springframework:spring"));
    // Check that we got the runtime dep
    Assert.assertEquals("3.3.6.Final", moduleLoader.getModuleVersion("org.jboss.xnio:xnio-nio"));
    moduleLoader.cleanup();
    moduleLoader.loadModule("org.liquibase:liquibase-core", "3.4.2", ModuleScope.COMPILE);
    // Check that we got the latest version
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-core"));
    // Check that this one did not get removed
    Assert.assertEquals("4.2.6.RELEASE", moduleLoader.getModuleVersion("org.springframework:spring-context"));
    // Those two should not be there
    Assert.assertNull(moduleLoader.getModuleVersion("javax.servlet:servlet-api"));
    Assert.assertNull(moduleLoader.getModuleVersion("org.springframework:spring"));
    // Check that we have no runtime dep
    Assert.assertNull(moduleLoader.getModuleVersion("org.jboss.xnio:xnio-nio"));
}
Also used : SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) HashMap(java.util.HashMap) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) Test(org.junit.Test)

Example 5 with CmrRepository

use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.

the class AbstractNodeRepositoryManager method fromRepositories.

/**
 * Cache is only used for remote repos; see issue #47.
 */
private Node fromRepositories(Iterable<CmrRepository> repositories, ArtifactContext context, boolean addLeaf) {
    log.debug("Looking for " + context);
    for (CmrRepository repository : repositories) {
        log.debug(" Looking in " + repository);
        if (!repository.supportsNamespace(context.getNamespace())) {
            log.debug(" -> does not support namespace " + context.getNamespace());
            continue;
        }
        Node child = fromRepository(repository, context, addLeaf);
        if (child != null) {
            log.debug(" -> Found");
            return child;
        }
        log.debug("  -> Not Found");
    }
    log.debug(" -> Artifact " + context + " not found in any repository");
    return null;
}
Also used : OpenNode(org.eclipse.ceylon.cmr.spi.OpenNode) Node(org.eclipse.ceylon.cmr.spi.Node) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository)

Aggregations

CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)43 File (java.io.File)26 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)26 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)24 Test (org.junit.Test)24 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)15 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)9 RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)8 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 OpenNode (org.eclipse.ceylon.cmr.spi.OpenNode)5 DefaultRepository (org.eclipse.ceylon.cmr.impl.DefaultRepository)4 Node (org.eclipse.ceylon.cmr.spi.Node)3 IOException (java.io.IOException)2 URL (java.net.URL)2 TreeSet (java.util.TreeSet)2 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)2 ModuleSearchResult (org.eclipse.ceylon.cmr.api.ModuleSearchResult)2 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)2 ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)2