简体   繁体   English

mvn release:执行失败,因为pom文件不在存储库的根目录下

[英]mvn release:perform fails because pom file is not at root of repository

I am trying to execute mvn release:perform , but the command assumes that the pom file is at the root of the repository. 我正在尝试执行mvn release:perform ,但该命令假定pom文件位于存储库的根目录下。 Is there a system property or preference that I can set to override the default? 是否有我可以设置的系统属性或首选项来覆盖默认值?

The call to mvn release:prepare seems to have succeeded as all the release artifacts are sitting in the target directory and the repository is properly tagged. mvn release:prepare的调用似乎已成功,因为所有发布工件都位于目标目录中,并且存储库已正确标记。

In case it matters, this is a git project. 如果重要,这是一个git项目。


EDIT Here is what I did: 编辑这是我做的:

cd /path/to/git/root/path/to/mvn/project
mvn -DdevelopmentVersion=1.2.0-SNAPSHOT -DreleaseVersion=1.1.0 release:prepare
...enter correct passphrase and choose all default options...
mvn release:perform

And then cloning the remote repo in the target/checkout directory and after some churning and pushing to the remote git repo, the following error happens: 然后克隆target/checkout目录中的远程仓库,并在一些搅拌并推送到远程git仓库后,发生以下错误:

[ERROR]   
[ERROR]   The project  (/path/to/git/root/path/to/mvn/project/target/checkout/pom.xml) has 1 error
[ERROR]     Non-readable POM /path/to/git/root/path/to/mvn/project/target/checkout/pom.xml: /path/to/git/root/path/to/mvn/project/target/checkout/pom.xml (No such file or directory)

So, maven is looking for the pom file in the root of the target/checkout directory, which is not where it is located. 因此,maven正在target/checkout目录的根目录中查找pom文件,而该目录不在它所在的位置。

I had the same problem. 我有同样的问题。 Add this to your pom: 把它添加到你的pom:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.2.1</version>
  <executions>
    <execution>
        <id>default</id>
        <goals>
            <goal>perform</goal>
        </goals>
        <configuration>
            <pomFileName>subdir/pom.xml</pomFileName>
        </configuration>
    </execution>
  </executions>
</plugin>

Source: https://stackoverflow.com/a/8233712/555220 资料来源: https//stackoverflow.com/a/8233712/555220

Since the root pom is not actually in source control I think release:prepare and release:perform are not going to work for you. 由于根pom实际上不在源代码控制中,我认为发布:prepare和release:perform不适合你。 I think one of the objectives of these commands it to ensure that the released project can be built (and pass tests) based on what is source control, not what is on one person's machine. 我认为这些命令的目标之一就是确保发布的项目可以根据源控件构建(并通过测试),而不是一个人的机器上的内容。 That is why it attempts to checkout and re-build. 这就是它试图结账和重建的原因。 If the pom is simply not in source control, then this objective is not possible. 如果pom根本不在源代码控制中,那么这个目标是不可能的。 You may have to manually do the steps that release:prepare and release:perform do: remove snapshot, commit, tag, mvn deploy, increment version adding snapshot, commit. 您可能必须手动执行发布的步骤:准备和发布:执行:删除快照,提交,标记,mvn部署,增加版本添加快照,提交。

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

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