[英]Maven 3.0's “mvn release:perform” doesn't like a pom.xml that isn't in its git repo's root directory
I have a question about Maven, the maven-release-plugin, git integration, pom.xml's, and having pom.xml's in subdirectories of the repo's local copy rather than in the root. 我有一个关于Maven,maven-release-plugin,git integration,pom.xml的问题,并且在repo的本地副本的子目录中而不是在根目录中有pom.xml。
Here's the setup: 这是设置:
Here's the actual error I get during this process: 这是我在此过程中遇到的实际错误:
[INFO] --- maven-release-plugin:2.0:perform (default-cli) @ standard_parent_project ---
[INFO] Checking out the project to perform the release ...
[INFO] Executing: /bin/sh -c cd "/Users/___/DEV c8ion 01/maven_based_code/0maven/standard_parent_project/target" && git clone git@github.com:clarafaction/0maven.git '/Users/___/DEV c8ion 01/maven_based_code/0maven/standard_parent_project/target/checkout'
...
/* note, the pom.xml the build should go out of at this point is at
'/Users/___/DEV c8ion 01/maven_based_code/0maven/standard_parent_project/target/checkout/standard_parent_project/pom.xml'
*/
...
[INFO] [ERROR] The goal you specified requires a project to execute but
there is no POM in this directory
(/Users/___/DEV c8ion 01/maven_based_code/0maven/standard_parent_project/target/checkout).
Please verify you invoked Maven from the correct directory. -> [Help 1]
Thanks. 谢谢。
This should do the trick: 这应该做的伎俩:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>perform</goal>
</goals>
<configuration>
<pomFileName>your_path/your_pom.xml</pomFileName>
</configuration>
</execution>
</executions>
</plugin>
You can do it in the same way you normally tell Maven to run from a POM that's somewhere else : the -f
option. 你可以像通常告诉Maven从其他地方的POM运行一样 : -f
选项。 mvn --help
describes it thusly: mvn --help
如此描述:
-f,--file <arg> Force the use of an alternate POM
file.
To do that in a release, you just need to pass the appropriate option to the release plugin. 要在发行版中执行此操作,您只需将适当的选项传递给发布插件即可。 You can use the perform goal's "arguments" property to do that. 您可以使用执行目标的“arguments”属性来执行此操作。 This property just tells the release plugin some additional arguments to append to the mvn
command it runs when doing the release. 此属性只是告诉release插件一些附加参数,以附加到它在执行发布时运行的mvn
命令。 You can set it from the command line by appending -D arguments="-f path/to/pom"
or set it permanently in the pom in the release plugin's configuration, something like 您可以通过附加-D arguments="-f path/to/pom"
从命令行设置它,或者在发布插件的配置中永久地将它设置在pom中,类似于
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.3</version>
<configuration>
<arguments>-f path/to/pom</arguments>
</configuration>
</plugin>
The first thing is to understand git which has it's convention that every project has it's own repository. 首先要理解git,它具有每个项目都拥有自己的存储库的约定。 The next thing is that Maven has it's conventions and putting the pom.xml into the root of it's project is the most obvious one. 接下来的事情是Maven有它的约定,把pom.xml放到它的项目的根目录中是最明显的。 Furthermore you are trying to fight against Maven and i will predict that you will lose the combat and make your life not easy. 此外,你正试图与Maven作战,我预测你将失去战斗,让你的生活变得不容易。 If your projects A and B are related (same versio number or same release times) in some kind you should think about a multi-module build which results in a structure like this: 如果您的项目A和B是相关的(相同的版本号或相同的发布时间),您应该考虑一个多模块构建,这将产生如下结构:
root (Git Repos)
+-- pom.xml
+--- projectA (pom.xml)
+--- projectB (pom.xml)
and you can do a release of both projectA (better calling it a module) and module b in a single step from the root. 并且您可以从根目录一步发布projectA(更好地称之为模块)和模块b。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.