Search in sources :

Example 1 with ModuleVersionDetails

use of com.redhat.ceylon.cmr.api.ModuleVersionDetails in project ceylon-compiler by ceylon.

the class CeylonPluginTool method addScripts.

private boolean addScripts(RepositoryManager outputRepositoryManager, ModuleSpec module, boolean errorIfMissing) throws IOException {
    // find all doc folders to zip
    List<File> existingScriptFolders = findExistingScriptFolders(module.getName(), errorIfMissing);
    if (existingScriptFolders.isEmpty()) {
        return false;
    }
    String version;
    if (!module.getName().equals(Module.DEFAULT_MODULE_NAME)) {
        ModuleVersionDetails mvd = getVersionFromSource(module.getName());
        if (mvd == null) {
            errorMsg("error.no.script.version", module.getName());
            return false;
        }
        version = mvd.getVersion();
    } else {
        version = null;
    }
    ArtifactContext artifactScriptsZip = new ArtifactContext(module.getName(), version, ArtifactContext.SCRIPTS_ZIPPED);
    // make the doc zip roots
    IOUtils.ZipRoot[] roots = new IOUtils.ZipRoot[existingScriptFolders.size()];
    int d = 0;
    for (File scriptFolder : existingScriptFolders) {
        roots[d] = new IOUtils.ZipRoot(scriptFolder, "");
    }
    File scriptZipFile = IOUtils.zipFolders(roots);
    File scriptZipSha1File = ShaSigner.sign(scriptZipFile, log, verbose != null);
    if (!repositoryRemoveArtifact(outputRepositoryManager, artifactScriptsZip))
        return true;
    if (!repositoryRemoveArtifact(outputRepositoryManager, artifactScriptsZip.getSha1Context()))
        return true;
    if (!repositoryPutArtifact(outputRepositoryManager, artifactScriptsZip, scriptZipFile))
        return true;
    if (!repositoryPutArtifact(outputRepositoryManager, artifactScriptsZip.getSha1Context(), scriptZipSha1File))
        return true;
    scriptZipFile.delete();
    scriptZipSha1File.delete();
    msg("success.packed", module.getName());
    newline();
    return true;
}
Also used : IOUtils(com.redhat.ceylon.cmr.impl.IOUtils) ModuleVersionDetails(com.redhat.ceylon.cmr.api.ModuleVersionDetails) ArtifactContext(com.redhat.ceylon.cmr.api.ArtifactContext) File(java.io.File)

Example 2 with ModuleVersionDetails

use of com.redhat.ceylon.cmr.api.ModuleVersionDetails in project ceylon-compiler by ceylon.

the class CeylonBrowseTool method run.

@Override
public void run() throws Exception {
    for (ModuleSpec module : modules) {
        List<ModuleVersionDetails> versions = new ArrayList<ModuleVersionDetails>(getModuleVersions(getRepositoryManager(), module.getName(), module.getVersion(), ModuleQuery.Type.ALL, null, null));
        Collections.sort(versions);
        if (versions.isEmpty()) {
            String err = getModuleNotFoundErrorMessage(getRepositoryManager(), module.getName(), module.getVersion());
            errorAppend(err);
            errorNewline();
            continue;
        }
        ModuleVersionDetails mvd = versions.get(versions.size() - 1);
        browseDoc(mvd);
    }
}
Also used : ModuleSpec(com.redhat.ceylon.common.tools.ModuleSpec) ModuleVersionDetails(com.redhat.ceylon.cmr.api.ModuleVersionDetails) ArrayList(java.util.ArrayList)

Example 3 with ModuleVersionDetails

use of com.redhat.ceylon.cmr.api.ModuleVersionDetails in project ceylon-compiler by ceylon.

the class CeylonInfoTool method run.

