Uploaded image for project: 'Maven Release Plugin'
  1. Maven Release Plugin
  2. MRELEASE-769

Release:prepare fails on Windows when commonBaseDir of all reactor projects is root drive (e.g. D:\)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.3.1
    • None
    • prepare
    • None
    • Windows 7 x64, Maven 3.0.4, Maven Release Plugin 2.3.1
    • Patch

    Description

      When running a release:prepare for a project in the RewritePomsForRelease phase, a NullPointerException is thrown when calculating the number of parent folders above the project root (part of the . This occurs when the reactor projects have a commonBaseDir that is the root drive - in my case D: . This is because the commonBaseDir is calculated to be "D:", whereas the java.io.File.getParentFile() method used in ReleaseUtil.getBaseWorkingDirectoryParentCount() returns "D:\" when it gets to the root. As a result the equality comparison between these directories fails, and the method continues looking above that location for a parent folder, resulting in the NPE.

      This can be reproduced by creating a reactor build where projects in the reactor only share a commonBaseDir which is a Windows root drive - I haven't included a test case because it's dependent on where you put it, not what it contains.

      I've attached a patch which normalises the commonBaseDir name by adding a trailing slash, in ReleaseUtil.java in the Maven Release Manager project. This could also be done after line 310 of the AbstractRewritePomsPhase, where the variable is originally assigned, but the ReleaseUtil.getCommonBasedir() method explicitly removes the trailing slash, so it seemed best to do it as close to the problem as possible.

      Stack trace from mvn -DdryRun=true release:prepare -X

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.1:prepare (default-cli) on project amee-platform-api: Execution default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.3.1:prepare failed. NullPointerException -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.1:prepare (default-cli) on project amee-platform-api: Execution default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.3.1:prepare failed.
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
              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:320)
              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
              at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
              at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
              at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
              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:290)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
              at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
              at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.apache.maven.plugins:maven-release-plugin:2.3.1:prepare failed.
              at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
              at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
              ... 19 more
      Caused by: java.lang.NullPointerException
              at org.apache.maven.shared.release.util.ReleaseUtil.getBaseWorkingDirectoryParentCount(ReleaseUtil.java:249)
              at org.apache.maven.shared.release.phase.RewritePomsForReleasePhase.translateScm(RewritePomsForReleasePhase.java:135)
              at org.apache.maven.shared.release.phase.RewritePomsForReleasePhase.transformScm(RewritePomsForReleasePhase.java:68)
              at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.transformDocument(AbstractRewritePomsPhase.java:317)
              at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.transformProject(AbstractRewritePomsPhase.java:219)
              at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.transform(AbstractRewritePomsPhase.java:125)
              at org.apache.maven.shared.release.phase.AbstractRewritePomsPhase.simulate(AbstractRewritePomsPhase.java:712)
              at org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:228)
              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:291)
              at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:247)
              at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
              ... 20 more
      

      Attachments

        1. ReleaseUtil_WindowsRootPatch
          0.8 kB
          Conan Cook

        Issue Links

          Activity

            People

              rfscholte Robert Scholte
              cook.conan@gmail.com Conan Cook
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: