简体   繁体   English

Maven-release-plugin部署目标在git存储库中具有顶级文件夹的项目上失败

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

We have a Maven project structured in a GIT repository with the following folders: 我们在GIT存储库中构建了一个Maven项目,其中包含以下文件夹:

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. 现在,我们试图使用maven-release-plugin来发布代码。

When running 'mvn release:prepare release:perform', the prepare phase works fine but when the perform phase runs we get the following error: 当运行'mvn release:prepare release:perform'时,prepare阶段运行良好,但是当perform阶段运行时,我们得到以下错误:

[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. 当在C:\\ CI \\ Jenkins \\ jobs \\ test 6 \\ workspace \\ Parent项目文件夹\\ target \\ checkout文件夹中查找时,实际上那里没有POM文件。 This is because the 'git checkout' has checked out the tag that was created which is against the 'Parent project folder'. 这是因为'git checkout'已经签出了与'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. 因此,在checkout文件夹中,我们有“ Parent项目文件夹”,没有POM文件,因为POM位于“ Parent项目文件夹”中,而不是位于存储库的顶层。

We know that a solution to this problem would be to move the POM to right at the top level of the repository (ie outside of 'Parent project folder') but would like to explore if there any alternative solutions. 我们知道,解决此问题的方法是将POM移至存储库的顶层(即“父项目文件夹”外部),但是想探索是否有其他解决方案。

We have a similar setup of a project in SVN and the release plugin works fine. 我们在SVN中具有类似的项目设置,并且release插件运行良好。 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. 这似乎是因为创建标签时,标签中仅显示“父项目文件夹”中的内容,因此POM被检出到目标中。 In git the actual 'Parent project folder' is tagged and so this is checked out into target and the POM lives within that. 在git中,实际的“父项目文件夹”被标记了,因此将其检出到目标中,并且POM位于其中。

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'? 实际运行发布插件时,有什么事情可以告诉它运行目标,例如从'C:\\ CI \\ Jenkins \\ jobs \\ test 6 \\ workspace \\ Parent项目文件夹\\ target \\ checkout \\ Parent项目运行文件夹”而不是“ C:\\ CI \\ Jenkins \\ jobs \\ test 6 \\ workspace \\ Parent项目文件夹\\ target \\ checkout”?

I expect this is a long shot but thought it would be worth asking. 我希望这是一个遥远的尝试,但我认为值得一问。

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. 因此,如果我没看错,听起来像是问题所在,当release:perform对其内部调用mvn deploy ,找不到父pom文件,因为它在子目录中更深了一层。

The solution then is to tell the inner call where to find the pom file: 然后的解决方案是告诉内部调用在哪里找到pom文件:

mvn release:perform

to

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

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM