18

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.

user710818
  • 23,228
  • 58
  • 149
  • 207

6 Answers6

34

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>
Andrew Logvinov
  • 21,181
  • 6
  • 52
  • 54
  • You can also do **/org.eclipse.wst.validation.prefs – Josh Unger Sep 18 '13 at 20:24
  • 2
    What exactly is this snippet doing? Does it only skip verification for both files but still include them into the artifact OR will these files not be included in the artifact? – Munchkin Dec 06 '18 at 08:34
4

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.

user1867477
  • 156
  • 1
  • 2
2

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

Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
1

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

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
1

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

Alexander Pogrebnyak
  • 44,836
  • 10
  • 105
  • 121
0

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