在 Eclipse 中使用 maven-release-plugin
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12245938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using maven-release-plugin in Eclipse
提问by mikera
I recently tried to use maven-release-plugin
since it is apparently the recommended way of building and packages releases in the Maven universe.
我最近尝试使用maven-release-plugin
它,因为它显然是在 Maven 世界中构建和打包发布的推荐方式。
However I wanted to use this within Eclipse, as the rest of my development workflow is Eclipse based. I normally run Maven commands via the m2eclipse plugin provided as part of Eclipse Juno (4.2)
但是我想在 Eclipse 中使用它,因为我的其余开发工作流程是基于 Eclipse 的。我通常通过作为 Eclipse Juno (4.2) 一部分提供的 m2eclipse 插件运行 Maven 命令
I noticed a few oddities when I tried to run "release:prepare" within Eclipse:
当我尝试在 Eclipse 中运行“release:prepare”时,我注意到了一些奇怪的地方:
- Some extra files were created in the root project directory - "pom.xml.releaseBackup" and "release.properties". Do they really belong there? Have I got the release directories set up correctly? I wouldn't really consider these temporary artifacts as part of my source code tree......
- The
pom.xml
gets manually overwritten with the updated release number. Eclipse warns you and is happy to reload the updated version - but is this generally safe? - The prepare ultimately fails giving the error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project clisk: Failed to invoke Maven build. Error configuring command-line. Reason: Maven executable not found at: C:\Users\Mike\git\clisk\EMBEDDED\bin\mvn.bat -> [Help 1]
- presumably because I am using the built-in Maven excetable provided by m2eclipse rather than the command line. I guess I could install command line maven as well.... but is that sensible or will it just cause more problems?
- 在根项目目录中创建了一些额外的文件 - “pom.xml.releaseBackup”和“release.properties”。他们真的属于那里吗?我是否正确设置了发布目录?我不会真正将这些临时工件视为我的源代码树的一部分......
- 在
pom.xml
被手动更新的版本号覆盖。Eclipse 会警告您并且很乐意重新加载更新的版本 - 但这通常安全吗? - 准备最终失败并给出错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project clisk: Failed to invoke Maven build. Error configuring command-line. Reason: Maven executable not found at: C:\Users\Mike\git\clisk\EMBEDDED\bin\mvn.bat -> [Help 1]
- 大概是因为我使用的是 m2eclipse 提供的内置 Maven excetable 而不是命令行。我想我也可以安装命令行 maven ......但这是明智的还是会引起更多问题?
Given these kind of issues, Is there a way to get maven-release-plugin to work smoothly within Eclipse, or should I just give up and continue to do releases manually?
鉴于这些问题,有没有办法让 maven-release-plugin 在 Eclipse 中顺利工作,还是应该放弃并继续手动发布?
采纳答案by kamuflage661
I have been using release plugin, but only from command line.
我一直在使用发布插件,但只能从命令行使用。
Re. 1. The backup files that release plugin creates are needed if something goes wrong in time of preparing the release. You can always rollback the prepared release using release:rollback command. When you do release:perform they will be deleted.
关于。1.如果在准备发布时出现问题,则需要发布插件创建的备份文件。您始终可以使用 release:rollback 命令回滚准备好的版本。当您执行 release:perform 时,它们将被删除。
Re. 2. The plugin changes the version number from snapshot version for example: 0.0.1-SNAPSHOT: to release version: 0.0.1. Then after release:perform release version is moved to the maven repository and release plugin changes version again to 0.0.2-SNAPSHOT. Now you can use you full released (tested) version in your testing or production enviornment and snapshot version for developping purposes.
关于。2.插件将版本号从快照版本例如:0.0.1-SNAPSHOT:更改为发布版本:0.0.1。然后在 release:perform 发布版本移动到 maven 存储库后,发布插件再次将版本更改为 0.0.2-SNAPSHOT。现在,您可以在测试或生产环境中使用完整发布(已测试)版本和用于开发目的的快照版本。
Re. 3. I don't know what is causing the problem, but I don't see the problem by using release plugin from command line.
关于。3. 我不知道是什么导致了问题,但是通过命令行使用 release 插件我没有看到问题。
回答by aglavina
Also mvn 3.3.3 installs a mvn.cmd file, instead of a mvn.bat file in Windows.
此外,mvn 3.3.3 安装了一个 mvn.cmd 文件,而不是 Windows 中的 mvn.bat 文件。
You should copy mvn.cmd to mvn.bat
您应该将 mvn.cmd 复制到 mvn.bat
回答by Aravind R
Well i know this link is OLD , but to help some on who reffers this link for the issue 3.
好吧,我知道这个链接是旧的,但是为了帮助那些为问题 3 提供这个链接的人。
Install maven separately on to local Box and give the path of the installation under Windows->Preferences--> maven--> Installation. Also you have to define the same in the run configuration within the Eclipse.
单独安装maven到本地Box,在Windows->Preferences-->maven-->Installation下给出安装路径。您还必须在 Eclipse 中的运行配置中定义相同的内容。
Attached is a link that explains the same.
附件是解释相同内容的链接。
http://maven.40175.n5.nabble.com/Build-Failure-prepare-release-td510949.html
http://maven.40175.n5.nabble.com/Build-Failure-prepare-release-td510949.html
回答by Nicola Musatti
You might be able to overcome the error you mention by installing command line Maven and configure Eclipse to use that rather than the embedded one by choosing Window -> Preferences -> Maven -> Installations, but I agree with the advice of making your releases outside Eclipse.
您可以通过安装命令行 Maven 来克服您提到的错误,并通过选择 Window -> Preferences -> Maven -> Installations 将 Eclipse 配置为使用该错误而不是嵌入的错误,但我同意在外部发布版本的建议蚀。