Maven 3.0的"mvn release:perform"不喜欢不在git repo根目录下的pom.xml

cla*_*ion 9 pom.xml maven-3 maven maven-release-plugin

我有一个关于Maven,maven-release-plugin,git integration,pom.xml的问题,并且在repo的本地副本的子目录中而不是在根目录中有pom.xml.

这是设置:

  • 我有一个github帐户,其中包含有限数量的私有存储库
  • 我想(我只是学习)使用Maven来组织我的构建/发布
  • 我可能需要创建许多Maven"项目",每个git存储库有几个项目
  • 每个maven项目都需要一个"pom.xml"来定义其特征
  • 我不能,或者至少不方便,将所有项目pom.xml文件放在git存储库的根目录中
  • 所以我最终得到了项目的文件夹布局:
    • git_repo_root_dir
      • project_A文件夹
        • 的pom.xml
        • other_code
      • project_B文件夹
        • 的pom.xml
        • other_code
      • 等等
      • ...
  • 我可以成功进入目录git_repo_root_dir/project_A并执行"mvn release:prepare"
  • 我在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 /.做实际的构建,并且没有办法告诉"maven-release"插件在尝试弄乱pom.xml之前进入源的特殊标记副本的子目录
  • 问题:有没有办法解决这个问题?有没有选择以某种方式告诉"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 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]
Run Code Online (Sandbox Code Playgroud)

谢谢.

小智 11

这应该做的伎俩:

<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>
Run Code Online (Sandbox Code Playgroud)


Rya*_*art 7

你可以像通常告诉Maven从其他地方的POM运行一样:-f选项.mvn --help这样描述:

-f,--file <arg>    Force the use of an alternate POM
                   file.
Run Code Online (Sandbox Code Playgroud)

要在发行版中执行此操作,您只需将适当的选项传递给发布插件即可.您可以使用执行目标的"arguments"属性来执行此操作.此属性只是告诉release插件一些附加参数,以附加到mvn它在执行发布时运行的命令.您可以通过-D arguments="-f path/to/pom"在发布插件的配置中将其永久附加或设置在命令行中来设置它,类似于

<plugin>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <arguments>-f path/to/pom</arguments>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)