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()));
}
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;
}
Aggregations