Search in sources :

Example 1 with MavenDependencyKey

use of org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.MavenDependencyKey in project gradle by gradle.

the class GradlePomModuleDescriptorParser method parseImportedDependencyMgts.

/**
 * Parses imported dependency management information.
 *
 * @param parseContext Parse context
 * @param currentDependencyMgts Current dependency management information
 * @return Imported dependency management information
 */
private Map<MavenDependencyKey, PomDependencyMgt> parseImportedDependencyMgts(DescriptorParseContext parseContext, Collection<PomDependencyMgt> currentDependencyMgts) throws IOException, SAXException {
    Map<MavenDependencyKey, PomDependencyMgt> importedDependencyMgts = new LinkedHashMap<>();
    for (PomDependencyMgt currentDependencyMgt : currentDependencyMgts) {
        if (isDependencyImportScoped(currentDependencyMgt)) {
            ModuleComponentSelector importedId = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(currentDependencyMgt.getGroupId(), currentDependencyMgt.getArtifactId()), new DefaultImmutableVersionConstraint(currentDependencyMgt.getVersion()));
            PomReader importedPom = parsePomForSelector(parseContext, importedId, Maps.newHashMap());
            for (Map.Entry<MavenDependencyKey, PomDependencyMgt> entry : importedPom.getDependencyMgt().entrySet()) {
                if (!importedDependencyMgts.containsKey(entry.getKey())) {
                    importedDependencyMgts.put(entry.getKey(), entry.getValue());
                }
            }
        }
    }
    return importedDependencyMgts;
}
Also used : DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) PomDependencyMgt(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.PomDependencyMgt) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) MavenDependencyKey(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.MavenDependencyKey) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with MavenDependencyKey

use of org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.MavenDependencyKey in project gradle by gradle.

the class PomReader method resolveDependencyMgt.

private Map<MavenDependencyKey, PomDependencyMgt> resolveDependencyMgt() {
    Map<MavenDependencyKey, PomDependencyMgt> dependencies = new LinkedHashMap<>();
    dependencies.putAll(pomParent.getDependencyMgt());
    dependencies.putAll(importedDependencyMgts);
    for (PomDependencyMgt dependencyMgt : parseDependencyMgt()) {
        dependencies.put(dependencyMgt.getId(), dependencyMgt);
    }
    return dependencies;
}
Also used : PomDependencyMgt(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.PomDependencyMgt) MavenDependencyKey(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.MavenDependencyKey) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2 MavenDependencyKey (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.MavenDependencyKey)2 PomDependencyMgt (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.PomDependencyMgt)2 Map (java.util.Map)1 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)1 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)1 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)1