Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven release:prepare : Cannot prepare the release because you have local modifications

I'm facing a problem with continuum's release:prepare phase which fails in scm-check-modifications step with error :

[ERROR] org.apache.maven.shared.release.ReleaseFailureException: Cannot prepare the release because you have local modifications : [pom.xml:modified]

What i did :

  1. I commited all my changes (*.java and pom.xml) into SVN
  2. I made a build of the project in Continuum
  3. I launched the preparation of the release.

I know that the scm-check-modifications calls ScmCheckModificationsPhase class that verifies that there are no local changes compared to what is on the SCM.

I understand if i'm working with only Maven, if there are some locally changes, or any differences between the local code and the SVN for example, release:prepare won't work, because it checks for modifications first; but working with Continuum,i don't know why it should be a differencse between the local code and the SVN repository ? So i don't know why the release:prepare goal in Continuum is facing that problem.

Example of my pom :

    <build>
      <plugins>
    ...
       <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <configuration>
                <useReleaseProfile>false</useReleaseProfile>
          </configuration>
       </plugin>

    ...     
      </plugins>

    </build>


<scm>
  <connection>scm:cvs:ext:url:/var/cvs:application_name</connection>         <developerConnection>scm:cvs:ext:url:/var/cvs:application_name</developerConnection>
</scm>

.....
</project>

In the parent pom.xml:

...
    <pluginManagement>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.2.2</version>
          <configuration>
            <useReleaseProfile>false</useReleaseProfile>
            <goals>deploy</goals>
            <arguments>-Prelease</arguments>
          </configuration>
        </plugin>
.....

For information, the build and the release of the project is always working fine, until now.

There is a Bypass solution that solved my issue but i still seeking to understand the origin of this problem.

The bypass solution:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.2.2</version>
  <configuration>
    ...
    <checkModificationExcludes>
      <checkModificationExclude>pom.xml</checkModificationExclude>
    </checkModificationExcludes>
  </configuration>
</plugin>
like image 261
Ahmed MANSOUR Avatar asked Apr 24 '13 18:04

Ahmed MANSOUR


5 Answers

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
    <checkModificationExcludes>
        <checkModificationExclude>pom.xml</checkModificationExclude>
        <checkModificationExclude>**</checkModificationExclude>
    </checkModificationExcludes>
</configuration>

like image 75
Rahul Dahiya Avatar answered Nov 18 '22 16:11

Rahul Dahiya


Removing my project's target folder from source control fixed this issue for me.

like image 28
Adil Hussain Avatar answered Nov 18 '22 15:11

Adil Hussain


I can confirm, that adding the plugin or configuring it to exclude the pom.xml check did work:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <configuration>
    <checkModificationExcludes>
        <checkModificationExclude>pom.xml</checkModificationExclude>
    </checkModificationExcludes>
  </configuration>
</plugin>
like image 23
4F2E4A2E Avatar answered Nov 18 '22 15:11

4F2E4A2E


For everybody who don't want to change the pom.xml a commandline option does the trick:

mvn [...] -DcheckModificationExcludeList=pom.xml,.maven/spy.log

I had the problem on our hudson / jenkins CI environment which complained about changes in the .maven/spy.log

like image 5
Lonzak Avatar answered Nov 18 '22 14:11

Lonzak


For me solution is staging and commiting pom.xml or any other changed file to push git

like image 3
Ali Karaca Avatar answered Nov 18 '22 15:11

Ali Karaca