使用 NPanday 和 Maven 发布插件进行版本控制
我正在开发一个 C# .NET Web 服务项目,该项目使用 Maven 和 NPanday。我们还想使用发布插件,但我发现了一个小版本控制问题。
当您进行构建时,NPanday 将(方便地)使用 POM 文件中的版本号更新 AssemblyInfo.cs
文件,但它不会将该更改提交给 SVN(我也不一定想要它)到)。
发布插件不知道 AssemblyInfo.cs
(我也不希望它知道)。但这意味着我的 AssemblyInfo.cs 和 POM 版本在发布操作期间不同步。
例如,假设我使用 mvn release:branch
从主干创建一个 2.0.x 分支。在分支之前,POM 和 AssemblyInfo.cs
可能都位于主干中的 2.0.0-SNAPSHOT,因此分支看起来符合我的预期。但在更新后的主干中,POM版本已更新(例如2.1.0-SNAPSHOT),但AssemblyInfo.cs仍为2.0.0-SNAPSHOT。
这不是一个大问题,因为主干上的下一个 mvncompile
将更新 AssemblyInfo.cs
并且有人会提交它。但 release:prepare
的情况更糟,因为从分支创建的标签在 POM 中具有正确的版本(例如 2.0.0),但 AssemblyInfo.cs
仍然显示 -快照。当release:perform运行时,NPanday将更新AssemblyInfo.cs
文件,但随后该标记会进行浮动修改。
有谁知道如何使用发布插件来纠正这个问题?我当然可以手动创建正确的分支/标签或编写自定义工具。或者我可以保留原样,说“AssemblyInfo.cs 文件不是最终版本源,POM 才是。”但我更喜欢两全其美。
I'm working on a C# .NET webservices project that uses Maven with NPanday. We also want to use the release plugin, but I've found a minor versioning issue.
NPanday will (conveniently) update the AssemblyInfo.cs
file with the version number from the POM file when you do a build, but it doesn't commit to that change to SVN (nor would I necessarily want it to).
The release plugin doesn't know about AssemblyInfo.cs
(nor would I expect it to). But this means that my AssemblyInfo.cs and POM versions get out of sync during release operations.
For example, say I do mvn release:branch
to create a 2.0.x branch from trunk. The POM and AssemblyInfo.cs
were probably both at 2.0.0-SNAPSHOT in the trunk prior to branching, so the branch looks as I would expect. But in the updated trunk, the POM version has been updated (e.g. 2.1.0-SNAPSHOT) but the AssemblyInfo.cs is still at 2.0.0-SNAPSHOT.
This isn't a huge problem because the next mvn compile
on the trunk will update the AssemblyInfo.cs
and someone will commit it. But it's worse with release:prepare
because the tag created from the branch has the correct version in the POM (e.g. 2.0.0), but the AssemblyInfo.cs
still says -SNAPSHOT. When release:perform is run, NPanday will update the AssemblyInfo.cs
file, but then there's a floating modification from that tag.
Does anyone know of a way to rectify this with the release plugin? I could certainly create correct branches/tags by hand or code up a custom tool. Or I could just leave it as is, saying that "The AssemblyInfo.cs file isn't the definitive version source, the POM is." But I'd prefer the best of both worlds.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会让 NPanday 为你生成 AssemblyInfo.cs - 然后你就可以避免检查其中包含版本的内容...
Visual Studio 在没有程序集信息的情况下也可以正常工作... 版本是 0.0.0.0,然后:-) - 我'我就是这样做的。
实际上 NPanday 正在“打破”maven 规则 - 构建永远不应该摆弄原始文件,而只是更新 /target 中的内容...
I'd let NPanday generate the AssemblyInfo.cs for you - then you avoid checking in things with versions in it...
Visual Studio will work fine without assembly infos... Version is 0.0.0.0, then :-) - I'm doing it that way.
Actually NPanday is "breaking" the maven rules - a build should never fiddle with the original files, but rather just update things in /target...