Maven 的 SCM 插件似乎没有提供“提交”目标。 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).
发布评论
评论(3)
以下代码将
scm:checkin
绑定到install
阶段。只要存储库是file://
方案(至少对于 Mercurial,根据 代码),scm:checkin 期间不执行 >push。定义以下步骤中使用的属性:
<前><代码><属性>;
maven install:安装自动签入。
file:///path/to/local/repository
hg ;
可以是您选择的任何内容。完全修复并不理想,因为提交应该包含有关所做更改的有意义的消息。但是,我确实相信自动提交中应该包含一条标准消息来标识它。只需在每次安装之前修改第 1 步中的
属性即可。这只是基于 Maven 项目的标准 scm 节点。由于这仅涉及本地存储库,因此 URL 都是相同的。
<预><代码>;
scm:${repository.type}:${repository.local}
scm:${repository.type}:${repository.local}
<连接>scm:${repository.type}:${repository.local}
这是在执行提交的
安装
阶段运行的插件。它只会根据步骤 2 中的定义执行正确的 scm 签入。<预置><代码><构建>
org.apache.maven.plugins
maven-scm-plugin ;
<插件>
<插件>
<版本>1.2
<处决>
<执行>
<阶段>安装
<目标>
<目标>签入
一个问题是我收到以下信息。
我正在研究如何解决它,但就目前而言,它有效,我会继续下去。
The following will bind
scm:checkin
to theinstall
phase. As long as the repository is afile://
scheme (at least for Mercurial, according to the code), a push is not performed duringscm:checkin
.Define properties used in the following steps:
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.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.
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.One problem is that I receive the following.
I'm looking into how to resolve it but, for now, it works and I'm going with it.
将
checkin
上的connectionUrl
设置为本地机器上的一次性存储库怎么样?因此,您的签出将来自“中央”存储库,但您的“签入”只会转到工作存储库(您想要的提交),并且(显然)不可避免的推送将转到 file:///tmp/whocares。或者,scm 插件中可能有一行代码可以注释掉,以避免这种推送。
What about setting the
connectionUrl
on thecheckin
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.
那么 scm 插件可能不是您正在寻找的:)
老实说,这是一个相当奇怪的用法。虽然我理解您所描述的内容,但对我来说,将快照与修订号“同步”并没有真正的意义。即使您不在两个 SNAPSHOT 构建之间提交代码,我也不明白这怎么会成为问题。换句话说,我看不出强制提交有什么附加价值。在我看来,使用发布插件并不能解决任何问题。
总而言之,我认为 scm 插件不会让您实现您的目标(至少在没有黑客攻击的情况下)。我不知道 Ant 中是否有 Mercurial 支持,但如果有,也许你应该朝这个方向看(并使用 antrun 插件)。
Then the scm plugin is maybe not what you're looking for :)
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).