use of org.commonjava.maven.ext.core.state.ProjectVersionEnforcingState in project pom-manipulation-ext by release-engineering.
the class ProjectVersionEnforcingManipulator method applyChanges.
/**
* For each project in the current build set, reset the version if using project.version
*/
@Override
public Set<Project> applyChanges(final List<Project> projects) throws ManipulationException {
final ProjectVersionEnforcingState state = session.getState(ProjectVersionEnforcingState.class);
if (!session.isEnabled() || !session.anyStateEnabled(State.activeByDefault) || state == null || !state.isEnabled()) {
logger.debug("Project version enforcement is disabled.");
return Collections.emptySet();
}
final Set<Project> changed = new HashSet<>();
for (final Project project : projects) {
final Model model = project.getModel();
if (model.getPackaging().equals("pom")) {
enforceProjectVersion(project, model.getDependencies(), changed);
if (model.getDependencyManagement() != null) {
enforceProjectVersion(project, model.getDependencyManagement().getDependencies(), changed);
}
final List<Profile> profiles = ProfileUtils.getProfiles(session, model);
if (profiles != null) {
for (final Profile profile : profiles) {
enforceProjectVersion(project, profile.getDependencies(), changed);
if (profile.getDependencyManagement() != null) {
enforceProjectVersion(project, profile.getDependencyManagement().getDependencies(), changed);
}
}
}
}
}
if (!changed.isEmpty()) {
logger.warn("Using ${project.version} in pom files may lead to unexpected errors with inheritance.");
}
return changed;
}
use of org.commonjava.maven.ext.core.state.ProjectVersionEnforcingState in project pom-manipulation-ext by release-engineering.
the class ProjectVersionEnforcingManipulator method init.
/**
* Sets the mode based on user properties and defaults.
* @see ProjectVersionEnforcingState
*/
@Override
public void init(final ManipulationSession session) {
this.session = session;
session.setState(new ProjectVersionEnforcingState(session.getUserProperties()));
}
Aggregations