use of org.commonjava.maven.ext.core.state.DependencyRemovalState in project pom-manipulation-ext by release-engineering.
the class DependencyRemovalManipulator method init.
/**
* Initialize the {@link DependencyState} 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) {
session.setState(new DependencyRemovalState(session.getUserProperties()));
this.session = session;
}
use of org.commonjava.maven.ext.core.state.DependencyRemovalState in project pom-manipulation-ext by release-engineering.
the class DependencyRemovalManipulator method apply.
private boolean apply(final Project project, final Model model) throws ManipulationException {
final DependencyRemovalState state = session.getState(DependencyRemovalState.class);
logger.info("Applying Dependency changes to: " + ga(project));
List<ProjectRef> dependenciesToRemove = state.getDependencyRemoval();
boolean result = scanDependencies(project.getAllResolvedDependencies(session), dependenciesToRemove, model.getDependencies());
if (model.getDependencyManagement() != null && scanDependencies(project.getResolvedManagedDependencies(session), dependenciesToRemove, model.getDependencyManagement().getDependencies())) {
result = true;
}
final HashMap<Profile, HashMap<ArtifactRef, Dependency>> pd = project.getAllResolvedProfileDependencies(session);
final HashMap<Profile, HashMap<ArtifactRef, Dependency>> pmd = project.getResolvedProfileManagedDependencies(session);
for (Profile profile : pd.keySet()) {
int index = model.getProfiles().indexOf(profile);
if (scanDependencies(pd.get(profile), dependenciesToRemove, model.getProfiles().get(index).getDependencies())) {
result = true;
}
}
for (Profile profile : pmd.keySet()) {
int index = model.getProfiles().indexOf(profile);
DependencyManagement dm = model.getProfiles().get(index).getDependencyManagement();
if (dm != null) {
if (scanDependencies(pmd.get(profile), dependenciesToRemove, dm.getDependencies())) {
result = true;
}
}
}
return result;
}
Aggregations