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 };
}
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;
}
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();
}
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;
}
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());
}
}
Aggregations