Maven 3.0 的“mvn release:perform”不喜欢不在 git repo 根目录中的 pom.xml

2023-11-25

我有一个关于 Maven、maven-release-plugin、git 集成、pom.xml 以及将 pom.xml 放在存储库本地副本的子目录而不是根目录中的问题。

这是设置:

  • 我有一个 github 帐户,其中私人存储库数量有限
  • 我想(正在学习)使用 Maven 来组织我的构建/发布
  • 我可能需要创建许多 Maven“项目”,每个 git 存储库有几个项目
  • 每个maven项目都需要一个“pom.xml”来定义其特性
  • 我不能,或者至少不方便,将所有项目 pom.xml 文件放在 git 存储库的根目录中
  • So I end up with this folder layout for projects:
    • git_repo_root_dir
      • project_A folder
        • pom.xml
        • 其他代码
      • project_B folder
        • pom.xml
        • 其他代码
      • etc.
      • ...
  • 我可以成功转到目录 git_repo_root_dir/project_A 并执行“mvn release:prepare”
  • I fail with this step in git_repo_root_dir/project_A: "mvn release:perform"
    • 问题似乎是 git-tagged 代码已成功签出到 git_repo_root_dir/project_A/target/checkout/project_A 准备发布构建,但签出后“maven-release”插件会转到目录 git_repo_root_dir/project_A /目标/结帐/。而不是 git_repo_root_dir/project_A/target/checkout/project_A/。进行实际的构建,并且在尝试弄乱 pom.xml 之前,无法告诉“maven-release”插件进入源代码的特殊标记副本的子目录
  • 问:有办法解决这个问题吗?是否有一个选项可以以某种方式告诉“mvn release:perform”转到子目录?

这是我在此过程中遇到的实际错误:

[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 [email protected]: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.


这应该可以解决问题:

<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Maven 3.0 的“mvn release:perform”不喜欢不在 git repo 根目录中的 pom.xml 的相关文章

随机推荐