title: maven-release-plugin:2.5:prepare fails with "Error writing POM: (Access is denied)"
body: <p>I try to run mvn release:prepare (of course, after release:clean), and I get an error:</p>
  
  <p><strong>Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:prepare (default-cli) ...: Error writing POM: D:\\pom.xml (Access is denied)</strong></p>
  
  <p><strong>Caused by: java.io.FileNotFoundException: D:...\pom.xml (Access is denied)</strong></p>
  
  <p>The problem: The file IS IN THE specified location, but it is write-protected (because it is under SCM). All poms must be checked-in, otherwise I get an error in earlier stage (check-poms phase). So pom must be checked-in, i.e. write-protected, hence I get "access denied" exception, and it does not make any sense!</p>
  
  <p>After downoading the maven sources scm-plugin and release-plugin), I tried to find something but unfortunately could not find a reason for this exception. Maybe I am missing something, so I post it here, maybe someone can shed some light.</p>
  
  <p>I've added logs in several points in the code (in DefaultReleaseManager, so I can see the phases), re-built and I see that it fails on phase called '<strong>rewrite-poms-for-release</strong>', which is the phase where maven tries to change my poms into release, and check them in again. But the thing is that these poms are under source-control, so they are read only. So the plugin cannot write to these poms, so it returns the error 'access denied'.</p>
  
  <p>Tried to see if there is something in the relevant class, <code>class RewritePomsForReleasePhase extends AbstractRewritePomsPhase</code>, but found nothing. Tried to run it with -X, so i got the relevant exception (see below).</p>
  
  <p>I work with maven-release-plugin:2.5, maven-scm-plugin:1.9, the provider is TFS (but I do not see how it is relevant for my error, since it does not fail in the 'provider' or in the scm-plugin.)</p>
  
  <hr>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>Just tried to reproduce with maven-release-plugin:2.1, which I know works for sure (with maven-scm:1.4). I get the same error. So I guess something in my configuration is incorrect... Maybe there are experts here that can help? Maybe it is related to the maven-scm-plugin?</p>
  
  <pre><code>[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:\&lt;correct path&gt;\pom.xml (Access is denied) -&gt; [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.&lt;init&gt;(FileOutputStream.java:194)
          at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:145)
          at org.codehaus.plexus.util.xml.XmlStreamWriter.&lt;init&gt;(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
  </code></pre>
  
  <hr>