问题
I use maven release plugin. In my pom exists and Ant task that automatically fix some properties files with additional information. This fixes should not be in SCM. But maven don't finish with success for error:
Cannot prepare the release because you have local modifications
Does it possible to set some parameters to don't check local modifications?
Thanks.
回答1:
I'm not very familiar with maven-release-plugin, but I can see that there is a checkModificationExcludes property that you can use for your purpose. The config should be somewhat like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
...
<checkModificationExcludes>
<checkModificationExclude>file_1</checkModificationExclude>
<checkModificationExclude>dir_1/file_2</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>
回答2:
We were trying to run the release from jenkins but it always failed with the same message...
Cannot prepare the release because you have local modifications
... which was weird, because we use jenkins to check out and build the latest sources before releasing.
We finally figured out that the problem was that we were building on a Windows node and some file paths were too long which caused the maven-release-plugin to complain about local modifications. Switching to a linux node solved this problem.
回答3:
Removing my project's target
folder from source control fixed this issue for me.
回答4:
I would suggest fixing your build process, so that it does not 'fix up' files that are under SCM. There are several ways of doing this, the simplest is to copy properties files in question to some directory under ${project.build.outputDirectory}
, and run your Ant script on these files, rather than originals
回答5:
@AndrewLogvinov's answer is half way there. The other half is mentioned in this:
I discovered that the comparison in org.apache.maven.shared.release.phase.ScmCheckModificationsPhase.execute() strips the path and compares file names only. So, I changed my pom to ignore application.properties instead of ${thewholepath}/applications properties. Lo and behold, success.
For some weird reason, you can't include paths in this tag. You can only specify file names.
回答6:
It worked on Windows in my case by renaming job name to a shorter length (About 20 characters).
In my case, Jenkins job name and also svn branch name were longer (About 40 characters). If some file paths are too long it causes the maven-release-plugin to complain about local modifications. Jenkin creates a local workspace with the job name
e.g. For and as below, Jenkins job while releasing will start complaining about local modifications.
D:\dev.env\data\jenkins\jobs\<LongerJobName>\workspace\<LongerBranchName>\testCommonJar\src\main\java\com.example.webservice.service.TestServiceImpl.java
来源:https://stackoverflow.com/questions/9140315/how-to-disable-maven-release-plugin-check-local-modifications