Maven-Release-Plugin: Force to use specific version of scm provider

南笙酒味 提交于 2020-01-03 19:05:11

问题


I'm in the process of trying to migrate our repository from SVN to Git and I'm having trouble with the release plugin on a very large project.

Problem:

There are about 50+ sub-modules to this project and it tries to add all the modified poms as one 'git add -- '. This breaks the windows command line limit.

Fortunately a fix was put in for this in release 1.8.1 of maven-scm-provider-gitexe however the maven-release-plugin is currently set up to use 1.7 which does not have the fix.

I have tried adding the following to my root pom.xml but I can still see it downloading 1.7 during mvn release:prepare and even running the process in verbose mode gives no indication that it is using 1.8.1.

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.3.2</version>
    <executions>
      <execution>
        <id>default</id>
        <goals>
          <goal>perform</goal>
        </goals>
        <configuration>
          <pomFileName>subproj/pom.xml</pomFileName>
        </configuration>
      </execution>
    </executions>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.scm</groupId>
        <artifactId>maven-scm-api</artifactId>
        <version>1.8.1</version>
      </dependency>
      <dependency>
        <groupId>org.apache.maven.scm</groupId>
        <artifactId>maven-scm-provider-gitexe</artifactId>
        <version>1.8.1</version>
      </dependency>
    </dependencies>
  </plugin>

I have also tried adding the following to the pom.xml in case that forces it to use the right version with no more luck.

<extensions>
    <extension>
      <groupId>org.apache.maven.scm</groupId>
      <artifactId>maven-scm-provider-gitexe</artifactId>
      <version>1.8.1</version>
    </extension>
</extensions>    

The reason I suspect it is not using 1.8.1 is that it still fails trying to do a git add with all the pom files whereas I have checked the plugin source code which definitely looks like it should be adding each file individually for Windows (I've even double-check the codehaus plexus Os.isFamily(Os.FAMILY_WINDOWS) to ensure that is returning true on my machine.

What am I missing? How can I force the release plugin to use the right version of the scm plugin?


回答1:


According to maven release plugin 2.4.1 changelog http://jira.codehaus.org/secure/ReleaseNote.jspa?projectId=11144&version=19050, SCM has been fall back to 1.7 in this version due to a bug with 'git status --porcelain'.

  • So you should try the 2.4 version. It should work and maybe you will not be affect with the bug.
  • Or wait for a future version ...

EDIT : The bug is related to this SCM bug : http://jira.codehaus.org/browse/SCM-686

A comment says to use maven-scm-provider-gitexe AND maven-scm-provider-git-commons as dependencies

<dependencies>
    <dependency>
      <groupId>org.apache.maven.scm</groupId>
      <artifactId>maven-scm-provider-gitexe</artifactId>
      <version>1.8.1</version>
    </dependency>
   <dependency>
    <groupId>org.apache.maven.scm</groupId>
    <artifactId>maven-scm-provider-git-commons</artifactId>
    <version>1.8.1</version>
   </dependency>       
</dependencies>



回答2:


Silly question but, have you thought about moving all these sub modules in their own git projects? And release them separately?




回答3:


As suggested Aurelien, extract the sub-projects into separate modules. Following this principle will make your life simpler. You won't have to release modules which don't have changes, just for the sake of releasing. Furthermore, the build time will be taken down. If you have a look at most Java projects hosted on Github, you'll see that a lot of people have extracted each of their modules into separate projects. Git is mainly meant to work with smaller repositories.

You can extract the history of the sub-directory like this:

git remote rm origin
git filter-branch --subdirectory-filter ${project} HEAD
git remote add origin git@foo.com:path/to/${project}.git
git branch --set-upstream master origin/master
git push

Not the king of answer you were looking for, I believe, but I think this could help you get on the right path and, if you don't move all your projects like this, at least, it will shorten your list, and, maybe help you workaound the problem.



来源:https://stackoverflow.com/questions/17233718/maven-release-plugin-force-to-use-specific-version-of-scm-provider

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