Search in sources :

Example 11 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class CompatTests method runCompiled1299With121MainApiDowngrade.

@Ignore("Removed until we can create compiled modules with alternate versions")
@Test
public void runCompiled1299With121MainApiDowngrade() throws Throwable {
    File err = File.createTempFile("compattest", "out");
    try {
        mainApiClasspath("test/src/org/eclipse/ceylon/compiler/java/test/compat/modules", new ModuleSpec(null, "compiled1299", "1.0.0"), Collections.<ModuleSpec>emptyList(), 1, err, false);
        assertFileContainsLine(err, "Module org.eclipse.ceylon.typechecker/1.2.99 not found in the following repositories:");
    } finally {
        err.delete();
    }
}
Also used : ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class LanguageCompiler method addDependenciesToAptPath.

private void addDependenciesToAptPath(RepositoryManager repositoryManager, ModuleSpec moduleSpec, Set<ModuleSpec> visited, StatusPrinterAptProgressListener progressListener) {
    if (!visited.add(moduleSpec))
        return;
    String ns = ModuleUtil.getNamespaceFromUri(moduleSpec.getName());
    String name = ModuleUtil.getModuleNameFromUri(moduleSpec.getName());
    ArtifactContext context = new ArtifactContext(ns, name, moduleSpec.getVersion(), ArtifactContext.JAR, ArtifactContext.CAR);
    if (progressListener != null)
        progressListener.retrievingModuleArtifact(moduleSpec, context);
    ArtifactResult result = repositoryManager.getArtifactResult(context);
    if (progressListener != null) {
        if (result == null) {
            progressListener.retrievingModuleArtifactFailed(moduleSpec, context);
        } else {
            progressListener.retrievingModuleArtifactSuccess(moduleSpec, result);
        }
    }
    ceylonEnter.addModuleToAptPath(moduleSpec, result);
    for (ArtifactResult dep : result.dependencies()) {
        if (JDKUtils.isJDKModule(dep.name()) || JDKUtils.isOracleJDKModule(dep.name())) {
            continue;
        }
        // we are running deps, so we need compile/provided/runtime, but not test
        if (dep.moduleScope() == ModuleScope.TEST)
            continue;
        ModuleSpec depSpec = new ModuleSpec(dep.namespace(), dep.name(), dep.version());
        addDependenciesToAptPath(repositoryManager, depSpec, visited, progressListener);
    }
}
Also used : ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 13 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class CeylonPluginTool method installScripts.

private boolean installScripts(RepositoryManager repositoryManager, ModuleSpec module, boolean errorIfMissing) throws IOException {
    String version = module.getVersion();
    if ((version == null || version.isEmpty()) && !module.getName().equals(Module.DEFAULT_MODULE_NAME)) {
        version = checkModuleVersionsOrShowSuggestions(module.getName(), null, ModuleQuery.Type.ALL, null, null, null, null);
        if (version == null)
            return false;
    }
    module = new ModuleSpec(module.getNamespace(), module.getName(), version);
    File zipSource = null;
    List<File> existingScriptFolders = null;
    if (isSourceModule(module.getName(), version, applyCwd(sourceFolders))) {
        // copy it directly from the source
        existingScriptFolders = findExistingScriptFolders(module.getName(), errorIfMissing);
        if (existingScriptFolders.isEmpty()) {
            return false;
        }
    } else {
        // obtain it from the repo
        ArtifactContext context = new ArtifactContext(null, module.getName(), version, ArtifactContext.SCRIPTS_ZIPPED);
        ArtifactResult result = repositoryManager.getArtifactResult(context);
        if (result == null) {
            String err = getModuleNotFoundErrorMessage(repositoryManager, module.getName(), version);
            errorAppend(err);
            errorNewline();
            return false;
        }
        zipSource = result.artifact();
    }
    File moduleScriptDir = getModuleScriptDir(module);
    ModuleSpec unversioned = new ModuleSpec(module.getNamespace(), module.getName(), "");
    if (existScripts(unversioned)) {
        if (force) {
            uninstallScripts(unversioned, false);
        } else {
            errorMsg("error.module.already.installed", module.getName(), moduleScriptDir);
            return false;
        }
    }
    if (!FileUtil.mkdirs(moduleScriptDir)) {
        errorMsg("error.unable.create.dest.dir", moduleScriptDir);
        return false;
    }
    if (zipSource != null)
        extractScripts(zipSource, moduleScriptDir);
    else {
        copyScripts(existingScriptFolders, moduleScriptDir);
    }
    msg("success.installed", module.getName(), moduleScriptDir);
    newline();
    return true;
}
Also used : ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 14 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class CeylonP2Tool method printUnitFeature.

