Search in sources :

Example 6 with DependencyResolver

use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.

the class SearchEngine method listOrganisationEntries.

public OrganisationEntry[] listOrganisationEntries() {
    Set<OrganisationEntry> entries = new HashSet<>();
    for (DependencyResolver resolver : settings.getResolvers()) {
        Map<String, String>[] orgs = resolver.listTokenValues(new String[] { IvyPatternHelper.ORGANISATION_KEY }, new HashMap<String, Object>());
        for (Map<String, String> oe : orgs) {
            String org = oe.get(IvyPatternHelper.ORGANISATION_KEY);
            entries.add(new OrganisationEntry(resolver, org));
        }
    }
    return entries.toArray(new OrganisationEntry[entries.size()]);
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

Example 7 with DependencyResolver

use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.

the class SearchEngine method listModules.

public String[] listModules(String org) {
    Set<String> entries = new HashSet<>();
    Map<String, Object> tokenValues = new HashMap<>();
    tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
    for (DependencyResolver resolver : settings.getResolvers()) {
        Map<String, String>[] modules = resolver.listTokenValues(new String[] { IvyPatternHelper.MODULE_KEY }, tokenValues);
        for (Map<String, String> module : modules) {
            entries.add(module.get(IvyPatternHelper.MODULE_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 8 with DependencyResolver

use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.

the class SearchEngine method listRevisionEntries.

public RevisionEntry[] listRevisionEntries(ModuleEntry module) {
    Set<RevisionEntry> entries = new HashSet<>();
    Map<String, Object> tokenValues = new HashMap<>();
    tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, module.getOrganisation());
    tokenValues.put(IvyPatternHelper.MODULE_KEY, module.getModule());
    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(new RevisionEntry(module, revision.get(IvyPatternHelper.REVISION_KEY)));
        }
    }
    return entries.toArray(new RevisionEntry[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 9 with DependencyResolver

use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.

the class SearchEngine method listModules.

/**
 * List module ids of the module accessible through the current resolvers matching the given mid
 * criteria according to the given matcher.
 * <p>
 * ModuleId are returned in the system namespace.
 * </p>
 *
 * @param moduleCrit ModuleId
 * @param matcher PatternMatcher
 * @return ModuleId[]
 */
public ModuleId[] listModules(ModuleId moduleCrit, PatternMatcher matcher) {
    List<ModuleId> ret = new ArrayList<>();
    Map<String, Object> criteria = new HashMap<>();
    addMatcher(matcher, moduleCrit.getOrganisation(), criteria, IvyPatternHelper.ORGANISATION_KEY);
    addMatcher(matcher, moduleCrit.getName(), criteria, IvyPatternHelper.MODULE_KEY);
    String[] tokensToList = new String[] { IvyPatternHelper.ORGANISATION_KEY, IvyPatternHelper.MODULE_KEY };
    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);
            ModuleId modId = ModuleId.newInstance(org, name);
            ret.add(NameSpaceHelper.transform(modId, resolver.getNamespace().getToSystemTransformer()));
        }
    }
    return ret.toArray(new ModuleId[ret.size()]);
}
Also used : ModuleId(org.apache.ivy.core.module.id.ModuleId) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

Example 10 with DependencyResolver

use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.

the class IvySettings method addResolver.

public synchronized void addResolver(DependencyResolver resolver) {
    if (resolver == null) {
        throw new NullPointerException("null resolver");
    }
    init(resolver);
    resolversMap.put(resolver.getName(), resolver);
    if (resolver instanceof ChainResolver) {
        List<DependencyResolver> subresolvers = ((ChainResolver) resolver).getResolvers();
        for (DependencyResolver dr : subresolvers) {
            addResolver(dr);
        }
    } else if (resolver instanceof DualResolver) {
        DependencyResolver ivyResolver = ((DualResolver) resolver).getIvyResolver();
        if (ivyResolver != null) {
            addResolver(ivyResolver);
        }
        DependencyResolver artifactResolver = ((DualResolver) resolver).getArtifactResolver();
        if (artifactResolver != null) {
            addResolver(artifactResolver);
        }
    }
}
Also used : WorkspaceChainResolver(org.apache.ivy.plugins.resolver.WorkspaceChainResolver) ChainResolver(org.apache.ivy.plugins.resolver.ChainResolver) DualResolver(org.apache.ivy.plugins.resolver.DualResolver) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

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