Repository: git-commit-id/git-commit-id-maven-plugin

Issue #315: maven.gitcommitid.skip does not override configuration in POM
Created: 2017-08-30T18:16:04Z
Executing Maven with the property -Dmaven.gitcommitid.skip=true does not skip the plugin execution when the configuration in the POM includes a <skip>false</skip>.  Thus, the command line option does not override the setting in the POM.
Usually, all properties set via command line override the settings in the POM (this is even the purpose of the properties), e.g. skipping the tests or skipping linting. In my opinion, the behaviour of the git-commit-plugin should be changed to follow the general Maven approach and let command line property override the setting in the POM.
For now, an easy workaround exists, simply remove <skip>false</skip> from the POM.

Duplicate issue #470: support mojo properties
Created: 2020-02-17T11:40:58Z
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.

Closing comment (2020-02-17T13:16:04Z): 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: 
  
    
      git-commit-id-maven-plugin/maven/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
    
    
        Lines 228 to 236
      in
      61af1b5
    
  
  
    

        
          
             @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: 
  
    
      git-commit-id-maven-plugin/maven/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
    
    
        Lines 248 to 260
      in
      61af1b5
    
  
  
    

        
          
             @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>