Maven multi module project with git submodule: release perform fails

354 Views Asked by At

I have a Maven multi-module project. One of the module is a git submodule

proj-root

  • proj-module
  • proj-submodule

When I try maven release:prepare, the project fails. I have tried multiple ways but still not succesful.

I follow the following steps:

  • Clone the root project and cd into the cloned project folder
  • git submodule sync
  • git submodule update --init --remote
  • mvn --batch-mode -DcommitByProject=true release:prepare
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M7:prepare (default-cli) on project proj-root: An error is occurred in the checkin process: Exception while executing SCM command. Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M7:prepare (default-cli) on project proj-root: An error is occurred in the checkin process: Exception while executing SCM command.
    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)
  ... 
Caused by: org.apache.maven.plugin.MojoExecutionException: An error is occurred in the checkin process: Exception while executing SCM command.
    at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:417)
    at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:349)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    ... 20 more
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: An error is occurred in the checkin process: Exception while executing SCM command.
    at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin(AbstractScmCommitPhase.java:191)
    at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.performCheckins(AbstractScmCommitPhase.java:168)
    at org.apache.maven.shared.release.phase.AbstractScmCommitPreparationPhase.runLogic(AbstractScmCommitPreparationPhase.java:88)
    ... 23 more
Caused by: org.apache.maven.scm.ScmException: Exception while executing SCM command.
    at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:64)
    at org.apache.maven.scm.provider.git.AbstractGitScmProvider.executeCommand(AbstractGitScmProvider.java:300)
    at org.apache.maven.scm.provider.git.AbstractGitScmProvider.checkin(AbstractGitScmProvider.java:218)
    ... 29 more
Caused by: org.apache.maven.scm.ScmException: Detecting the current branch failed: fatal: ref HEAD is not a symbolic ref

My finding is that the above error is because the submodule "proj-submodule" is at HEAD and not specific branch.

* (HEAD detached from c560983)
  master

I tried it differently now:

  • Clone the root project and cd into the cloned project folder
  • git submodule sync
  • git submodule update --init --remote
  • cd proj-submodule && git checkout master && cd -
  • mvn --batch-mode -DcommitByProject=true release:prepare
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M7:prepare (default-cli) on project proj-root: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] To github.com:user1234/proj-root.git
[ERROR] ! [rejected]        master -> master (fetch first)
[ERROR] error:********@github.com:user1234/proj-root.git'
[ERROR] hint: Updates were rejected because the remote contains work that you do
[ERROR] hint: not have locally. This is usually caused by another repository pushing
[ERROR] hint: to the same ref. You may want to first integrate the remote changes
[ERROR] hint: (e.g., 'git pull ...') before pushing again.
[ERROR] hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[ERROR] -> [Help 1]

I don't understand why the above error even through there were no changes pushed to repo. When I looked into it the repo, the release version of pom files were updated to root and proj-module but not to proj-submodule. So my analysis is that the failure is again due to the submodule (git submodule project).

Can anyone help resolve the issue? Regular release builds with or without modules complete successfully but not the one with a submodule (git submodule).

0

There are 0 best solutions below