Henning
Henning

Reputation: 1421

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

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?

Upvotes: 4

Views: 1873

Answers (2)

le0diaz
le0diaz

Reputation: 2508

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

Upvotes: 2

crea1
crea1

Reputation: 12627

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.

Upvotes: 0

Related Questions