Search in sources :

Example 6 with ModuleVersionQuery

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

use of org.eclipse.ceylon.cmr.api.ModuleVersionQuery 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)

Example 8 with ModuleVersionQuery

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

the class CeylonInfoTool method getModules.

private Collection<ModuleDetails> getModules(RepositoryManager repoMgr, String namespace, String name, ModuleQuery.Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) {
    String queryString = name;
    if (queryString.startsWith("*")) {
        queryString = queryString.substring(1);
    }
    if (queryString.endsWith("*")) {
        queryString = queryString.substring(0, queryString.length() - 1);
    }
    ModuleVersionQuery query = getModuleVersionQuery(namespace, queryString, null, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
    ModuleSearchResult result;
    if (!name.startsWith("*") || name.equals("*")) {
        result = repoMgr.completeModules(query);
    } else {
        result = repoMgr.searchModules(query);
    }
    return result.getResults();
}
Also used : ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult)

Aggregations

ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)8 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)5 ModuleVersionResult (org.eclipse.ceylon.cmr.api.ModuleVersionResult)5 File (java.io.File)2 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)2 ModuleSearchResult (org.eclipse.ceylon.cmr.api.ModuleSearchResult)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 ModuleDependencyInfo (org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)1 ModuleDetails (org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails)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