Java Code Examples for org.apache.ivy.core.module.descriptor.ModuleDescriptor#getConfiguration()

The following examples show how to use org.apache.ivy.core.module.descriptor.ModuleDescriptor#getConfiguration() . 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
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 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 4
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 5
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 6
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 7
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 8
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 9
Source File: XmlModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testImportConfigurationsWithExtendOtherConfigs() throws Exception {
    // import configurations and default mapping
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-configextendsothers2.xml"), true);
    assertNotNull(md);

    // has an 'all-public' configuration
    Configuration allPublic = md.getConfiguration("all-public");
    assertNotNull(allPublic);

    // 'all-public' extends all other public configurations
    String[] allPublicExt = allPublic.getExtends();
    assertEquals(Arrays.asList("default", "test", "extra"),
        Arrays.asList(allPublicExt));
}
 
Example 10
Source File: LazyDependencyToModuleResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void checkDescriptor(ComponentMetaData metaData) {
    ModuleDescriptor moduleDescriptor = metaData.getDescriptor();
    for (Configuration configuration : moduleDescriptor.getConfigurations()) {
        for (String parent : configuration.getExtends()) {
            if (moduleDescriptor.getConfiguration(parent) == null) {
                throw new ModuleVersionResolveException(metaData.getId(), String.format("Configuration '%s' extends unknown configuration '%s' in module descriptor for %%s.", configuration.getName(), parent));
            }
        }
    }
}
 
Example 11
Source File: LazyDependencyToModuleResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void checkDescriptor(ComponentMetaData metaData) {
    ModuleDescriptor moduleDescriptor = metaData.getDescriptor();
    for (Configuration configuration : moduleDescriptor.getConfigurations()) {
        for (String parent : configuration.getExtends()) {
            if (moduleDescriptor.getConfiguration(parent) == null) {
                throw new ModuleVersionResolveException(metaData.getId(), String.format("Configuration '%s' extends unknown configuration '%s' in module descriptor for %%s.", configuration.getName(), parent));
            }
        }
    }
}
 
Example 12
Source File: AbstractModuleDescriptorParserTester.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected void assertConf(ModuleDescriptor md, String name, String desc, Visibility visibility,
        String[] exts) {
    Configuration conf = md.getConfiguration(name);
    assertNotNull("configuration not found: " + name, conf);
    assertEquals(name, conf.getName());
    assertEquals(desc, conf.getDescription());
    assertEquals(visibility, conf.getVisibility());
    assertEquals(Arrays.asList(exts), Arrays.asList(conf.getExtends()));
}
 
Example 13
Source File: XmlModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testExtendOtherConfigs() throws Exception {
    // import configurations and default mapping
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-configextendsothers1.xml"), true);
    assertNotNull(md);

    // has an 'all-public' configuration
    Configuration allPublic = md.getConfiguration("all-public");
    assertNotNull(allPublic);

    // 'all-public' extends all other public configurations
    String[] allPublicExt = allPublic.getExtends();
    assertEquals(Arrays.asList("default", "test"), Arrays.asList(allPublicExt));
}