Search in sources :

Example 26 with DependencyResolver

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()]);
}
Also used : HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

Example 27 with DependencyResolver

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()]);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with DependencyResolver

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()]);
}
Also used : HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

Example 29 with DependencyResolver

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);
}
Also used : DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

Example 30 with DependencyResolver

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;
}
Also used : DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver) WorkspaceChainResolver(org.apache.ivy.plugins.resolver.WorkspaceChainResolver)

Aggregations

DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)50 Test (org.junit.Test)23 ModuleDescriptorParserRegistryTest (org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)11 ChainResolver (org.apache.ivy.plugins.resolver.ChainResolver)11 File (java.io.File)10 Ivy (org.apache.ivy.Ivy)9 HashMap (java.util.HashMap)8 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)8 URL (java.net.URL)7 HashSet (java.util.HashSet)7 Map (java.util.Map)7 LinkedHashSet (java.util.LinkedHashSet)6 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)6 IvySettings (org.apache.ivy.core.settings.IvySettings)6 FileSystemResolver (org.apache.ivy.plugins.resolver.FileSystemResolver)6 ParseException (java.text.ParseException)5 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)5 IvyRepResolver (org.apache.ivy.plugins.resolver.IvyRepResolver)5 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)4 ModuleId (org.apache.ivy.core.module.id.ModuleId)4