使用Maven SCM插件提交多个文件

3

我希望使用Maven SCM插件(v1.9.4)提交不同文件夹中的两个文件,例如:abc/p.jsonxyz\p.json。 我不想提交任何其他文件,如other/p.json.

根据chekin目标的文档,逗号分隔的列表,如abc/p.json,xyz/p.json应该可以工作。 但实际上它提交了所有文件。

我正在使用Maven Release插件的<preparationGoals>配置来运行scm:checkin目标。

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

我该如何提交仅限于 "abc/p.json" 和 "xyz/p.json" 文件的更改?

此功能请求投票。 - Vivek
1个回答

2

我能够通过创建一个类似以下的配置文件来获取已检入文件列表:

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

然后,在发布插件配置中:

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

参考资料: formatter-m2e-configurator的pom.xml文件


谢谢!有没有办法对准备目标进行排序?我想提交的文件在“验证”生命周期中更新。但是使用此配置,“scm:checkin”在“verify”运行之前运行 :( - Aruna Herath
我的配置:<preparationGoals>清理 验证 SCM:添加 SCM:检入 -P提交-版本更新的文件</preparationGoals> - Aruna Herath
在“验证”阶段修改文件似乎对我来说是不正确的,我会在那里查找并解决问题。所有被修改的内容都应该在“打包”阶段之前完成。话虽如此...您可能可以将执行本身放在配置文件中,并选择要运行它的阶段,而不是从命令行触发目标在<preparationGoals />中。但是,在“验证”之后没有太多的阶段,并且绑定到“验证”本身可能无法保证它将在绑定到“验证”的其他插件之后运行。 - Christopher
啊,抱歉我错了。实际上是在“验证”阶段更新版本文本,而不是“验证”。但是scm:checkin目标甚至在此之前运行。如果执行绑定到配置文件,则我将使用post-validate阶段。那么,配置文件仍应在“preparationGoals”和“completionGoals”中激活,对吗?非常感谢您的帮助 :) - Aruna Herath
构建生命周期中没有“post-validate”阶段(https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html)。但是,绑定到“initialize”应该可以工作...只需确保将“scm:add”和“scm:checkin”都绑定到该阶段,并且您需要让“scm:add”先执行(如果您真的想确保,可以将“scm:checkin”绑定到“generate-sources”)。何时激活它取决于更改发生的时间。在我的情况下,插件在“release:prepare”和“release:perform”的“clean”阶段更改了文件,因此我做了两者。您的情况可能不同。 - Christopher

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接