maven-release-plugin in multi-module project having a seperate git repository for each module

对着背影说爱祢 提交于 2019-12-12 13:29:25

问题


I wonder if it's possible to use the maven-release-plugin in a multi module project where each module has its own git repository? Something like this:

parent/
  .git/
  pom.xml
module1/
  .git/
  pom.xml

I set up a simple test (under linux) and it fails for the "git add" command (simplyfied):

cd parent && git add -- pom.xml /.../module1/pom.xml

The error message is

fatal: /.../module1/pom.xml: '/.../module1/pom.xml' is outside repository

I understand that this git command can't work. Is maven-release-plugin able to do a seperate "git add" command for each repository?

Just for the case the answer is NO: Assume i only have a single git repository. Does it matter whether i use a flat hierarchy or a nested one?

Are there any other options for automated versioning/releasing and keeping multiple git repositories?


回答1:


Since maven-release-plugin 2.0-beta-5 they added a new property called commitByProject that in my case (that happens to be exactly your case) let us commit per project each submodule (referenced from root pom with 'git submodule add' strategy). And this gets the job done!!

mvn release:prepare -DcommitByProject=true




回答2:


You can use git submodules to have other git repositories inside your git repository. But if your module1 have a dependency to parent through maven (i.e <parent> or parent has dependencyManagement), there seems like module1 isn't really a standalone module and should not have it's own repository in my opinion.

About hierarchy I prefer nested ones to more easily see parent and modules.



来源:https://stackoverflow.com/questions/24201482/maven-release-plugin-in-multi-module-project-having-a-seperate-git-repository-fo

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