Search in sources :

Example 16 with ModuleVersionDetails

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

the class JSUtils method getBinaryVersions.

@Override
public int[] getBinaryVersions(String moduleName, String version, File moduleArchive) {
    int major = 0;
    int minor = 0;
    ModuleVersionDetails mvd = readModuleInfo(moduleName, version, moduleArchive, false, null);
    ModuleVersionArtifact mva = mvd.getArtifactTypes().first();
    if (mva.getMajorBinaryVersion() != null) {
        major = mva.getMajorBinaryVersion();
    }
    if (mva.getMinorBinaryVersion() != null) {
        minor = mva.getMinorBinaryVersion();
    }
    return new int[] { major, minor };
}
Also used : ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ModuleVersionArtifact(org.eclipse.ceylon.cmr.api.ModuleVersionArtifact)

Example 17 with ModuleVersionDetails

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

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 = getModuleVersionDetailsFromSource(module.getName());
        if (mvd == null) {
            errorMsg("error.no.script.version", module.getName());
            return false;
        }
        version = mvd.getVersion();
    } else {
        version = null;
    }
    ArtifactContext artifactScriptsZip = new ArtifactContext(null, 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, getLogger(), 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(org.eclipse.ceylon.cmr.impl.IOUtils) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) File(java.io.File)

Example 18 with ModuleVersionDetails

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

the class SourceDependencyResolver method traverseDependencies.

/**
 * Traverses the given sources finding all dependencies that have
 * their sources available in the source directories
 * @param sourceFiles Iterable of <File> pointing to sources
 * @return A boolean indicating if any additional modules were found
 */
public boolean traverseDependencies(Iterable<File> sourceFiles) {
    originalModules = collectModulesFromSources(sourceFiles);
    allModules = new HashSet<ModuleVersionDetails>(originalModules);
    for (ModuleVersionDetails module : originalModules) {
        collectModulesFromDependencies(allModules, module);
    }
    additionalModules = new HashSet<ModuleVersionDetails>(allModules);
    additionalModules.removeAll(originalModules);
    return !additionalModules.isEmpty();
}
Also used : ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails)

Example 19 with ModuleVersionDetails

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

the class SourceDependencyResolver method collectModulesFromSources.

// Given the list of _all_ source files we return the list of module details
private Set<ModuleVersionDetails> collectModulesFromSources(Iterable<File> sourceFiles) {
    Set<ModuleVersionDetails> modules = new HashSet<ModuleVersionDetails>();
    Set<File> descriptors = collectModuleDescriptorsFromSources(sourceFiles);
    for (File d : descriptors) {
        String moduleName = moduleNameFromDescriptorFile(d);
        ModuleVersionDetails mvd = moduleVersionReader.fromSource(moduleName);
        if (mvd != null) {
            modules.add(mvd);
        }
    }
    return modules;
}
Also used : ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) File(java.io.File) HashSet(java.util.HashSet)

Example 20 with ModuleVersionDetails

use of org.eclipse.ceylon.cmr.api.ModuleVersionDetails 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)32 ModuleDependencyInfo (org.eclipse.ceylon.cmr.api.ModuleDependencyInfo)10 ModuleVersionArtifact (org.eclipse.ceylon.cmr.api.ModuleVersionArtifact)10 File (java.io.File)7 ArrayList (java.util.ArrayList)6 ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)5 ModuleVersionResult (org.eclipse.ceylon.cmr.api.ModuleVersionResult)5 OpenNode (org.eclipse.ceylon.cmr.spi.OpenNode)5 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)4 Node (org.eclipse.ceylon.cmr.spi.Node)4 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)4 HashSet (java.util.HashSet)3 TreeSet (java.util.TreeSet)3 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)3 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)3 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)3 List (java.util.List)2 Map (java.util.Map)2 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)2 ModuleInfo (org.eclipse.ceylon.cmr.api.ModuleInfo)2