Search in sources :

Example 1 with ProfileInjectionState

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

the class ProfileInjectionManipulator method init.

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

Example 2 with ProfileInjectionState

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

the class ProfileInjectionManipulator method applyChanges.

/**
 * Apply the profile injection changes to the top level pom.
 */
@Override
public Set<Project> applyChanges(final List<Project> projects) throws ManipulationException {
    final ProfileInjectionState state = session.getState(ProfileInjectionState.class);
    if (!session.isEnabled() || !state.isEnabled()) {
        logger.debug(getClass().getSimpleName() + ": Nothing to do!");
        return Collections.emptySet();
    }
    final Set<Project> changed = new HashSet<>();
    final Model remoteModel = modelBuilder.resolveRawModel(state.getRemoteProfileInjectionMgmt());
    final List<Profile> remoteProfiles = remoteModel.getProfiles();
    for (final Project project : projects) {
        if (project.isInheritanceRoot()) {
            logger.info("Applying changes to: {} ", ga(project));
            project.updateProfiles(remoteProfiles);
            changed.add(project);
            break;
        }
    }
    return changed;
}
Also used : Project(org.commonjava.maven.ext.common.model.Project) Model(org.apache.maven.model.Model) ProfileInjectionState(org.commonjava.maven.ext.core.state.ProfileInjectionState) Profile(org.apache.maven.model.Profile) HashSet(java.util.HashSet)

Aggregations

ProfileInjectionState (org.commonjava.maven.ext.core.state.ProfileInjectionState)2 HashSet (java.util.HashSet)1 Model (org.apache.maven.model.Model)1 Profile (org.apache.maven.model.Profile)1 Project (org.commonjava.maven.ext.common.model.Project)1