安装时如何配置 Maven 以提交到 Mercurial 存储库:install

发布于 2024-08-15 18:38:17 字数 479 浏览 6 评论 0 原文

MavenSCM 插件似乎没有提供“提交”目标。 scm:checkin 执行提交和推送。我需要避免推动。

我只是对在 install:install 期间执行 hg commit 感兴趣。我没有使用 release 插件,也不需要它。我只是在多模块环境中本地工作,并希望确保我的源存储库与每个模块本地安装的 Maven 快照保持一致。换句话说,每次安装模块的新快照时,我都希望将相关代码提交给 hg 以使每个快照直接与 hg 修订版(或快照之间发生多次提交时的修订范围)相关联。

Maven's SCM plug-in doesn't appear to provide a "commit" goal. scm:checkin performs a commit AND push. I need to avoid the push.

I'm simply interested in doing an hg commit during install:install. I'm not using the release plugin and don't need it yet. I'm simply working locally in a multi-module environment and want to ensure that my source repository aligns with my Maven locally-installed snapshots for each module. In other words, every time I install a new snapshot of a module, I want the related code committed to hg to make every snapshot directly correlate to an hg revision (or range of revisions when multiple commits occur between snapshots).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

活雷疯 2024-08-22 18:38:17

以下代码将 scm:checkin 绑定到 install 阶段。只要存储库是 file:// 方案(至少对于 Mercurial,根据 代码),scm:checkin 期间不执行 >push

  1. 定义以下步骤中使用的属性:

    <前><代码><属性>;
    maven install:安装自动签入。
    file:///path/to/local/repository
    hg;

    可以是您选择的任何内容。完全修复并不理想,因为提交应该包含有关所做更改的有意义的消息。但是,我确实相信自动提交中应该包含一条标准消息来标识它。只需在每次安装之前修改第 1 步中的 属性即可。

  2. 这只是基于 Maven 项目的标准 scm 节点。由于这仅涉及本地存储库,因此 URL 都是相同的。

    <预><代码>;
    <连接>scm:${repository.type}:${repository.local}
    scm:${repository.type}:${repository.local}
    scm:${repository.type}:${repository.local}

  3. 这是在执行提交的安装阶段运行的插件。它只会根据步骤 2 中的定义执行正确的 scm 签入。

    <预置><代码><构建>
    <插件>
    <插件>
    org.apache.maven.plugins
    maven-scm-plugin;
    <版本>1.2
    <处决>
    <执行>
    <阶段>安装
    <目标>
    <目标>签入





一个问题是我收到以下信息。

已弃用:绑定聚合器 mojos
POM 中的生命周期阶段是
被认为是危险的。该功能有
已被弃用。请调整您的
相应的 POM 文件。

我正在研究如何解决它,但就目前而言,它有效,我会继续下去。

The following will bind scm:checkin to the install phase. As long as the repository is a file:// scheme (at least for Mercurial, according to the code), a push is not performed during scm:checkin.

  1. Define properties used in the following steps:

    <properties>
      <message>maven install:install auto-checkin.</message>
      <repository.local>file:///path/to/local/repository</repository.local>
      <repository.type>hg</repository.type>
    </properties>
    

    The <message> can be anything you choose. It isn't ideal to be completely fixed as commits should include meaningful messages as to what changes were made. But, I do believe there should be a standard message included in auto-commits to identify it as such. Just modify the <message> property from step 1. before each install.

  2. This is just a standard scm node for a Maven-based project. Since this is concerned only with a local repository, the URLs are all the same.

    <scm>
      <connection>scm:${repository.type}:${repository.local}</connection>
      <developerConnection>scm:${repository.type}:${repository.local}</developerConnection>
      <url>scm:${repository.type}:${repository.local}</url>
    </scm>
    
  3. This is plug-in that runs during the install phase that performs the commit. It'll simply execute the proper scm checkin based on the definition in step 2.

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-scm-plugin</artifactId>
          <version>1.2</version>
          <executions>
            <execution>
              <phase>install</phase>
              <goals>
                <goal>checkin</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
    

One problem is that I receive the following.

DEPRECATED: Binding aggregator mojos
to lifecycle phases in the POM is
considered dangerous. This feature has
been deprecated. Please adjust your
POM files accordingly.

I'm looking into how to resolve it but, for now, it works and I'm going with it.

波浪屿的海角声 2024-08-22 18:38:17

checkin 上的 connectionUrl 设置为本地机器上的一次性存储库怎么样?因此,您的签出将来自“中央”存储库,但您的“签入”只会转到工作存储库(您想要的提交),并且(显然)不可避免的推送将转到 file:///tmp/whocares。

或者,scm 插件中可能有一行代码可以注释掉,以避免这种推送。

What about setting the connectionUrl on the checkin to a throw-away repository on the local box? So your checkout would come from the "central" repo, but your 'checkin' would go only to the working repository (the commit that you want) and the (apparently) unavoidable push would go to file:///tmp/whocares.

Alternately there's probably a single line of code in the scm plugin to comment out to avoid that push.

醉酒的小男人 2024-08-22 18:38:17

Maven 的 scm 插件似乎没有提供“提交”目标。 scm:checkin 执行提交和推送。我需要避免推动。

那么 scm 插件可能不是您正在寻找的:)

我只是对在 install:install 期间进行 hg 提交感兴趣。我没有使用 release 插件,也不需要它。

老实说,这是一个相当奇怪的用法。虽然我理解您所描述的内容,但对我来说,将快照与修订号“同步”并没有真正的意义。即使您不在两个 SNAPSHOT 构建之间提交代码,我也不明白这怎么会成为问题。换句话说,我看不出强制提交有什么附加价值。在我看来,使用发布插件并不能解决任何问题。

总而言之,我认为 scm 插件不会让您实现您的目标(至少在没有黑客攻击的情况下)。我不知道 Ant 中是否有 Mercurial 支持,但如果有,也许你应该朝这个方向看(并使用 antrun 插件)。

Maven's scm plugin doesn't appear to provide a "commit" goal. scm:checkin performs a commit AND push. I need to avoid the push.

Then the scm plugin is maybe not what you're looking for :)

I'm simply interested in doing an hg commit during install:install. I'm not using the release plugin and don't need it yet.

To be honest, this is a pretty odd usage. While I understand what you described, it doesn't really make sense to me to "sync" a SNAPSHOT with a revision number. Even if you don't commit code between two SNAPSHOT builds, I don't understand how this can this be a problem. In other words, I don't see what is the added value of forcing the commit. And using the release plugin won't solve anything in my opinion.

To summarize, I don't think that the scm plugin will allow you to achieve your goal (at least not without hacking). I don't know if there is mercurial support in Ant but, if there is, maybe you should look in this direction instead (and use the antrun plugin).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文