There is a previous answer to this but I don't think the accepted answer is correct
I have created a Maven plugin that programatically 'fiddles' with the <repositories>
and <distributionManagement>
configuration based upon some aspect of the version (so if the version has a branch name appended ie. 1.0.0-RC1). This allows for separate Nexus repositories to be used in feature branch builds without requiring POM modifications before merge back into int.
I cannot just change the groupId on branch builds because this is an OSGi project and groupId must ideally match the source package.
The problem is that there seems to be no part of the maven lifecycle that runs before dependency resolution. So the goal that would provide the correct <repository>
for resolution never gets configured, so Maven just complains that it can't resolve.
The linked answer suggests that 'clean' runs before resolution, but it doesn't seem to be true. If I configure my goal to have a default phase of 'clean' or 'validate', resolution still seems to happen first.
Can I make my plugin goal run before dependency resolution?
EDIT : It seems this cannot be done. I think this needs fixing in Maven. There ought to be place to run plugins that require 'project', before dependency resolution, without having to delve around in Plexus. This would permit the dynamic configuration of the repositories list used during subsequent resolution. Presumably this needs a Change somewhere in the EventDispatcher implementation (which I note is deprecated?).