@Override
public void run() throws Exception {
    if (showIncompatible != Incompatible.yes) {
        binaryMajor = Versions.JVM_BINARY_MAJOR_VERSION;
        binaryMinor = Versions.JVM_BINARY_MINOR_VERSION;
    }
    String msgkey = showIncompatible == Incompatible.no ? "module.not.found.compat" : "module.not.found";
    for (ModuleSpec module : modules) {
        String name = module.getName();
        if (!module.isVersioned() && (name.startsWith("*") || name.endsWith("*"))) {
            Collection<ModuleDetails> modules = getModules(getRepositoryManager(), name, queryType, binaryMajor, binaryMinor);
            if (modules.isEmpty()) {
                String err;
                if (name.startsWith("*") || name.endsWith("*")) {
                    err = CeylonInfoMessages.msg("no.match", name);
                } else {
                    err = getModuleNotFoundErrorMessage(getRepositoryManager(), module.getName(), module.getVersion(), msgkey);
                }
                errorAppend(err);
                errorNewline();
                continue;
            }
            outputModules(module, modules);
        } else {
            Collection<ModuleVersionDetails> versions = getModuleVersions(getRepositoryManager(), module.getName(), module.getVersion(), queryType, binaryMajor, binaryMinor);
            if (versions.isEmpty()) {
                // try from source
                ModuleVersionDetails fromSource = getVersionFromSource(name);
                if (fromSource != null) {
                    // is it the version we're after?
                    versions = Arrays.asList(fromSource);
                } else {
                    if (showIncompatible == Incompatible.auto && (binaryMajor != null || binaryMinor != null)) {
                        // If we were called with a specific version and we didn't find a "compatible"
                        // artifact then lets see if we can find an "incompatible" one
                        versions = getModuleVersions(getRepositoryManager(), module.getName(), module.getVersion(), queryType, null, null);
                    }
                    if (versions.isEmpty()) {
                        String err = getModuleNotFoundErrorMessage(getRepositoryManager(), module.getName(), module.getVersion(), msgkey);
                        errorAppend(err);
                        errorNewline();
                        continue;
                    }
                }
            }
            if (module.getVersion() == null || module.getVersion().isEmpty() || versions.size() > 1) {
                outputVersions(module, versions);
            } else {
                outputDetails(module, versions.iterator().next());
            }
        }
    }
}
Also used : ModuleSpec(com.redhat.ceylon.common.tools.ModuleSpec) ModuleVersionDetails(com.redhat.ceylon.cmr.api.ModuleVersionDetails) ModuleDetails(com.redhat.ceylon.cmr.api.ModuleSearchResult.ModuleDetails)

Example 4 with ModuleVersionDetails

use of com.redhat.ceylon.cmr.api.ModuleVersionDetails in project ceylon-compiler by ceylon.

the class CeylonInfoTool method outputVersions.

private void outputVersions(String moduleName, Collection<ModuleVersionDetails> versions, String prefix) throws IOException {
    String namePrefix = (formatting == Formatting.fancy) ? prefix + "    " : "";
    for (ModuleVersionDetails version : versions) {
        if (formatting == Formatting.fancy || (!showDependencies && !showNames)) {
            append(prefix);
            if (formatting == Formatting.simple) {
                append(moduleName).append("/");
            }
            append(version.getVersion());
            if (formatting == Formatting.fancy) {
                append(" - ").append(version.getOrigin());
                if (hasOnlyIncompatibleBinaries(version)) {
                    append(" ");
                    msg("label.incompatible.version");
                }
                if (version.isRemote()) {
                    append(" ");
                    msg("label.remote");
                }
            }
            newline();
        }
        if (showDependencies) {
            if (formatting == Formatting.fancy || !version.getDependencies().isEmpty()) {
                for (ModuleDependencyInfo dep : version.getDependencies()) {
                    if (formatting == Formatting.fancy) {
                        append(prefix).append("    ").append(dep);
                    } else {
                        append(moduleName).append("/").append(version.getVersion()).append(" ").append(dep.getModuleName());
                    }
                    newline();
                }
            } else {
                append(moduleName).append("/").append(version.getVersion()).newline();
            }
        }
        if (showNames) {
            outputNames(moduleName, version, namePrefix);
        }
    }
}
Also used : ModuleVersionDetails(com.redhat.ceylon.cmr.api.ModuleVersionDetails) ModuleDependencyInfo(com.redhat.ceylon.cmr.api.ModuleDependencyInfo)

Aggregations

ModuleVersionDetails (com.redhat.ceylon.cmr.api.ModuleVersionDetails)4 ModuleSpec (com.redhat.ceylon.common.tools.ModuleSpec)2 ArtifactContext (com.redhat.ceylon.cmr.api.ArtifactContext)1 ModuleDependencyInfo (com.redhat.ceylon.cmr.api.ModuleDependencyInfo)1 ModuleDetails (com.redhat.ceylon.cmr.api.ModuleSearchResult.ModuleDetails)1 IOUtils (com.redhat.ceylon.cmr.impl.IOUtils)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1