Java Code Examples for org.apache.ivy.core.module.descriptor.DependencyDescriptor#getDependencyConfigurations()

The following examples show how to use org.apache.ivy.core.module.descriptor.DependencyDescriptor#getDependencyConfigurations() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultDependencyToConfigurationResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void collectTargetConfiguration(DependencyDescriptor dependencyDescriptor, ConfigurationMetaData fromConfiguration, String mappingRhs, ModuleDescriptor targetModule, Collection<String> targetConfigs) {
    String[] dependencyConfigurations = dependencyDescriptor.getDependencyConfigurations(mappingRhs, fromConfiguration.getName());
    for (String target : dependencyConfigurations) {
        String candidate = target;
        int startFallback = candidate.indexOf('(');
        if (startFallback >= 0) {
            if (candidate.charAt(candidate.length() - 1) == ')') {
                String preferred = candidate.substring(0, startFallback);
                if (targetModule.getConfiguration(preferred) != null) {
                    targetConfigs.add(preferred);
                    continue;
                }
                candidate = candidate.substring(startFallback + 1, candidate.length() - 1);
            }
        }
        if (candidate.equals("*")) {
            Collections.addAll(targetConfigs, targetModule.getPublicConfigurationsNames());
            continue;
        }
        targetConfigs.add(candidate);
    }
}
 
Example 2
Source File: DefaultDependencyToConfigurationResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void collectTargetConfiguration(DependencyDescriptor dependencyDescriptor, ConfigurationMetaData fromConfiguration, String mappingRhs, ModuleDescriptor targetModule, Collection<String> targetConfigs) {
    String[] dependencyConfigurations = dependencyDescriptor.getDependencyConfigurations(mappingRhs, fromConfiguration.getName());
    for (String target : dependencyConfigurations) {
        String candidate = target;
        int startFallback = candidate.indexOf('(');
        if (startFallback >= 0) {
            if (candidate.charAt(candidate.length() - 1) == ')') {
                String preferred = candidate.substring(0, startFallback);
                if (targetModule.getConfiguration(preferred) != null) {
                    targetConfigs.add(preferred);
                    continue;
                }
                candidate = candidate.substring(startFallback + 1, candidate.length() - 1);
            }
        }
        if (candidate.equals("*")) {
            Collections.addAll(targetConfigs, targetModule.getPublicConfigurationsNames());
            continue;
        }
        targetConfigs.add(candidate);
    }
}
 
Example 3
Source File: DefaultDependencyToConfigurationResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void collectTargetConfiguration(DependencyDescriptor dependencyDescriptor, ConfigurationMetaData fromConfiguration, String mappingRhs, ModuleDescriptor targetModule, Collection<String> targetConfigs) {
    String[] dependencyConfigurations = dependencyDescriptor.getDependencyConfigurations(mappingRhs, fromConfiguration.getName());
    for (String target : dependencyConfigurations) {
        String candidate = target;
        int startFallback = candidate.indexOf('(');
        if (startFallback >= 0) {
            if (candidate.charAt(candidate.length() - 1) == ')') {
                String preferred = candidate.substring(0, startFallback);
                if (targetModule.getConfiguration(preferred) != null) {
                    targetConfigs.add(preferred);
                    continue;
                }
                candidate = candidate.substring(startFallback + 1, candidate.length() - 1);
            }
        }
        if (candidate.equals("*")) {
            Collections.addAll(targetConfigs, targetModule.getPublicConfigurationsNames());
            continue;
        }
        targetConfigs.add(candidate);
    }
}
 
