Search in sources :

Example 1 with Conf2ScopeMapping

use of org.gradle.api.artifacts.maven.Conf2ScopeMapping in project gradle by gradle.

the class DefaultConf2ScopeMappingContainerTest method createTestMappings.

private Map<Configuration, Conf2ScopeMapping> createTestMappings() {
    Map<Configuration, Conf2ScopeMapping> testMappings = new HashMap<Configuration, Conf2ScopeMapping>() {

        {
            Configuration configuration = context.mock(Configuration.class);
            put(configuration, new Conf2ScopeMapping(10, configuration, "scope"));
        }
    };
    return testMappings;
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) HashMap(java.util.HashMap) Conf2ScopeMapping(org.gradle.api.artifacts.maven.Conf2ScopeMapping)

Example 2 with Conf2ScopeMapping

use of org.gradle.api.artifacts.maven.Conf2ScopeMapping in project gradle by gradle.

the class DefaultConf2ScopeMappingContainer method getMappingsWithHighestPriority.

private Set<Conf2ScopeMapping> getMappingsWithHighestPriority(Collection<Configuration> configurations) {
    Integer lastPriority = null;
    Set<Conf2ScopeMapping> result = new HashSet<Conf2ScopeMapping>();
    for (Conf2ScopeMapping conf2ScopeMapping : getMappingsForConfigurations(configurations)) {
        Integer thisPriority = conf2ScopeMapping.getPriority();
        if (lastPriority != null && lastPriority.equals(thisPriority)) {
            result.add(conf2ScopeMapping);
        } else if (lastPriority == null || (thisPriority != null && lastPriority < thisPriority)) {
            lastPriority = thisPriority;
            result = WrapUtil.toSet(conf2ScopeMapping);
        }
    }
    return result;
}
Also used : Conf2ScopeMapping(org.gradle.api.artifacts.maven.Conf2ScopeMapping)

Example 3 with Conf2ScopeMapping

use of org.gradle.api.artifacts.maven.Conf2ScopeMapping in project gradle by gradle.

the class DefaultPomDependenciesConverter method convert.

public List<Dependency> convert(Conf2ScopeMappingContainer conf2ScopeMappingContainer, Set<Configuration> configurations) {
    Map<ModuleDependency, Set<Configuration>> dependencyToConfigurations = createDependencyToConfigurationsMap(configurations);
    Map<ModuleDependency, Conf2ScopeMapping> dependenciesMap = createDependencyToScopeMap(conf2ScopeMappingContainer, dependencyToConfigurations);
    Map<Dependency, Integer> dependenciesWithPriorities = new LinkedHashMap<Dependency, Integer>();
    for (ModuleDependency dependency : dependenciesMap.keySet()) {
        Conf2ScopeMapping conf2ScopeMapping = dependenciesMap.get(dependency);
        String scope = conf2ScopeMapping.getScope();
        Integer priority = conf2ScopeMapping.getPriority() == null ? 0 : conf2ScopeMapping.getPriority();
        Set<Configuration> dependencyConfigurations = dependencyToConfigurations.get(dependency);
        if (dependency.getArtifacts().size() == 0) {
            addFromDependencyDescriptor(dependenciesWithPriorities, dependency, scope, priority, dependencyConfigurations);
        } else {
            addFromArtifactDescriptor(dependenciesWithPriorities, dependency, scope, priority, dependencyConfigurations);
        }
    }
    return new ArrayList<Dependency>(dependenciesWithPriorities.keySet());
}
Also used : Dependency(org.apache.maven.model.Dependency) Conf2ScopeMapping(org.gradle.api.artifacts.maven.Conf2ScopeMapping)

Example 4 with Conf2ScopeMapping

use of org.gradle.api.artifacts.maven.Conf2ScopeMapping in project gradle by gradle.

the class DefaultPomDependenciesConverter method createDependencyToScopeMap.

private Map<ModuleDependency, Conf2ScopeMapping> createDependencyToScopeMap(Conf2ScopeMappingContainer conf2ScopeMappingContainer, Map<ModuleDependency, Set<Configuration>> dependencyToConfigurations) {
    Map<ModuleDependency, Conf2ScopeMapping> dependencyToScope = new LinkedHashMap<ModuleDependency, Conf2ScopeMapping>();
    for (ModuleDependency dependency : dependencyToConfigurations.keySet()) {
        Conf2ScopeMapping conf2ScopeDependencyMapping = conf2ScopeMappingContainer.getMapping(dependencyToConfigurations.get(dependency));
        if (!useScope(conf2ScopeMappingContainer, conf2ScopeDependencyMapping)) {
            continue;
        }
        dependencyToScope.put(findDependency(dependency, conf2ScopeDependencyMapping.getConfiguration()), conf2ScopeDependencyMapping);
    }
    return dependencyToScope;
}
Also used : Conf2ScopeMapping(org.gradle.api.artifacts.maven.Conf2ScopeMapping)

Aggregations

Conf2ScopeMapping (org.gradle.api.artifacts.maven.Conf2ScopeMapping)4 HashMap (java.util.HashMap)1 Dependency (org.apache.maven.model.Dependency)1 Configuration (org.gradle.api.artifacts.Configuration)1