Search in sources :

Example 1 with ModuleVersionResult

use of org.eclipse.ceylon.cmr.api.ModuleVersionResult 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 2 with ModuleVersionResult

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

the class RepoUsingTool method getModuleVersions.

protected Collection<ModuleVersionDetails> getModuleVersions(RepositoryManager repoMgr, String namespace, String name, String version, boolean exactVersionMatch, ModuleQuery.Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) {
    ModuleVersionQuery query = getModuleVersionQuery(namespace, name, version, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
    query.setExactVersionMatch(exactVersionMatch);
    ModuleVersionResult result = repoMgr.completeVersions(query);
    NavigableMap<String, ModuleVersionDetails> versionMap = result.getVersions();
    return versionMap.values();
}
Also used : ModuleVersionResult(org.eclipse.ceylon.cmr.api.ModuleVersionResult) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery)

Example 3 with ModuleVersionResult

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

the class ModuleCopycat method getModuleVersions.

private Collection<ModuleVersionDetails> getModuleVersions(RepositoryManager repoMgr, String name, String version, ModuleQuery.Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) {
    ModuleVersionQuery query = new ModuleVersionQuery(null, name, version, type);
    if (jvmBinaryMajor != null) {
        query.setJvmBinaryMajor(jvmBinaryMajor);
    }
    if (jvmBinaryMinor != null) {
        query.setJvmBinaryMinor(jvmBinaryMinor);
    }
    if (jsBinaryMajor != null) {
        query.setJsBinaryMajor(jsBinaryMajor);
    }
    if (jsBinaryMinor != null) {
        query.setJsBinaryMinor(jsBinaryMinor);
    }
    ModuleVersionResult result = repoMgr.completeVersions(query);
    NavigableMap<String, ModuleVersionDetails> versionMap = result.getVersions();
    return versionMap.values();
}
Also used : ModuleVersionResult(org.eclipse.ceylon.cmr.api.ModuleVersionResult) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery)

Example 4 with ModuleVersionResult

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

the class AetherTestCase method testListVersionsAether.

@Test
public void testListVersionsAether() throws Exception {
    CmrRepository repository = createAetherRepository();
    RepositoryManager manager = new SimpleRepositoryManager(repository, log);
    ModuleVersionQuery lookup = new ModuleVersionQuery("com.sparkjava:spark-core", "1.", Type.JAR);
    ModuleVersionResult result = manager.completeVersions(lookup);
    Assert.assertEquals(3, result.getVersions().size());
    Assert.assertNotNull(result.getVersions().get("1.0"));
    Assert.assertNotNull(result.getVersions().get("1.1"));
    Assert.assertNotNull(result.getVersions().get("1.1.1"));
    for (ModuleVersionDetails res : result.getVersions().values()) {
        Assert.assertEquals("Spark\nA Sinatra inspired java web framework\nhttp://www.sparkjava.com", res.getDoc());
        Assert.assertEquals("The Apache Software License, Version 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0.txt", res.getLicense());
        NavigableSet<ModuleDependencyInfo> deps = res.getDependencies();
        List<ModuleDependencyInfo> compileDeps = new ArrayList<>(deps.size());
        for (ModuleDependencyInfo dep : res.getDependencies()) {
            if (dep.getModuleScope() == ModuleScope.COMPILE || dep.getModuleScope() == ModuleScope.PROVIDED)
                compileDeps.add(dep);
        }
        Assert.assertEquals(4, compileDeps.size());
    }
    lookup = new ModuleVersionQuery("com.sparkjava:spark-core", null, Type.JAR);
    result = manager.completeVersions(lookup);
    // Count the version up to 2.3
    int cnt = 0;
    for (ModuleVersionDetails mvd : result.getVersions().values()) {
        cnt++;
        if ("2.3".equals(mvd.getVersion())) {
            break;
        }
    }
    Assert.assertEquals(7, cnt);
    // now check that we only downloaded the POMs for that, and not the jars
    File repo = new File("build/test-classes/maven-settings/repository");
    File folder = new File(repo, "com/sparkjava/spark-core/1.0");
    Assert.assertTrue(new File(folder, "spark-core-1.0.pom").exists());
    Assert.assertFalse(new File(folder, "spark-core-1.0.jar").exists());
    Assert.assertFalse(new File(repo, "org/eclipse/jetty/jetty-server/9.0.2.v20130417/jetty-server-9.0.2.v20130417.jar").exists());
    // this one has a conflict if we do resolve it non-lazily
    lookup = new ModuleVersionQuery("org.hibernate:hibernate-validator", "3.", Type.JAR);
    result = manager.completeVersions(lookup);
    Assert.assertEquals(4, result.getVersions().size());
}
Also used : ModuleVersionResult(org.eclipse.ceylon.cmr.api.ModuleVersionResult) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ArrayList(java.util.ArrayList) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ModuleDependencyInfo(org.eclipse.ceylon.cmr.api.ModuleDependencyInfo) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery) CmrRepository(org.eclipse.ceylon.cmr.api.CmrRepository) File(java.io.File) Test(org.junit.Test)

