Skip to content

support mojo properties #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
davidkarlsen opened this issue Feb 17, 2020 · 1 comment
Closed

support mojo properties #470

davidkarlsen opened this issue Feb 17, 2020 · 1 comment

Comments

@davidkarlsen
Copy link

Describe your idea

Use https://maven.apache.org/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Parameter.html#property-- so that one can more easily override parameters in child-pom's / on command line.

Expected Behavior

Today you can only configure plugin explicitly in an xml section, making it harder to parameterize behaviour.

Additional context

See other maven plugins for inspiration, for instance surefire.

@TheSnoozer
Copy link
Collaborator

TheSnoozer commented Feb 17, 2020

Hello,
thank you for this suggestion.
However i think this is something I would not explore further in this project.

Essentially this plugin has two major switches that work from command-line right now:

  • maven.gitcommitid.nativegit:
    @Parameter(property = "maven.gitcommitid.nativegit", defaultValue = "false")
    boolean useNativeGitViaCommandLine;
    /**
    * Set this to {@code 'true'} to skip plugin execution.
    * @since 2.1.8
    */
    @Parameter(defaultValue = "false")
    boolean skip;
  • maven.gitcommitid.skip:
    @Parameter(property = "maven.gitcommitid.skip", defaultValue = "false")
    private boolean skipViaCommandLine;
    /**
    * <p>Set this to {@code 'true'} to only run once in a multi-module build. This probably won't "do the right thing"
    * if your project has more than one git repository. If you use this with {@code 'generateGitPropertiesFile'},
    * it will only generate (or update) the file in the directory where you started your build.</p>
    *
    * <p>The git.* maven properties are available in all modules.</p>
    * @since 2.1.12
    */
    @Parameter(defaultValue = "false")
    boolean runOnlyOnce;

The ugly part of using properties is that the configuration within the XML always overwrites whatever is provided via command-line. IMHO maven should work in a way where the command-line argument should overwrite whatever is configured in the XML. So just adding 'property' is counter intuitive.
The "solution" to get this working as 'expected' from the plugin side is two essentially introduce two variables, one for the configuration for the XML and one for the command-line.

This is related to #315 and https://issues.apache.org/jira/browse/MNG-6278. Basically the maven maintainers consider this expected behaviour and if you want any other configuration exposed as configuration you should be able to follow the 'standard' way by specifying properties and using them inside the config:

<properties>
  <maven.gitcommitid.someprefix>blah-blub</maven.gitcommitid.someprefix>
</properties>
...
<plugin>
						<groupId>pl.project13.maven</groupId>
						<artifactId>git-commit-id-plugin</artifactId>
						<version>${git-commit-id-version}</version>
						<executions>
							<execution>
								<id>get-the-git-infos</id>
								<goals>
									<goal>revision</goal>
								</goals>
								<phase>initialize</phase>
							</execution>
						</executions>
						<configuration>
							<prefix>${maven.gitcommitid.someprefix}</prefix>
                                               </configuration>
</plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants