use of org.commonjava.maven.ext.core.state.RepositoryInjectionState in project pom-manipulation-ext by release-engineering.
the class RepositoryInjectionManipulator method applyChanges.
/**
* Apply the repository injection changes to the the top level pom.
*/
@Override
public Set<Project> applyChanges(final List<Project> projects) throws ManipulationException {
final RepositoryInjectionState state = session.getState(RepositoryInjectionState.class);
if (!session.isEnabled() || !state.isEnabled()) {
logger.debug(getClass().getSimpleName() + ": Nothing to do!");
return Collections.emptySet();
}
final Set<Project> changed = new HashSet<>();
final Model remoteModel = modelBuilder.resolveRawModel(state.getRemoteRepositoryInjectionMgmt());
final List<Repository> remoteRepositories = remoteModel.getRepositories();
final List<Repository> remotePluginRepositories = remoteModel.getPluginRepositories();
for (final Project project : projects) {
final String ga = ga(project);
logger.info("Applying changes to: " + ga);
final Model model = project.getModel();
if (checkProject(state, project)) {
// inject repositories
final List<Repository> repositories = model.getRepositories();
if (!remoteRepositories.isEmpty()) {
final Iterator<Repository> i1 = remoteRepositories.iterator();
while (i1.hasNext()) {
addRepository(repositories, i1.next());
}
changed.add(project);
}
// inject plugin repositories
final List<Repository> pluginRepositories = model.getPluginRepositories();
if (!remotePluginRepositories.isEmpty()) {
final Iterator<Repository> i2 = remotePluginRepositories.iterator();
while (i2.hasNext()) {
addRepository(pluginRepositories, i2.next());
}
changed.add(project);
}
}
}
return changed;
}
use of org.commonjava.maven.ext.core.state.RepositoryInjectionState in project pom-manipulation-ext by release-engineering.
the class RepositoryInjectionManipulator method init.
/**
* Initialize the {@link RepositoryInjectionState} 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 RepositoryInjectionState(session.getUserProperties()));
}
Aggregations