How do I simultaneously create a Maven project and branch it?

293 views Asked by At

My company does a lot of projects that look very similar. Time for a Maven archetype, right? I think so.

To speed up the process, I don't want the developer of each project to have to manually set up source control (we use Mercurial). Instead, when the the project is created from a Maven archetype, it should already be attached to a version control repository, and Maven creates a branch just for that project.

My attempt so far has an archetype whose source pom has the desired SCM info in it, so the project is created with version control. However, since there's no .hg directory on disk, Mercurial doesn't believe the project's under source control. I think my only option is doing something with scm:bootstrap, but I'm not sure: I've only been working with Maven for two days.

BTW, we're using Eclipse and the m2eclipse plugin, so if there's an Eclipse-only way of doing this, it's fine with me.

1

There are 1 answers

1
crowne On

I haven't used mercurial extensively, but from what I've seen it works best if each project is in its own repository.

I had to get used to this difference from the default way that subversion works, where it is natural to have multiple projects in a single repository.

The branch applies to all files in the repository, and if that repository contains multiple projects, then they're all carried through on the branch, and all subsequent clones.
If you're creating a lot of similar projects, do you really want to carry all of them around in your one single repository, when you probably only working on one of them at a time?

And every time that you tag or branch one project you'll have that tag applied to all projects in the repository.

See this article for a developers thought on how to use maven with mercurial.

Note that after creating the project, whether via an archetype or not, the first step is to create the repository 'manually' by issuing the command hg init.