Example 4
Source File: DefaultDependencyToConfigurationResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void collectTargetConfiguration(DependencyDescriptor dependencyDescriptor, ConfigurationMetaData fromConfiguration, String mappingRhs, ModuleDescriptor targetModule, Collection<String> targetConfigs) {
    String[] dependencyConfigurations = dependencyDescriptor.getDependencyConfigurations(mappingRhs, fromConfiguration.getName());
    for (String target : dependencyConfigurations) {
        String candidate = target;
        int startFallback = candidate.indexOf('(');
        if (startFallback >= 0) {
            if (candidate.charAt(candidate.length() - 1) == ')') {
                String preferred = candidate.substring(0, startFallback);
                if (targetModule.getConfiguration(preferred) != null) {
                    targetConfigs.add(preferred);
                    continue;
                }
                candidate = candidate.substring(startFallback + 1, candidate.length() - 1);
            }
        }
        if (candidate.equals("*")) {
            Collections.addAll(targetConfigs, targetModule.getPublicConfigurationsNames());
            continue;
        }
        targetConfigs.add(candidate);
    }
}
 
Example 5
Source File: PomModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private static DependencyDescriptor[] getDependencies(ModuleDescriptor md,
        PomWriterOptions options) {
    String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);

    List<DependencyDescriptor> result = new ArrayList<>();
    for (DependencyDescriptor dd : md.getDependencies()) {
        String[] depConfs = dd.getDependencyConfigurations(confs);
        if (depConfs != null && depConfs.length > 0) {
            result.add(dd);
        }
    }

    return result.toArray(new DependencyDescriptor[result.size()]);
}
 
Example 6
Source File: IvyNode.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
/**
 * Load the dependencies of the current node
 * <p>
 * The resulting collection of nodes may have some configuration to load
 *
 * @param rootModuleConf
 *            the requested configuration of the root module
 * @param conf
 *            the configuration to load of this node
 * @param requestedConf
 *            the actual node conf requested, possibly extending the <code>conf</code> one.
 * @return {@link Collection} of {@link IvyNode}
 */
public Collection<IvyNode> getDependencies(String rootModuleConf, String conf,
        String requestedConf) {
    if (md == null) {
        throw new IllegalStateException(
                "impossible to get dependencies when data has not been loaded");
    }
    // it's important to respect order => LinkedHashMap
    Map<ModuleRevisionId, IvyNode> dependencies = new LinkedHashMap<>();
    for (DependencyDescriptor dependencyDescriptor : md.getDependencies()) {
        DependencyDescriptor dd = data.mediate(dependencyDescriptor);
        String[] dependencyConfigurations = dd.getDependencyConfigurations(conf, requestedConf);
        if (dependencyConfigurations.length == 0) {
            // no configuration of the dependency is required for current confs :
            // it is exactly the same as if there was no dependency at all on it
            continue;
        }
        ModuleRevisionId requestedDependencyRevisionId = dd.getDependencyRevisionId();
        if (isDependencyModuleExcluded(dd, rootModuleConf, requestedDependencyRevisionId, conf)) {
            // the whole module is excluded, it is considered as not being part of dependencies
            // at all
            Message.verbose("excluding " + dd + " in " + conf);
            continue;
        }

        // check if not already loaded here
        IvyNode depNode = dependencies.get(requestedDependencyRevisionId);
        if (depNode == null) {
            // check if not already loaded during the resolve session
            depNode = data.getNode(requestedDependencyRevisionId);
        }

        if (depNode == null) {
            depNode = new IvyNode(data, this, dd);
        } else {
            depNode.addDependencyDescriptor(this, dd);
            if (depNode.hasProblem()) {
                // dependency already tried to be resolved, but unsuccessfully
                // nothing special to do
            }

        }
        String[] confsArray = depNode.resolveSpecialConfigurations(dependencyConfigurations);
        Collection<String> confs = Arrays.asList(confsArray);
        depNode.updateConfsToFetch(confs);
        depNode.addRootModuleConfigurations(depNode.usage, rootModuleConf, confsArray);
        depNode.usage.setRequiredConfs(this, conf, confs);

        depNode.addCaller(rootModuleConf, this, conf, requestedConf, dependencyConfigurations,
            dd);
        dependencies.put(requestedDependencyRevisionId, depNode);
    }
    return dependencies.values();
}