8

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.

Andrew Eisenberg
  • 28,387
  • 9
  • 92
  • 148
  • 3
    No. Maven assumes the pom is in the current working directory and the root of the project. It does not assume the pom is at the root of the repository. One common layout (in Subversion) is /trunk/ProjectName/pom.xml. release:prepare works there. Can you elaborate on the problem you are getting with release perform? – Jeanne Boyarsky Jul 03 '13 at 23:28
  • Just curious, where *is* the pom.xml located, and is it found automatically for all other tasks, for example "mvn install", "mvn compile"? Generally you can use "mvn -f dir1/dir2/pom.xml" to use an alternate pom.xml, though I've never tried it with the release plugin. – Keith Jul 04 '13 at 17:59
  • @Keith The pom is located 2 levels below the root of the git repo. I always launch commands from the project root (not the git root) so all other mvn commands work for me and I have no need to use the -f option. – Andrew Eisenberg Jul 04 '13 at 18:34
  • @Keith shouldn't you post your last comment as an answer? – Sled Jul 04 '13 at 18:46
  • In the end, I gave up and just ran `mvn deploy`. This works and doesn't rely on as much maven magic (ie- maven isn't doing any automated tagging and pushing, which confuses our CI system). I had this all working when the project was under svn, but now I can't get it working under git. – Andrew Eisenberg Jul 04 '13 at 19:18
  • I have same type of issue. My release:prepare is running properly and tag created successfully but, after release:prepare when I am trying to run release:perform it show error.It show the current directory is /somthing/target and there is no pom.xml file exist. But I am running the maven command outside the target directory where I had executed release:perpare. – JDGuide Sep 06 '13 at 04:52

2 Answers2

7

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

Community
  • 1
  • 1
Fedy2
  • 3,147
  • 4
  • 26
  • 44
  • Thanks. Looks promising. As I said, I am no longer using the release plugin. Instead using the deploy goal. I'll try this out, though and see if it works. – Andrew Eisenberg Jul 14 '13 at 20:33
0

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.

Keith
  • 4,144
  • 1
  • 19
  • 14
  • 2
    I think you misunderstood my comment above. The pom is under source control. It is just not in the root of the source control. – Andrew Eisenberg Jul 04 '13 at 19:00
  • @Andrew, Git has no "subdirectory" concept when it comes to commits, so your scenario is unworkable in terms of Git + maven-release-plugin. The plugin has to commit/tag the whole (Git) project - and can't do it. KISS overall design is to have 1:1 Git-project:build-artifact. That said, Maven sub-modules will work but you have to run maven-release-plugin on the parent and all its sub-modules. – Andre Jun 02 '15 at 20:02