简体   繁体   中英

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. 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.

In case it matters, this is a git project.


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:

[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.

I had the same problem. Add this to your 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

Since the root pom is not actually in source control I think release:prepare and release:perform are not going to work for you. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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