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;
}
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;
}
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());
}
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;
}
Aggregations