use of org.commonjava.maven.ext.core.state.ProfileRemovalState in project pom-manipulation-ext by release-engineering.
the class ProfileRemovalManipulator method applyChanges.
/**
* Apply the profile removal changes to all pom files.
*/
@Override
public Set<Project> applyChanges(final List<Project> projects) {
final ProfileRemovalState state = session.getState(ProfileRemovalState.class);
if (!session.isEnabled() || !state.isEnabled()) {
logger.debug(getClass().getSimpleName() + ": Nothing to do!");
return Collections.emptySet();
}
final List<String> profilesToRemove = state.getProfileRemoval();
final Set<Project> changed = new HashSet<>();
for (final Project project : projects) {
final String ga = ga(project);
logger.info("Applying changes to: " + ga);
final Model model = project.getModel();
final List<Profile> profiles = model.getProfiles();
Iterator<Profile> i = profiles.iterator();
while (i.hasNext()) {
Profile p = i.next();
for (String id : profilesToRemove) {
if (p.getId().equals(id)) {
logger.debug("Removing profile {}", p.getId());
i.remove();
break;
}
}
}
}
return changed;
}
use of org.commonjava.maven.ext.core.state.ProfileRemovalState in project pom-manipulation-ext by release-engineering.
the class ProfileRemovalManipulator method init.
/**
* Initialize the {@link ProfileRemovalState} 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 ProfileRemovalState(session.getUserProperties()));
}
Aggregations