aleksandr-m / gitflow-maven-plugin

The Git-Flow Maven Plugin supports various Git workflows, including GitFlow and GitHub Flow. This plugin runs Git and Maven commands from the command line.
https://aleksandr-m.github.io/gitflow-maven-plugin/
Apache License 2.0
490 stars 182 forks source link

Need ability to override GitFlowConfig and CommitMessages via CLI #284

Closed kutsal closed 2 years ago

kutsal commented 3 years ago

Have a particular use-case where (because our CI pipeline is using this plugin indiscriminately across all our Java projects) we need the ability to override the plugin configuration defaults via maven command-line even when the project being built does not reference this plugin. Right now gitFlowConfig cannot be specified via command-line. #263 attempts this, but since it's doing it in constructor, pom files override the configuration, which isn't how it should work with Maven -- command-line overrides pom, not the other way around.

aleksandr-m commented 3 years ago

@kutsal

pom files override the configuration, which isn't how it should work with Maven

But it is.

I see what benefit it brings, but I'm not sure that going against Maven way is the best course of action.

kutsal commented 3 years ago

@aleksandr-m

see edit history of this comment if you like, but

I guess it becomes against convention if a <configuration>...</configuration> block is provided in the pom. I'd argue that isn't the case in our use-case, but I see your point.

How do you feel about something like this instead:

public void set(String gitFlowConfig) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
    Map<String, String> values = Splitter.on(",").withKeyValueSeparator("=").split(gitFlowConfig);
    for(Entry<String, String> e : values.entrySet()) {
        new PropertyDescriptor(e.getKey(), this.getClass()).getWriteMethod().invoke(this, e.getValue());
    }
}

that allows me to pass -DgitFlowConfig=productionBranch=FOO,origin=BAR via command-line.

This has the advantage of doing it The Maven Way -- via the set(..) method. If pom has a configuration block for the plugin, that takes precedence as expected.