use of org.eclipse.ceylon.cmr.api.ModuleVersionDetails in project ceylon by eclipse.
the class AbstractTestTool method findTestVersionInDependecies.
private String findTestVersionInDependecies(ModuleDependencyInfo module, Queue<ModuleDependencyInfo> queue) {
Collection<ModuleVersionDetails> moduleDetailsCollection = getModuleVersions(module.getNamespace(), module.getName(), module.getVersion(), false, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
Iterator<ModuleVersionDetails> moduleDetailsIterator = moduleDetailsCollection.iterator();
if (moduleDetailsIterator.hasNext()) {
ModuleVersionDetails moduleDetails = moduleDetailsIterator.next();
for (ModuleDependencyInfo dependency : moduleDetails.getDependencies()) {
if (dependency.getName().equals("ceylon.test")) {
return dependency.getVersion();
}
if (dependency.getName().equals("ceylon.language")) {
continue;
}
queue.add(dependency);
}
}
return null;
}
use of org.eclipse.ceylon.cmr.api.ModuleVersionDetails in project ceylon by eclipse.
the class AbstractRepository method searchModules.
private void searchModules(Node parent, ModuleQuery query, ModuleSearchResult result, Ret ret) throws GetOut {
List<Node> sortedChildren = new ArrayList<Node>();
for (Node child : parent.getChildren()) sortedChildren.add(child);
Collections.sort(sortedChildren, AlphabeticalNodeComparator);
for (Node child : sortedChildren) {
// Winner of the less aptly-named method
boolean isFolder = !child.hasBinaries();
// ignore non-folders
if (!isFolder)
continue;
// is it a module? does it contains artifacts?
ret.foundRightType = false;
if (!ArtifactContext.isDirectoryName(child.getLabel())) {
// safety check
if (hasChildrenContainingAnyArtifact(child, query, ret)) {
// does it contain an artifact of the type we're looking for?
if (ret.foundRightType) {
// check if we were already done but were checking for a next results
if (ret.stopSearching) {
// we already found enough results but were checking if there
// were more results to be found for paging, so record that
// and stop
result.setHasMoreResults(true);
throw new GetOut();
}
// are we interested in this result or did we need to skip it?
String moduleName = toModuleName(child);
ModuleVersionDetails mvd = getSearchResult(moduleName, child, query);
if (mvd != null) {
if (query.getStart() == null || ret.found++ >= query.getStart()) {
result.addResult(moduleName, mvd);
// stop if we're done searching
if (query.getStart() != null && query.getCount() != null && ret.found >= query.getStart() + query.getCount()) {
// we're done, but we want to see if there's at least one more result
// to be found so we can tell clients there's a next page
ret.stopSearching = true;
}
}
}
}
} else {
// it doesn't contain artifacts, it's probably leading to modules
searchModules(child, query, result, ret);
}
}
}
}
use of org.eclipse.ceylon.cmr.api.ModuleVersionDetails in project ceylon by eclipse.
the class AbstractRepository method getSearchResult.
private ModuleVersionDetails getSearchResult(String moduleName, Node namePart, ModuleQuery query) {
SortedSet<String> versions = new TreeSet<String>();
String[] suffixes = query.getType().getSuffixes();
for (Node child : namePart.getChildren()) {
// Winner of the less aptly-named method
boolean isFolder = !child.hasBinaries();
// ignore non-folders
if (!isFolder)
continue;
// now make sure at least one of the artifacts we're looking for is in there
String version = child.getLabel();
// When we need to find ALL requested suffixes we maintain a set of those not found yet
HashSet<String> suffixesToFind = null;
if (query.getRetrieval() == Retrieval.ALL) {
suffixesToFind = new HashSet<String>(Arrays.asList(suffixes));
}
// try every requested suffix
for (String suffix : suffixes) {
String artifactName = getArtifactName(moduleName, version, suffix);
Node artifact = child.getChild(artifactName);
if (artifact != null) {
if (shouldCheckBinaryVersion(suffix) && !checkBinaryVersion(moduleName, version, artifact, query, suffix)) {
continue;
}
if (query.getRetrieval() == Retrieval.ANY) {
// we found the artifact: store it
versions.add(version);
break;
} else {
// Retrieval.ALL
suffixesToFind.remove(suffix);
}
}
}
if (query.getRetrieval() == Retrieval.ALL && suffixesToFind.isEmpty()) {
// we found the artifact and all of the requested suffixes: store it
versions.add(version);
}
}
// sanity check
if (versions.isEmpty()) {
// We didn't find any versions so we silently skip this result
return null;
}
// find the latest version
String latestVersion = versions.last();
Node versionChild = namePart.getChild(latestVersion);
if (versionChild == null)
throw new RuntimeException("Assertion failed: we didn't find the version child for " + moduleName + "/" + latestVersion);
String memberName = query.getMemberName();
// null group/artifact and fill it up later
ModuleVersionDetails mvd = new ModuleVersionDetails(getNamespace(), moduleName, latestVersion, null, null);
boolean found = false;
// Now try to retrieve information for each of the suffixes
for (String suffix : suffixes) {
Node artifact;
// make sure we don't try to read info from source artifacts
if (ArtifactContext.SRC.equals(suffix)) {
artifact = getBestInfoArtifact(versionChild);
if (artifact == null)
continue;
suffix = ArtifactContext.getSuffixFromNode(artifact);
} else {
String artifactName = getArtifactName(moduleName, latestVersion, suffix);
artifact = versionChild.getChild(artifactName);
}
if (artifact == null)
continue;
// let's see if we can extract some information
switch(addArtifactInfo(artifact, moduleName, latestVersion, suffix, memberName, mvd, query)) {
case INFO_FOUND:
found = true;
// cool, go on
break;
case NO_MATCH:
return null;
case OTHER:
// nothing;
break;
}
}
if (!found)
return null;
mvd.setRemote(root.isRemote());
mvd.setOrigin(getDisplayString());
return mvd;
}
use of org.eclipse.ceylon.cmr.api.ModuleVersionDetails in project ceylon by eclipse.
the class ModuleCopycat method copyModuleInternal.
private void copyModuleInternal(ArtifactContext context) throws Exception {
assert (context != null);
if (!shouldExclude(context.getName())) {
String module = ModuleUtil.makeModuleName(context.getName(), context.getVersion());
// Skip all duplicates and artifacts from repositories that don't support copying
if (!copiedModules.add(module) || !canBeCopied(context)) {
// Faking a copy here for feedback because it was already done and we never copy twice
if (feedback != null) {
feedback.beforeCopyModule(context, count++, maxCount);
}
if (feedback != null) {
feedback.afterCopyModule(context, count, maxCount, false);
}
return;
}
Collection<ModuleVersionDetails> versions = getModuleVersions(srcRepoman, context.getName(), context.getVersion(), ModuleQuery.Type.ALL, null, null, null, null);
if (!versions.isEmpty()) {
ArtifactContext depContext = context.copy();
ModuleVersionDetails ver = versions.iterator().next();
boolean copyModule = true;
if (feedback != null) {
copyModule = feedback.beforeCopyModule(context, count++, maxCount);
}
boolean copiedModule = false;
if (copyModule) {
List<ArtifactResult> results = srcRepoman.getArtifactResults(context);
int artCnt = 0;
for (ArtifactResult r : results) {
boolean copyArtifact = true;
if (feedback != null) {
copyArtifact = feedback.beforeCopyArtifact(context, r, artCnt++, results.size());
}
boolean copied = copyArtifact && copyArtifact(context, r);
if (feedback != null) {
feedback.afterCopyArtifact(context, r, artCnt, results.size(), copied);
}
copiedModule |= copied;
}
}
if (feedback != null) {
feedback.afterCopyModule(context, count, maxCount, copiedModule);
}
if (copyModule && !context.isIgnoreDependencies()) {
maxCount += countNonExcludedDeps(ver.getDependencies());
for (ModuleDependencyInfo dep : ver.getDependencies()) {
if (skipDependency(dep)) {
continue;
}
ModuleSpec depModule = new ModuleSpec(dep.getNamespace(), dep.getName(), dep.getVersion());
ArtifactContext copyContext = depContext.copy();
copyContext.setNamespace(dep.getNamespace());
copyContext.setName(depModule.getName());
copyContext.setVersion(depModule.getVersion());
copyModuleInternal(copyContext);
}
}
} else {
if (feedback != null) {
feedback.notFound(context);
}
}
}
}
use of org.eclipse.ceylon.cmr.api.ModuleVersionDetails 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();
}
Aggregations