mavenmaven-scm

Commit multiple files with maven scm plugin


I want to git commit two files in different folders with maven scm plugin (v1.9.4). Eg: abc/p.json and xyz\p.json. I dont want to commit any other files such as other/p.json

According to the documentation for the chekin goal, a comma separated list such as abc/p.json,xyz/p.json should work. But it ends up commiting all the files.

I am using the scm:checkin goal with the maven release plugin's <preparationGoals> configuration.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>${maven.release.plugin.version}</version>
    <configuration>
        <preparationGoals>
            clean verify
            scm:checkin -DpushChanges=false -Dmessage="[maven-release-plugin] Update version text"
            -Dincludes="abc/p.json,xyz/p.json"
    </configuration>
</plugin>

How do I commit just the abc/p.json and xyz/p.json files?


Solution

  • I was able to get a list of files checked in by creating a profile, similar to:

    <profile>
      <id>commit-changed-files</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-scm-plugin</artifactId>
              <configuration>
                <includes>file1,file2,file3,file4</includes>
                <message>[maven-release-plugin] commit changed files</message>
                <pushChanges>false</pushChanges><!-- because I use git -->
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    

    And then, in the release plugin configuration:

            <preparationGoals>-Pcommit-changed-files clean scm:add scm:checkin</preparationGoals>
            <completionGoals>-Pcommit-changed-files clean scm:add scm:checkin</completionGoals>
    

    Reference: formatter-m2e-configurator's pom.xml