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

The following examples show how to use org.apache.ivy.core.module.descriptor.DependencyDescriptor#getModuleConfigurations() . 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
public Set<ConfigurationMetaData> resolveTargetConfigurations(DependencyMetaData dependencyMetaData, ConfigurationMetaData fromConfiguration, ComponentResolveMetaData targetComponent) {
    // TODO - resolve directly to config meta data
    ModuleDescriptor targetDescriptor = targetComponent.getDescriptor();
    DependencyDescriptor dependencyDescriptor = dependencyMetaData.getDescriptor();
    Set<String> targetConfigurationNames = new LinkedHashSet<String>();
    for (String config : dependencyDescriptor.getModuleConfigurations()) {
        if (config.equals("*") || config.equals("%")) {
            collectTargetConfiguration(dependencyDescriptor, fromConfiguration, fromConfiguration.getName(), targetDescriptor, targetConfigurationNames);
        } else if (fromConfiguration.getHierarchy().contains(config)) {
            collectTargetConfiguration(dependencyDescriptor, fromConfiguration, config, targetDescriptor, targetConfigurationNames);
        }
    }

    Set<ConfigurationMetaData> targets = new LinkedHashSet<ConfigurationMetaData>();
    for (String targetConfigurationName : targetConfigurationNames) {
        // TODO - move this down below
        if (targetDescriptor.getConfiguration(targetConfigurationName) == null) {
            throw new RuntimeException(String.format("Module version %s, configuration '%s' declares a dependency on configuration '%s' which is not declared in the module descriptor for %s",
                    fromConfiguration.getComponent().getId(), fromConfiguration.getName(),
                    targetConfigurationName, targetComponent.getId()));
        }
        ConfigurationMetaData targetConfiguration = targetComponent.getConfiguration(targetConfigurationName);
        targets.add(targetConfiguration);
    }
    return targets;
}
 
Example 2
Source File: DefaultDependencyToConfigurationResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Set<ConfigurationMetaData> resolveTargetConfigurations(DependencyMetaData dependencyMetaData, ConfigurationMetaData fromConfiguration, ComponentMetaData targetComponent) {
    // TODO - resolve directly to config meta data
    ModuleDescriptor targetDescriptor = targetComponent.getDescriptor();
    DependencyDescriptor dependencyDescriptor = dependencyMetaData.getDescriptor();
    Set<String> targetConfigurationNames = new LinkedHashSet<String>();
    for (String config : dependencyDescriptor.getModuleConfigurations()) {
        if (config.equals("*") || config.equals("%")) {
            collectTargetConfiguration(dependencyDescriptor, fromConfiguration, fromConfiguration.getName(), targetDescriptor, targetConfigurationNames);
        } else if (fromConfiguration.getHierarchy().contains(config)) {
            collectTargetConfiguration(dependencyDescriptor, fromConfiguration, config, targetDescriptor, targetConfigurationNames);
        }
    }

    Set<ConfigurationMetaData> targets = new LinkedHashSet<ConfigurationMetaData>();
    for (String targetConfigurationName : targetConfigurationNames) {
        // TODO - move this down below
        if (targetDescriptor.getConfiguration(targetConfigurationName) == null) {
            throw new RuntimeException(String.format("Module version %s, configuration '%s' declares a dependency on configuration '%s' which is not declared in the module descriptor for %s",
                    fromConfiguration.getComponent().getId(), fromConfiguration.getName(),
                    targetConfigurationName, targetComponent.getId()));
        }
        ConfigurationMetaData targetConfiguration = targetComponent.getConfiguration(targetConfigurationName);
        targets.add(targetConfiguration);
    }
    return targets;
}
 
Example 3
Source File: DefaultDependencyToConfigurationResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Set<ConfigurationMetaData> resolveTargetConfigurations(DependencyMetaData dependencyMetaData, ConfigurationMetaData fromConfiguration, ComponentResolveMetaData targetComponent) {
    // TODO - resolve directly to config meta data
    ModuleDescriptor targetDescriptor = targetComponent.getDescriptor();
    DependencyDescriptor dependencyDescriptor = dependencyMetaData.getDescriptor();
    Set<String> targetConfigurationNames = new LinkedHashSet<String>();
    for (String config : dependencyDescriptor.getModuleConfigurations()) {
        if (config.equals("*") || config.equals("%")) {
            collectTargetConfiguration(dependencyDescriptor, fromConfiguration, fromConfiguration.getName(), targetDescriptor, targetConfigurationNames);
        } else if (fromConfiguration.getHierarchy().contains(config)) {
            collectTargetConfiguration(dependencyDescriptor, fromConfiguration, config, targetDescriptor, targetConfigurationNames);
        }
    }

    Set<ConfigurationMetaData> targets = new LinkedHashSet<ConfigurationMetaData>();
    for (String targetConfigurationName : targetConfigurationNames) {
        // TODO - move this down below
        if (targetDescriptor.getConfiguration(targetConfigurationName) == null) {
            throw new RuntimeException(String.format("Module version %s, configuration '%s' declares a dependency on configuration '%s' which is not declared in the module descriptor for %s",
                    fromConfiguration.getComponent().getId(), fromConfiguration.getName(),
                    targetConfigurationName, targetComponent.getId()));
        }
        ConfigurationMetaData targetConfiguration = targetComponent.getConfiguration(targetConfigurationName);
        targets.add(targetConfiguration);
    }
    return targets;
}
 
