use of org.commonjava.maven.ext.core.state.DistributionEnforcingState in project pom-manipulation-ext by release-engineering.
the class DistributionEnforcingManipulator method applyChanges.
/**
* For each project in the current build set, enforce the value of the plugin-wide skip flag and that of the 'default-deploy' execution, if they
* exist. There are three possible modes for enforcement:
*
* <ul>
* <li><b>on</b> - Ensure install and deploy skip is <b>disabled</b>, and that these functions will happen during the build.</li>
* <li><b>off</b> - Ensure install and deploy skip is <b>enabled</b>, and that neither of these functions will happen during the build.</li>
* <li><b>detect</b> - Detect the proper flag value from the install plugin's <code>skip</code> flag (either in the plugin-wide config or the
* <code>default-install</code> execution, if it's specified in the main POM, not a profile). If not present, disable the skip flag.
* Enforce consistency with this value install/deploy.</li>
* </ul>
*
* <b>NOTE:</b> It's possible to specify an enforcement mode that's unique to a single project, using a command-line parameter of:
* <code>-DdistroExclusion.g:a=<mode></code>.
*
* @see DistributionEnforcingState
* @see EnforcingMode
*/
@Override
public Set<Project> applyChanges(final List<Project> projects) throws ManipulationException {
final DistributionEnforcingState state = session.getState(DistributionEnforcingState.class);
if (state == null || !state.isEnabled()) {
logger.debug("Distribution skip-flag enforcement is disabled.");
return Collections.emptySet();
}
final Map<String, String> excluded = state.getExcludedProjects();
final Set<Project> changed = new HashSet<>();
for (final Project project : projects) {
final String ga = ga(project);
EnforcingMode mode = state.getEnforcingMode();
final String override = excluded.get(ga);
if (override != null) {
mode = EnforcingMode.getMode(override);
}
if (mode == EnforcingMode.none) {
logger.debug("Install/Deploy skip-flag enforcement is disabled for: {}.", ga);
continue;
}
logger.debug("Applying skip-flag enforcement mode of: " + mode + " to: " + ga);
final Model model = project.getModel();
// this is 3-value logic, where skip == on == true, don't-skip == off == false, and (detect from install) == detect == null
Boolean baseSkipSetting = mode.defaultModificationValue();
baseSkipSetting = enforceSkipFlag(model, baseSkipSetting, project, changed, true);
final List<Profile> profiles = ProfileUtils.getProfiles(session, model);
if (profiles != null) {
for (final Profile profile : ProfileUtils.getProfiles(session, model)) {
enforceSkipFlag(profile, baseSkipSetting, project, changed, false);
}
}
if (baseSkipSetting == Boolean.FALSE && model.getProperties().containsKey("maven.deploy.skip")) {
model.getProperties().setProperty("maven.deploy.skip", "false");
}
}
return changed;
}
use of org.commonjava.maven.ext.core.state.DistributionEnforcingState in project pom-manipulation-ext by release-engineering.
the class DistributionEnforcingManipulatorTest method initTest.
private void initTest(final EnforcingMode mode, final boolean enabled) throws Exception {
setModeProperty(mode);
setMavenSession();
manipulator.init(session);
final DistributionEnforcingState state = session.getState(DistributionEnforcingState.class);
assertThat(state.isEnabled(), equalTo(enabled));
}
use of org.commonjava.maven.ext.core.state.DistributionEnforcingState in project pom-manipulation-ext by release-engineering.
the class DistributionEnforcingManipulator method init.
/**
* Sets the mode to on, off, detect (from install plugin), or none (disabled) based on user properties.
* @see DistributionEnforcingState
*/
@Override
public void init(final ManipulationSession session) throws ManipulationException {
this.session = session;
session.setState(new DistributionEnforcingState(session.getUserProperties()));
}
Aggregations