Example 5 with ModuleVersionResult

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

the class AbstractTest method testListVersions.

protected void testListVersions(String query, String versionQuery, ModuleVersionDetails[] expected, RepositoryManager manager, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor, String memberSearch, ModuleQuery.Type type, ModuleQuery.Retrieval retrieval) throws Exception {
    ModuleVersionQuery lookup = new ModuleVersionQuery(query, versionQuery, type);
    lookup.setRetrieval(retrieval);
    lookup.setJvmBinaryMajor(jvmBinaryMajor);
    lookup.setJvmBinaryMinor(jvmBinaryMinor);
    lookup.setJsBinaryMajor(jsBinaryMajor);
    lookup.setJsBinaryMinor(jsBinaryMinor);
    lookup.setMemberName(memberSearch);
    ModuleVersionResult result = manager.completeVersions(lookup);
    int i = 0;
    Assert.assertEquals(expected.length, result.getVersions().size());
    for (Entry<String, ModuleVersionDetails> entry : result.getVersions().entrySet()) {
        ModuleVersionDetails expectedVersion = expected[i++];
        ModuleVersionDetails version = entry.getValue();
        Assert.assertEquals(expectedVersion.getVersion(), entry.getKey());
        Assert.assertEquals(expectedVersion.getVersion(), version.getVersion());
        if (expectedVersion.getDoc() != null) {
            // Docs can be really big, this let's allow us to ignore them for comparisons
            Assert.assertEquals(expectedVersion.getDoc(), version.getDoc());
        }
        Assert.assertEquals(expectedVersion.getLicense(), version.getLicense());
        Assert.assertEquals(expectedVersion.getAuthors(), version.getAuthors());
        Assert.assertEquals(expectedVersion.getDependencies(), version.getDependencies());
        Assert.assertEquals(expectedVersion.getArtifactTypes(), version.getArtifactTypes());
        Assert.assertEquals(expectedVersion.isRemote(), version.isRemote());
        Assert.assertEquals(expectedVersion.getOrigin(), version.getOrigin());
        Assert.assertEquals(expectedVersion.getNamespace(), version.getNamespace());
    }
}
Also used : ModuleVersionResult(org.eclipse.ceylon.cmr.api.ModuleVersionResult) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery)

Aggregations

ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)5 ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)5 ModuleVersionResult (org.eclipse.ceylon.cmr.api.ModuleVersionResult)5 File (java.io.File)2 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)2 ArrayList (java.util.ArrayList)1 ModuleDependencyInfo (org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)1 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)1 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)1 ContentHandle (org.eclipse.ceylon.cmr.spi.ContentHandle)1 ContentStore (org.eclipse.ceylon.cmr.spi.ContentStore)1 OpenNode (org.eclipse.ceylon.cmr.spi.OpenNode)1 Test (org.junit.Test)1