private void printUnitFeature(XMLStreamWriter writer, Feature feature, boolean group) throws XMLStreamException {
    writer.writeStartElement("unit");
    String name = feature.name + (group ? ".feature.group" : ".feature.jar");
    writer.writeAttribute("id", name);
    writer.writeAttribute("version", feature.version);
    if (group) {
        writer.writeAttribute("singleton", "false");
        {
            writer.writeEmptyElement("update");
            writer.writeAttribute("id", name);
            writer.writeAttribute("range", "[0.0.0," + feature.version + ")");
            writer.writeAttribute("severity", "0");
        }
    }
    {
        writer.writeStartElement("properties");
        SortedMap<String, String> properties = feature.getProperties();
        writer.writeAttribute("size", String.valueOf(properties.size() + (group ? 1 : 0)));
        for (Map.Entry<String, String> property : properties.entrySet()) {
            writer.writeEmptyElement("property");
            writer.writeAttribute("name", property.getKey());
            writer.writeAttribute("value", property.getValue());
        }
        if (group) {
            writer.writeEmptyElement("property");
            writer.writeAttribute("name", "org.eclipse.equinox.p2.type.group");
            writer.writeAttribute("value", "true");
        }
        writer.writeEndElement();
    }
    {
        writer.writeStartElement("provides");
        writer.writeAttribute("size", group ? "1" : "3");
        {
            writer.writeEmptyElement("provided");
            writer.writeAttribute("namespace", "org.eclipse.equinox.p2.iu");
            writer.writeAttribute("name", name);
            writer.writeAttribute("version", feature.version);
        }
        if (!group) {
            {
                writer.writeEmptyElement("provided");
                writer.writeAttribute("namespace", "org.eclipse.equinox.p2.eclipse.type");
                writer.writeAttribute("name", "feature");
                writer.writeAttribute("version", "1.0.0");
            }
            {
                writer.writeEmptyElement("provided");
                writer.writeAttribute("namespace", "org.eclipse.update.feature");
                writer.writeAttribute("name", feature.name);
                writer.writeAttribute("version", feature.version);
            }
        }
        writer.writeEndElement();
    }
    if (group) {
        writer.writeStartElement("requires");
        List<ModuleSpec> importedModules = feature.getImportedModules();
        writer.writeAttribute("size", String.valueOf(importedModules.size() + 1));
        for (ModuleSpec mod : importedModules) {
            writer.writeEmptyElement("required");
            writer.writeAttribute("namespace", "org.eclipse.equinox.p2.iu");
            writer.writeAttribute("name", mod.getName());
            writer.writeAttribute("range", "[" + mod.getVersion() + "," + mod.getVersion() + "]");
        }
        {
            writer.writeStartElement("required");
            writer.writeAttribute("namespace", "org.eclipse.equinox.p2.iu");
            writer.writeAttribute("name", feature.name + ".feature.jar");
            writer.writeAttribute("range", "[" + feature.version + "," + feature.version + "]");
            {
                writer.writeStartElement("filter");
                writer.writeCharacters("(org.eclipse.update.install.features=true)");
                writer.writeEndElement();
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
    } else {
        writer.writeStartElement("filter");
        writer.writeCharacters("(org.eclipse.update.install.features=true)");
        writer.writeEndElement();
        {
            writer.writeStartElement("artifacts");
            writer.writeAttribute("size", "1");
            {
                writer.writeEmptyElement("artifact");
                writer.writeAttribute("classifier", "org.eclipse.update.feature");
                writer.writeAttribute("id", feature.name);
                writer.writeAttribute("version", feature.version);
            }
            writer.writeEndElement();
        }
    }
    {
        writer.writeEmptyElement("touchpoint");
        writer.writeAttribute("id", group ? "null" : "org.eclipse.equinox.p2.osgi");
        writer.writeAttribute("version", group ? "0.0.0" : "1.0.0");
    }
    if (!group) {
        writer.writeStartElement("touchpointData");
        writer.writeAttribute("size", "1");
        {
            writer.writeStartElement("instructions");
            writer.writeAttribute("size", "1");
            {
                writer.writeStartElement("instruction");
                writer.writeAttribute("key", "zipped");
                writer.writeCharacters("true");
                writer.writeEndElement();
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
    }
    {
        writer.writeStartElement("licenses");
        writer.writeAttribute("size", "1");
        {
            writer.writeStartElement("license");
            writer.writeAttribute("uri", "");
            writer.writeAttribute("url", "");
            writer.writeCharacters(feature.getLicense());
            writer.writeEndElement();
        }
        writer.writeEndElement();
    }
    {
        writer.writeStartElement("copyright");
        writer.writeCharacters(feature.getCopyright());
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
Also used : Entry(java.util.Map.Entry) ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) SortedMap(java.util.SortedMap)

Example 15 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class CeylonP2Tool method run.

@Override
public void run() throws Exception {
    RepositoryManager repoManager = getRepositoryManager();
    Map<String, ModuleInfo> allModules = new HashMap<>();
    for (ModuleSpec module : modules) {
        String version = findModuleVersion(module);
        msg("collecting.modules", module.toString());
        newline();
        collectModules(repoManager, module.getName(), version, allModules);
    }
    // now purge empty modules
    purgeMissingModules(allModules);
    Map<String, Feature> features = collectFeatures();
    Map<String, Category> categoriesByName = null;
    if (categories != null) {
        categoriesByName = parseCategories(features);
    }
    msg("generating.artifacts");
    newline();
    printArtifacts(allModules, features);
    msg("generating.content");
    newline();
    printContent(allModules, features, categoriesByName);
}
Also used : ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) HashMap(java.util.HashMap) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager)

Aggregations

ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)35 File (java.io.File)18 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)13 ArrayList (java.util.ArrayList)11 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)7 IOException (java.io.IOException)6 Test (org.junit.Test)6 ZipFile (java.util.zip.ZipFile)5 ModuleGraph (org.eclipse.ceylon.cmr.ceylon.loader.ModuleGraph)5 HashSet (java.util.HashSet)4 LinkedList (java.util.LinkedList)4 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)4 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)4 List (java.util.List)3 ZipEntry (java.util.zip.ZipEntry)3 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)3 Module (org.eclipse.ceylon.cmr.ceylon.loader.ModuleGraph.Module)3 Ignore (org.junit.Ignore)3 BufferedReader (java.io.BufferedReader)2 FileOutputStream (java.io.FileOutputStream)2