use of org.commonjava.maven.ext.io.resolver.ExtensionInfrastructure in project pom-manipulation-ext by release-engineering.
the class ManipulationManager method init.
/**
* Initialize {@link ManipulationSession} using the given {@link MavenSession} instance, along with any state managed by the individual
* {@link Manipulator} components.
*
* @param session the container session for manipulation.
* @throws ManipulationException if an error occurs.
*/
public void init(final ManipulationSession session) throws ManipulationException {
logger.debug("Initialising ManipulationManager with user properties {}", session.getUserProperties());
for (final ExtensionInfrastructure infra : infrastructure.values()) {
infra.init(session.getTargetDir(), session.getRemoteRepositories(), session.getLocalRepository(), session.getSettings(), session.getActiveProfiles());
}
orderedManipulators = new ArrayList<>(manipulators.values());
// The RESTState depends upon the VersionState being initialised. Therefore initialise in reverse order
// and do a final sort to run in the correct order. See the Manipulator interface for detailed discussion
// on ordered.
Collections.sort(orderedManipulators, Collections.reverseOrder(new ManipulatorPriorityComparator()));
for (final Manipulator manipulator : orderedManipulators) {
logger.debug("Initialising manipulator " + manipulator.getClass().getSimpleName());
manipulator.init(session);
}
Collections.sort(orderedManipulators, new ManipulatorPriorityComparator());
// Now init the common state
session.setState(new CommonState(session.getUserProperties()));
}
use of org.commonjava.maven.ext.io.resolver.ExtensionInfrastructure in project pom-manipulation-ext by release-engineering.
the class ManipulationManager method scanAndApply.
/**
* Encapsulates {@link #applyManipulations(List)}
*
* @param session the container session for manipulation.
* @throws ManipulationException if an error occurs.
*/
public void scanAndApply(final ManipulationSession session) throws ManipulationException {
final List<Project> projects = pomIO.parseProject(session.getPom());
session.setProjects(projects);
for (final Project project : projects) {
logger.debug("Got " + project + " (POM: " + project.getPom() + ")");
}
Set<Project> changed = applyManipulations(projects);
// Create a marker file if we made some changes to prevent duplicate runs.
if (!changed.isEmpty()) {
logger.info("Maven-Manipulation-Extension: Rewrite changed: " + projects);
GAV gav = pomIO.rewritePOMs(changed);
try {
final VersioningState state = session.getState(VersioningState.class);
state.setExecutionRootModified(gav);
new File(session.getTargetDir().getParentFile(), ManipulationManager.MARKER_PATH).mkdirs();
new File(session.getTargetDir().getParentFile(), ManipulationManager.MARKER_FILE).createNewFile();
try (FileWriter writer = new FileWriter(new File(session.getTargetDir().getParentFile(), RESULT_FILE))) {
writer.write(collectResults(session));
}
} catch (IOException e) {
logger.error("Unable to create marker or result file", e);
throw new ManipulationException("Marker/result file creation failed", e);
}
}
// Ensure shutdown of GalleyInfrastructure Executor Service
for (ExtensionInfrastructure e : infrastructure.values()) {
e.finish();
}
logger.info("Maven-Manipulation-Extension: Finished.");
}
Aggregations