Search in sources :

Example 1 with XMLState

use of org.commonjava.maven.ext.core.state.XMLState in project pom-manipulation-ext by release-engineering.

the class XMLManipulator method applyChanges.

/**
 * Apply the xml changes to the specified file(s).
 */
@Override
public Set<Project> applyChanges(final List<Project> projects) throws ManipulationException {
    final XMLState state = session.getState(XMLState.class);
    if (!session.isEnabled() || !state.isEnabled()) {
        logger.debug(getClass().getSimpleName() + ": Nothing to do!");
        return Collections.emptySet();
    }
    final Set<Project> changed = new HashSet<>();
    final List<XMLState.XMLOperation> scripts = state.getXMLOperations();
    for (final Project project : projects) {
        if (project.isExecutionRoot()) {
            for (XMLState.XMLOperation operation : scripts) {
                internalApplyChanges(project, operation);
                changed.add(project);
            }
            break;
        }
    }
    return changed;
}
Also used : Project(org.commonjava.maven.ext.common.model.Project) XMLState(org.commonjava.maven.ext.core.state.XMLState) HashSet(java.util.HashSet)

Example 2 with XMLState

use of org.commonjava.maven.ext.core.state.XMLState in project pom-manipulation-ext by release-engineering.

the class XMLManipulator method init.

/**
 * Initialize the {@link XMLState} state holder in the {@link ManipulationSession}. This state holder detects
 * configuration from the Maven user properties (-D properties from the CLI) and makes it available for
 * later.
 */
@Override
public void init(final ManipulationSession session) throws ManipulationException {
    this.session = session;
    session.setState(new XMLState(session.getUserProperties()));
}
Also used : XMLState(org.commonjava.maven.ext.core.state.XMLState)

Aggregations

XMLState (org.commonjava.maven.ext.core.state.XMLState)2 HashSet (java.util.HashSet)1 Project (org.commonjava.maven.ext.common.model.Project)1