Is this code
project.getPluginRepositories().add(myCustomRepository);
executed inside afterProjectsRead method of a maven extension (class extending AbstractMavenLifecycleParticipant) supposed to work? It executes fine (no errors nor warnings) but the repo does not seem to be taken into account by Maven and build fails with "Plugin .... or one of its dependencies could not be resolved"!
If this is not possible this way, are there any other ways to dynamically add a repo from maven extension?
It seams this code
works. Here is an example from
ExecutionListenerrather thanMavenLifecycleParticipantbut I guess it should work inafterProjectsReadtoo.WARNING: This is probably not what Maven expects you to do and may break some plugins. For example
maven-shade-pluginworks mostly OK but breaks (and fails the build) while trying to generate reduced POM when repositories are added this way.