Search in sources :

Example 1 with PomProfile

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

the class PomReader method parseActivePomProfiles.

/**
 * Parses all active profiles that can be found in POM.
 *
 * @return Active POM profiles
 */
private List<PomProfile> parseActivePomProfiles() {
    if (declaredActivePomProfiles == null) {
        List<PomProfile> activeByDefaultPomProfiles = new ArrayList<PomProfile>();
        List<PomProfile> activeByAbsenceOfPropertyPomProfiles = new ArrayList<PomProfile>();
        Element profilesElement = getFirstChildElement(projectElement, PROFILES);
        if (profilesElement != null) {
            for (Element profileElement : getAllChilds(profilesElement)) {
                if (PROFILE.equals(profileElement.getNodeName())) {
                    Element activationElement = getFirstChildElement(profileElement, PROFILE_ACTIVATION);
                    if (activationElement != null) {
                        String activeByDefault = getFirstChildText(activationElement, PROFILE_ACTIVATION_ACTIVE_BY_DEFAULT);
                        if (activeByDefault != null && "true".equals(activeByDefault)) {
                            activeByDefaultPomProfiles.add(new PomProfileElement(profileElement));
                        } else {
                            Element propertyElement = getFirstChildElement(activationElement, PROFILE_ACTIVATION_PROPERTY);
                            if (propertyElement != null) {
                                if (isActivationPropertyActivated(propertyElement)) {
                                    activeByAbsenceOfPropertyPomProfiles.add(new PomProfileElement(profileElement));
                                }
                            }
                        }
                    }
                }
            }
        }
        declaredActivePomProfiles = determineActiveProfiles(activeByDefaultPomProfiles, activeByAbsenceOfPropertyPomProfiles);
    }
    return declaredActivePomProfiles;
}
Also used : Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) PomProfile(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.PomProfile)

Example 2 with PomProfile

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

the class PomReader method parseDependencyMgt.

/**
 * Parses the dependency management elements declared in this POM without removing the duplicates.
 *
 * @return Parsed dependency management elements
 */
public List<PomDependencyMgt> parseDependencyMgt() {
    if (declaredDependencyMgts == null) {
        List<PomDependencyMgt> dependencyMgts = getDependencyMgt(projectElement);
        for (PomProfile pomProfile : parseActivePomProfiles()) {
            for (PomDependencyMgt dependencyMgt : pomProfile.getDependencyMgts()) {
                dependencyMgts.add(dependencyMgt);
            }
        }
        declaredDependencyMgts = dependencyMgts;
    }
    return declaredDependencyMgts;
}
Also used : PomDependencyMgt(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.PomDependencyMgt) PomProfile(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.PomProfile)

Aggregations

PomProfile (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.PomProfile)2 ArrayList (java.util.ArrayList)1 PomDependencyMgt (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.data.PomDependencyMgt)1 Element (org.w3c.dom.Element)1