How to disable maven release plugin check local mo

2019-04-19 00:25发布

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.

5条回答
劫难
2楼-- · 2019-04-19 00:44

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.

查看更多
Root(大扎)
3楼-- · 2019-04-19 00:52

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

查看更多
啃猪蹄的小仙女
4楼-- · 2019-04-19 00:53

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

查看更多
做自己的国王
5楼-- · 2019-04-19 01:05

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>
查看更多
Root(大扎)
6楼-- · 2019-04-19 01:08

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

查看更多
登录 后发表回答