Search in sources :

Example 1 with Manipulator

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

the class ManipulationManager method init.

/**
 * Initialize {@link ManipulationSession} using the given {@link MavenSession} instance, along with any state managed by the individual
 * {@link Manipulator} components.
 *
 * @param session the container session for manipulation.
 * @throws ManipulationException if an error occurs.
 */
public void init(final ManipulationSession session) throws ManipulationException {
    logger.debug("Initialising ManipulationManager with user properties {}", session.getUserProperties());
    for (final ExtensionInfrastructure infra : infrastructure.values()) {
        infra.init(session.getTargetDir(), session.getRemoteRepositories(), session.getLocalRepository(), session.getSettings(), session.getActiveProfiles());
    }
    orderedManipulators = new ArrayList<>(manipulators.values());
    // The RESTState depends upon the VersionState being initialised. Therefore initialise in reverse order
    // and do a final sort to run in the correct order. See the Manipulator interface for detailed discussion
    // on ordered.
    Collections.sort(orderedManipulators, Collections.reverseOrder(new ManipulatorPriorityComparator()));
    for (final Manipulator manipulator : orderedManipulators) {
        logger.debug("Initialising manipulator " + manipulator.getClass().getSimpleName());
        manipulator.init(session);
    }
    Collections.sort(orderedManipulators, new ManipulatorPriorityComparator());
    // Now init the common state
    session.setState(new CommonState(session.getUserProperties()));
}
Also used : CommonState(org.commonjava.maven.ext.core.state.CommonState) ExtensionInfrastructure(org.commonjava.maven.ext.io.resolver.ExtensionInfrastructure) ManipulatorPriorityComparator(org.commonjava.maven.ext.core.util.ManipulatorPriorityComparator) Manipulator(org.commonjava.maven.ext.core.impl.Manipulator)

Aggregations

Manipulator (org.commonjava.maven.ext.core.impl.Manipulator)1 CommonState (org.commonjava.maven.ext.core.state.CommonState)1 ManipulatorPriorityComparator (org.commonjava.maven.ext.core.util.ManipulatorPriorityComparator)1 ExtensionInfrastructure (org.commonjava.maven.ext.io.resolver.ExtensionInfrastructure)1