maven-release-plugin deploy goal fails on project with folder at top level in git repository

允我心安 提交于 2019-12-13 18:12:58

问题


We have a Maven project structured in a GIT repository with the following folders:

Parent project folder
------> pom.xml
------> Child 1 project folder
------> ------> pom.xml
------> Child 2 project folder
------> ------> pom.xml

We are now trying to use the maven-release-plugin in order to go releases of the code.

When running 'mvn release:prepare release:perform', the prepare phase works fine but when the perform phase runs we get the following error:

[INFO] --- maven-release-plugin:2.0:perform (default-cli) @ PARENTPROJECT ---
[INFO] Checking out the project to perform the release ...
[INFO] Executing: cmd.exe /X /C "git clone ssh://GITREPO.git "C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target\checkout"
"
[INFO] Working directory: C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target
[INFO] Executing: cmd.exe /X /C "git fetch ssh://GITREPO.git"
[INFO] Working directory: C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target\checkout
[INFO] Executing: cmd.exe /X /C "git checkout PARENTPROJECT-0.0.0.0.2"
[INFO] Working directory: C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target\checkout
[INFO] Executing: cmd.exe /X /C "git ls-files"
[INFO] Working directory: C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target\checkout
[INFO] Executing goals 'deploy'...
[WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] [INFO] Scanning for projects...
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 0.063s
[INFO] [INFO] Finished at: Fri Feb 07 15:07:26 GMT 2014
[INFO] [INFO] Final Memory: 1M/15M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target\checkout). Please
 verify you invoked Maven from the correct directory. -> [Help 1]

When looking in the C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target\checkout folder, there is indeed no POM file in there. This is because the 'git checkout' has checked out the tag that was created which is against the 'Parent project folder'.

Therefore, within the checkout folder, we have 'Parent project folder' and no POM file because the POM lives within 'Parent project folder' rather than right at the top level of the repository.

We know that a solution to this problem would be to move the POM to right at the top level of the repository (i.e. outside of 'Parent project folder') but would like to explore if there any alternative solutions.

We have a similar setup of a project in SVN and the release plugin works fine. This seems to be because when the tag is created, only the contents within 'Parent project folder' appear in the tag so the POM is checked out into target. In git the actual 'Parent project folder' is tagged and so this is checked out into target and the POM lives within that.

Is there anything that we can do when actually running the release plugin to tell it to run goals such as deploy to run from 'C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target\checkout\Parent project folder' rather than 'C:\CI\Jenkins\jobs\test 6\workspace\Parent project folder\target\checkout'?

I expect this is a long shot but thought it would be worth asking.


回答1:


So if I'm reading you correctly, it sounds like the problem is that when release:perform makes its inner call mvn deploy it can't find the parent pom file because it's buried one level deeper in a subdir.

The solution then is to tell the inner call where to find the pom file:

mvn release:perform

to

mvn release:perform -Dgoals='deploy -f parent_project_folder/pom.xml'

Hope that helps.



来源:https://stackoverflow.com/questions/21632947/maven-release-plugin-deploy-goal-fails-on-project-with-folder-at-top-level-in-gi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!