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

允我心安 提交于 2019-12-10 03:14:35

问题


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>

回答1:


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>



回答2:


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




回答3:


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




回答4:


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




回答5:


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



来源:https://stackoverflow.com/questions/16199154/maven-releaseprepare-cannot-prepare-the-release-because-you-have-local-modifi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!