maven-release-plugin:2.5:prepare 失败并显示“写入 POM 时出错:(访问被拒绝)”
Posted
技术标签:
【中文标题】maven-release-plugin:2.5:prepare 失败并显示“写入 POM 时出错:(访问被拒绝)”【英文标题】:maven-release-plugin:2.5:prepare fails with "Error writing POM: (Access is denied)" 【发布时间】:2014-05-22 14:08:11 【问题描述】:我尝试运行 mvn release:prepare(当然,在 release:clean 之后),我得到一个错误:
未能执行目标 org.apache.maven.plugins:maven-release-plugin:2.5:prepare (default-cli) ...: Error writing POM: D:\\pom.xml (Access is拒绝)
原因:java.io.FileNotFoundException: D:...\pom.xml(访问被拒绝)
问题:文件在指定位置,但被写保护(因为它在 SCM 下)。必须签入所有 pom,否则我会在早期阶段(检查 poms 阶段)收到错误。所以 pom 必须签入,即写保护,因此我得到“拒绝访问”异常,这没有任何意义!
在下载 maven 源 scm-plugin 和 release-plugin) 后,我试图找到一些东西,但不幸的是找不到这个异常的原因。也许我遗漏了一些东西,所以我把它贴在这里,也许有人可以解释一下。
我在代码中的几个点中添加了日志(在 DefaultReleaseManager 中,所以我可以看到阶段),重新构建,我看到它在名为“rewrite-poms-for-release',这是 maven 尝试将我的 poms 更改为 release 并再次签入的阶段。但问题是这些 pom 受源代码控制,因此它们是只读的。因此插件无法写入这些 pom,因此它返回错误“访问被拒绝”。
尝试查看相关类class RewritePomsForReleasePhase extends AbstractRewritePomsPhase
中是否有东西,但什么也没找到。尝试使用 -X 运行它,所以我得到了相关的异常(见下文)。
我使用 maven-release-plugin:2.5, maven-scm-plugin:1.9,提供者是 TFS(但我看不出它与我的错误有什么关系,因为它不会在“提供者”中失败或在 scm 插件中。)
更新:
刚刚尝试使用 maven-release-plugin:2.1 进行复制,我知道它肯定有效(使用 maven-scm:1.4)。我犯了同样的错误。所以我猜我的配置中的某些内容不正确......也许这里有专家可以提供帮助?也许它与maven-scm-plugin有关?
[INFO] Command line - cmd.exe /X /C "tf status -workspace:ohad -recursive -format:detailed $/NNG/PLS/dev/PLS/PLR"
[DEBUG] line -There are no pending changes.
[INFO] err -
[DEBUG] Iterating
[INFO] *** DefaultReleaseManager(): phase name= check-dependency-snapshots
[INFO] Checking dependencies and plugins for snapshots ...
[INFO] *** DefaultReleaseManager(): phase name= create-backup-poms
[INFO] *** DefaultReleaseManager(): phase name= map-release-versions
What is the release version for "referencedata"? (com.ccih:referencedata) ***: : 6.6.0-RELEASE
What is the release version for "referencedata.resolvertool"? ***: : 6.6.0-RELEASE
[INFO] *** DefaultReleaseManager(): phase name= input-variables
[INFO] scmUrl - https://***:$/***
[INFO] Scheme - https
What is SCM release tag or label for "referencedata"? ***: :
[INFO] *** DefaultReleaseManager(): phase name= map-development-versions
What is the new development version for "referencedata"? ***: :
What is the new development version for "referencedata.resolvertool"? ***: :
[INFO] *** DefaultReleaseManager(): phase name= rewrite-poms-for-release
[INFO] Transforming 'referencedata'...
[INFO] scmUrl - https://***:$/***R
[DEBUG] Using mirror nng (http://192.168.244.13:8081/artifactory/nng) for plt-release (http://192.168.244.13:8081/artifactory/plt-release-local).
[DEBUG] Using mirror nng (http://192.168.244.13:8081/artifactory/nng) for plt-snapshot (http://192.168.244.13:8081/artifactory/plt-snapshot-local).
[DEBUG] Extension realms for project com.ccih:ccih-platform-dependencies:pom:6.5.0600.0000: (none)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] No SCM translator found - skipping rewrite
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] referencedata ..................................... FAILURE [2:16.083s]
[INFO] referencedata.resolvertool ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:16.696s
[INFO] Finished at: Thu May 22 15:55:20 IDT 2014
[INFO] Final Memory: 10M/109M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:prepare (default-cli) on project referencedata: Error writing POM: D:\<correct path>\pom.xml (Access is denied) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:prepare (default-cli) on project referencedata:
Error writing POM: D:\Dev\projects\NNG\PLS\dev\PLS\PLR\pom.xml (Access is denied)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error writing POM: D:\Dev\projects\NNG\PLS\dev\PLS\PLR\pom.xml (Access is denied)
at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:281)
at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:232)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: Error writing POM: D:\Dev\projects\NNG\PLS\dev\PLS\PLR\pom.xml (Access is denied)
at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.writePom(AbstractRewritePomsPhase.java:685)
at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.writePom(AbstractRewritePomsPhase.java:632)
at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.transformProject(AbstractRewritePomsPhase.java:241)
at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.transform(AbstractRewritePomsPhase.java:131)
at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.execute(AbstractRewritePomsPhase.java:116)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:236)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:169)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:146)
at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:107)
at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:277)
... 22 more
Caused by: java.io.FileNotFoundException: D:\Dev\projects\NNG\PLS\dev\PLS\PLR\pom.xml (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
at org.codehaus.plexus.util.xml.XmlStreamWriter.<init>(XmlStreamWriter.java:59)
at org.codehaus.plexus.util.WriterFactory.newXmlWriter(WriterFactory.java:117)
at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.writePom(AbstractRewritePomsPhase.java:666)
... 31 more
【问题讨论】:
jira.codehaus.org/browse/SCM-752 【参考方案1】:这似乎是 maven-scm-provider-tfs 中的一个错误。意思是,对 maven-scm-plugin 的 TFS 支持不完整。
我为此打开了JIRA item [SCM-752],并提出了修复建议。它将在 maven-scm-plugin 的下一个版本(1.10)中发布。
【讨论】:
以上是关于maven-release-plugin:2.5:prepare 失败并显示“写入 POM 时出错:(访问被拒绝)”的主要内容,如果未能解决你的问题,请参考以下文章