Search in sources :

Example 1 with ModuleVersionQuery

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

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

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

the class CeylonInfoTool method getModuleVersionQuery.

@Override
protected ModuleVersionQuery getModuleVersionQuery(String namespace, String name, String version, ModuleQuery.Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) {
    ModuleVersionQuery query = super.getModuleVersionQuery(namespace, name, version, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
    if (findMember != null) {
        query.setMemberName(findMember);
    }
    if (findPackage != null) {
        query.setMemberName(findPackage);
        query.setMemberSearchPackageOnly(true);
    }
    query.setMemberSearchExact(exactMatch);
    if (requireAll) {
        query.setRetrieval(ModuleQuery.Retrieval.ALL);
    }
    return query;
}
Also used : ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery)

Example 4 with ModuleVersionQuery

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

the class LegacyImporter method findSuggestions.

private Set<ModuleDetails> findSuggestions(String pkg) {
    Set<ModuleDetails> suggestions = new TreeSet<>();
    ModuleVersionQuery query = new ModuleVersionQuery(null, "", null, ModuleQuery.Type.JVM);
    query.setJvmBinaryMajor(Versions.JVM_BINARY_MAJOR_VERSION);
    query.setJvmBinaryMinor(Versions.JVM_BINARY_MINOR_VERSION);
    query.setMemberName(pkg);
    query.setMemberSearchExact(true);
    query.setMemberSearchPackageOnly(true);
    ModuleSearchResult result = lookupRepoman.completeModules(query);
    for (ModuleDetails mvd : result.getResults()) {
        suggestions.add(mvd);
    }
    return suggestions;
}
Also used : TreeSet(java.util.TreeSet) ModuleDetails(org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult)

Example 5 with ModuleVersionQuery

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

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