一个maven打包错误:

[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.2.5:revision (default) on project scheduler-server-dao: Could not complete Mojo execution...: Unable to find commits until some tag: Walk failure. Missing commit a4ae6e8f03140a20d126fdcb285b108452964bda -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :scheduler-server-dao

看错误日志描述为插件git-commit-id-plugin的错误,该插件会在打包的文件加上commitid,如果这个commitid丢失了则无法读取。

git issue https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/61

解决方案有以下几种:

  1. 升级插件版本:2.2.5 -> 3.0.0
  2. git中修复commitid
  3. 删除或者禁用pom中的该插件

此处着重讲第3种,因为可以通用:

在打包命令后加入:-Dmaven.gitcommitid.skip=true

完整命令为:mvn clean package -U -Dmaven.test.skip=true -DSHUXI_VERSION=5.1.2 -Dmaven.gitcommitid.skip=true

此命令的通用性在于maven打包的-D参数,表示环境变量