Example 4
Source File: DefaultDependencyToConfigurationResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Set<ConfigurationMetaData> resolveTargetConfigurations(DependencyMetaData dependencyMetaData, ConfigurationMetaData fromConfiguration, ComponentMetaData targetComponent) {
    // TODO - resolve directly to config meta data
    ModuleDescriptor targetDescriptor = targetComponent.getDescriptor();
    DependencyDescriptor dependencyDescriptor = dependencyMetaData.getDescriptor();
    Set<String> targetConfigurationNames = new LinkedHashSet<String>();
    for (String config : dependencyDescriptor.getModuleConfigurations()) {
        if (config.equals("*") || config.equals("%")) {
            collectTargetConfiguration(dependencyDescriptor, fromConfiguration, fromConfiguration.getName(), targetDescriptor, targetConfigurationNames);
        } else if (fromConfiguration.getHierarchy().contains(config)) {
            collectTargetConfiguration(dependencyDescriptor, fromConfiguration, config, targetDescriptor, targetConfigurationNames);
        }
    }

    Set<ConfigurationMetaData> targets = new LinkedHashSet<ConfigurationMetaData>();
    for (String targetConfigurationName : targetConfigurationNames) {
        // TODO - move this down below
        if (targetDescriptor.getConfiguration(targetConfigurationName) == null) {
            throw new RuntimeException(String.format("Module version %s, configuration '%s' declares a dependency on configuration '%s' which is not declared in the module descriptor for %s",
                    fromConfiguration.getComponent().getId(), fromConfiguration.getName(),
                    targetConfigurationName, targetComponent.getId()));
        }
        ConfigurationMetaData targetConfiguration = targetComponent.getConfiguration(targetConfigurationName);
        targets.add(targetConfiguration);
    }
    return targets;
}
 
Example 5
Source File: XmlModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
protected static void printDependency(ModuleDescriptor md, DependencyDescriptor dep,
        PrintWriter out) {
    final ModuleRevisionId dependencyRevisionId = dep.getDependencyRevisionId();
    out.print(String.format("<dependency org=\"%s\" name=\"%s\"",
            XMLHelper.escape(dependencyRevisionId.getOrganisation()),
            XMLHelper.escape(dependencyRevisionId.getName())));
    if (dependencyRevisionId.getBranch() != null) {
        out.print(" branch=\"" + XMLHelper.escape(dependencyRevisionId.getBranch()) + "\"");
    }
    out.print(" rev=\"" + XMLHelper.escape(dependencyRevisionId.getRevision()) + "\"");
    final ModuleRevisionId dynamicConstraintDependencyRevisionId =
            dep.getDynamicConstraintDependencyRevisionId();
    if (!dynamicConstraintDependencyRevisionId.equals(dependencyRevisionId)) {
        if (dynamicConstraintDependencyRevisionId.getBranch() != null) {
            out.print(" branchConstraint=\""
                    + XMLHelper.escape(dynamicConstraintDependencyRevisionId.getBranch())
                    + "\"");
        }
        out.print(" revConstraint=\""
                + XMLHelper.escape(dynamicConstraintDependencyRevisionId.getRevision())
                + "\"");
    }
    if (dep.isForce()) {
        out.print(" force=\"" + dep.isForce() + "\"");
    }
    if (dep.isChanging()) {
        out.print(" changing=\"" + dep.isChanging() + "\"");
    }
    if (!dep.isTransitive()) {
        out.print(" transitive=\"" + dep.isTransitive() + "\"");
    }
    StringBuilder sb = new StringBuilder();
    for (String modConf : dep.getModuleConfigurations()) {
        if (sb.length() > 0) {
            sb.append(";");
        }
        sb.append(XMLHelper.escape(modConf)).append(
                listToPrefixedString(dep.getDependencyConfigurations(modConf), "->"));
    }
    out.print(" conf=\"" + sb + "\"");

    printExtraAttributes(dep, out, " ");

    DependencyArtifactDescriptor[] depArtifacts = dep.getAllDependencyArtifacts();
    if (depArtifacts.length > 0) {
        out.println(">");
    }
    printDependencyArtefacts(md, out, depArtifacts);

    IncludeRule[] includes = dep.getAllIncludeRules();
    if (includes.length > 0 && depArtifacts.length == 0) {
        out.println(">");
    }
    printDependencyIncludeRules(md, out, includes);

    ExcludeRule[] excludes = dep.getAllExcludeRules();
    if (excludes.length > 0 && includes.length == 0 && depArtifacts.length == 0) {
        out.println(">");
    }
    printDependencyExcludeRules(md, out, excludes);
    if (includes.length + excludes.length + depArtifacts.length == 0) {
        out.println("/>");
    } else {
        out.println("\t\t</dependency>");
    }
}