use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class SearchEngine method listRevisions.
public String[] listRevisions(String org, String module) {
Set<String> entries = new HashSet<>();
Map<String, Object> tokenValues = new HashMap<>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
tokenValues.put(IvyPatternHelper.MODULE_KEY, module);
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] revisions = resolver.listTokenValues(new String[] { IvyPatternHelper.REVISION_KEY }, tokenValues);
for (Map<String, String> revision : revisions) {
entries.add(revision.get(IvyPatternHelper.REVISION_KEY));
}
}
return entries.toArray(new String[entries.size()]);
}
use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class SearchEngine method listModules.
/**
* List module revision ids of the module accessible through the current resolvers matching the
* given mrid criteria according to the given matcher.
* <p>
* ModuleRevisionId are returned in the system namespace.
* </p>
*
* @param moduleCrit ModuleRevisionId
* @param matcher PatternMatcher
* @return ModuleRevisionId[]
*/
public ModuleRevisionId[] listModules(ModuleRevisionId moduleCrit, PatternMatcher matcher) {
List<ModuleRevisionId> ret = new ArrayList<>();
Map<String, Object> criteria = new HashMap<>();
for (Map.Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
addMatcher(matcher, entry.getValue(), criteria, entry.getKey());
}
String[] tokensToList = moduleCrit.getAttributes().keySet().toArray(new String[moduleCrit.getAttributes().size()]);
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
for (Map<String, String> moduleId : moduleIdAsMap) {
String org = moduleId.get(IvyPatternHelper.ORGANISATION_KEY);
String name = moduleId.get(IvyPatternHelper.MODULE_KEY);
String branch = moduleId.get(IvyPatternHelper.BRANCH_KEY);
String rev = moduleId.get(IvyPatternHelper.REVISION_KEY);
Map<String, String> foundExtraAtts = new HashMap<>();
for (String qualifiedKey : moduleCrit.getQualifiedExtraAttributes().keySet()) {
String value = null;
int colonIndex = qualifiedKey.indexOf(':');
if (colonIndex == -1) {
value = moduleId.get(qualifiedKey);
} else {
value = moduleId.get(qualifiedKey.substring(colonIndex + 1));
}
if (value != null) {
foundExtraAtts.put(qualifiedKey, value);
}
}
ModuleRevisionId modRevId = ModuleRevisionId.newInstance(org, name, branch, rev, foundExtraAtts);
ret.add(resolver.getNamespace().getToSystemTransformer().transform(modRevId));
}
}
return ret.toArray(new ModuleRevisionId[ret.size()]);
}
use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class SearchEngine method listModuleEntries.
public ModuleEntry[] listModuleEntries(OrganisationEntry org) {
Set<ModuleEntry> entries = new HashSet<>();
Map<String, Object> tokenValues = new HashMap<>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
for (DependencyResolver resolver : settings.getResolvers()) {
Map<String, String>[] modules = resolver.listTokenValues(new String[] { IvyPatternHelper.MODULE_KEY }, tokenValues);
for (Map<String, String> me : modules) {
String module = me.get(IvyPatternHelper.MODULE_KEY);
entries.add(new ModuleEntry(org, module));
}
}
return entries.toArray(new ModuleEntry[entries.size()]);
}
use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class IvySettings method getResolver.
public synchronized DependencyResolver getResolver(ModuleRevisionId mrid) {
DependencyResolver r = getDictatorResolver();
if (r != null) {
return r;
}
String resolverName = getResolverName(mrid);
return getResolver(resolverName);
}
use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class IvySettings method getResolver.
public synchronized DependencyResolver getResolver(String resolverName) {
DependencyResolver r = getDictatorResolver();
if (r != null) {
return r;
}
DependencyResolver resolver = resolversMap.get(resolverName);
if (resolver == null) {
Message.error("unknown resolver " + resolverName);
} else if (workspaceResolver != null && !(resolver instanceof WorkspaceChainResolver)) {
resolver = new WorkspaceChainResolver(this, resolver, workspaceResolver);
resolversMap.put(resolver.getName(), resolver);
resolversMap.put(resolverName, resolver);
}
return resolver;
}
Aggregations