如何使用 Maven 从 SVN 标签创建分支?
假设我已在 $SVNROOT/project/tags/1.0
下标记了我们项目的发布版本。现在假设我需要从该标记创建一个分支,将其标记为 SNAPSHOT
,并更新 scm
配置。
我尝试使用 release:prepare
目标:
$ svn co $SVNROOT/project/tags/1.0 project-1.0
$ cd project-1.0
$ mvn release:branch -DbranchName=project-1.0.X -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false
但这失败了,并显示一条错误消息,警告我没有对 $SVNROOT/project/tags/1.0 项目的提交权限 - 1.0
路径(这是完全正确的——我们不允许提交到标签中)。
我在这里做错了什么,为什么 Maven 试图在标签中提交一些东西?
更新
只是为了澄清:我从我签出标签的目录中运行它。我收到的确切错误如下:
[INFO] Executing: /bin/sh -c cd xxx && svn --non-interactive commit --file /tmp/maven-scm-28755080.commit --targets /tmp/maven-scm-535803351230252749-targets
[INFO] Working directory: xxx
org.apache.maven.shared.release.scm.ReleaseScmCommandException: Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: Commit failed (details follow):
svn: 'pre-commit' hook failed with error output:
you do not have the rights to access this file: xxx/tags/xxx.
at org.apache.maven.shared.release.phase.ScmCommitPhase.checkin(ScmCommitPhase.java:133)
at org.apache.maven.shared.release.phase.ScmCommitPhase.execute(ScmCommitPhase.java:109)
at org.apache.maven.shared.release.DefaultReleaseManager.branch(DefaultReleaseManager.java:379)
at org.apache.maven.shared.release.DefaultReleaseManager.branch(DefaultReleaseManager.java:350)
at org.apache.maven.plugins.release.BranchReleaseMojo.execute(BranchReleaseMojo.java:133)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: Commit failed (details follow):
svn: 'pre-commit' hook failed with error output:
you do not have the rights to access this file: xxx/tags/xxx.
Suppose I have tagged the release version of our project under $SVNROOT/project/tags/1.0
. Suppose now that I need to create a branch from that tag, mark it as being a SNAPSHOT
, and update the scm
configuration.
I tried with the release:prepare
goal thus:
$ svn co $SVNROOT/project/tags/1.0 project-1.0
$ cd project-1.0
$ mvn release:branch -DbranchName=project-1.0.X -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false
But this fails, with an error message warning me that I don't have commit rights into the $SVNROOT/project/tags/1.0 project-1.0
path (which is perfectly true---we don't allow commits into tags).
What am I doing wrong here, and why was Maven trying to commit something in the tag?
Update
Just to clarify: I am running this from the directory into which I've checked out the tag. The exact error I'm getting is the following:
[INFO] Executing: /bin/sh -c cd xxx && svn --non-interactive commit --file /tmp/maven-scm-28755080.commit --targets /tmp/maven-scm-535803351230252749-targets
[INFO] Working directory: xxx
org.apache.maven.shared.release.scm.ReleaseScmCommandException: Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: Commit failed (details follow):
svn: 'pre-commit' hook failed with error output:
you do not have the rights to access this file: xxx/tags/xxx.
at org.apache.maven.shared.release.phase.ScmCommitPhase.checkin(ScmCommitPhase.java:133)
at org.apache.maven.shared.release.phase.ScmCommitPhase.execute(ScmCommitPhase.java:109)
at org.apache.maven.shared.release.DefaultReleaseManager.branch(DefaultReleaseManager.java:379)
at org.apache.maven.shared.release.DefaultReleaseManager.branch(DefaultReleaseManager.java:350)
at org.apache.maven.plugins.release.BranchReleaseMojo.execute(BranchReleaseMojo.java:133)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to commit files
Provider message:
The svn command failed.
Command output:
svn: Commit failed (details follow):
svn: 'pre-commit' hook failed with error output:
you do not have the rights to access this file: xxx/tags/xxx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您在哪里执行该命令
mvn release:branch< /代码>
?
正如在此线程中提到的:
另请参阅此帖子:
Where did you execute that command
mvn release:branch
?As mentioned in this thread:
See also this thread:
-DautoVersionSubmodules=true
运行时,Maven 将提示要在分支中使用的版本。我提供了 1.5.0-azuresupport-SNAPSHOT。由于 autoVersionSubmodules 设置为 true,Maven Release 将自动为所有子模块使用此版本,因此也会将所有内部项目依赖项更新为该版本。
-DsuppressCommitBeforeBranch=true
默认情况下, Maven Releases 创建对当前工作副本的中间提交。我不确定原因,但我认为这是因为某些 VCS 不支持修改后的工作副本的分支/标记。此参数确保不会对工作副本进行任何中间提交。
-DremoteTagging=false
使用 SVN,默认情况下会远程创建标签。如果要省略中间提交,则必须将其设置为 false。
-DupdateBranchVersions=true
-DupdateWorkingCopyVersions=false
分支时,您可以为当前工作副本或新分支或两者定义新版本。按照此处的设置,工作副本将被保留,插件将要求分支的新版本。
这里解释了所有 -D 参数
http://startbigthinksmall.wordpress。 com/2011/11/29/create-branches-with-maven-release-plugin-svn/
-DautoVersionSubmodules=true
When ran, Maven will prompt for the version to be used in the branch. I provided 1.5.0-azuresupport-SNAPSHOT. Since autoVersionSubmodules is set to true, Maven Release will automatically use this versions for all submodules and hence also update all inner-project dependencies to that version.
-DsuppressCommitBeforeBranch=true
By default, Maven Releases creates intermediate commits to the current working copy. I’m not sure of the reason, but I think it was because some VCS do not support branching/tagging of modified working copies. This parameter makes sure, no intermediate commits are made to the working copy.
-DremoteTagging=false
With SVN, by default, tags are created remotely. If you want to ommit intermediate commits, this must be set to false.
-DupdateBranchVersions=true
-DupdateWorkingCopyVersions=false
When branching, you can either define new versions for the current working copy, or the new branch, or both. As set here, the working copy will be left alone, and the plugin will ask for a new version for the branch.
here you have all the -D arguments explained
http://startbigthinksmall.wordpress.com/2011/11/29/create-branches-with-maven-release-plugin-svn/
您正在运行的命令看起来不错,并严格遵循 创建分支:
但是,它似乎是一个失败并抱怨的“预提交”钩子。所以我想知道:
The commands you're running looks OK and strictly follow the example given in Create a Branch:
However, it seems that it's a 'pre-commit' hook that is failing and complaining. So I wonder:
实际问题是
release:branch
目标提交到标签,这是一个 不合理的错误。没有解决方法。您的预提交挂钩可能会失败,因为它的设计(可能是正确的)是为了防止在标记目录内提交。The actual problem is that the
release:branch
goal commits to tags, which is an unconscionable bug. There is no workaround. Your pre-commit hook is likely failing because it is designed--probably correctly--to prevent commits inside a tag directory.