I am currently working on a Java project within a team of 5 colleagues for university. Actually, we will finish the planning phase within the next few days and then start implementing.
For the project, we have to use Mercurial (via Bitbucket.org) and Apache Maven. We'd like to use Eclipse as IDE. I know how to use Mercurial, and I've read some articles and guides about Maven. The thing I don't understand is how we should use those tools in collaboration.
What should be placed on the repository? The whole Eclipse project? Or just the source files and Maven's pom.xml? If the latter, how would a working session look like? Pull the files, create an Eclipse project with mvn eclipse:eclipse, code a while and commit/push them to the repo?
I am responsible for creating the project structure, so my colleagues - and me too - can start developing. But I really don't know how to start now. If the use of Maven wasn't obligatory, I would just place the Eclipse project into the repository. But having to use it, I'm quite confused now how if affects everything.
I use a similar setup, except I am using Dropbox for my repository (just two developers). Just follow these steps, with the m2eclipse (update site: http://m2eclipse.sonatype.org/sites/m2e) and the MercurialEclipse (update site: http://cbes.javaforge.com/update) plugin you can do all in eclipse.
Create a maven project:
File -> New -> Other -> Maven project
In Project explorer right click on the new created maven project
Team -> Share Project... -> Mercurial -> (leave the folder as it is) Finish
Then create an .hgignore file in the project root:
In Project explorer right click on the new created maven project
New -> File -> File Name: .hgignore and Finish
.hgignore:
syntax: regexp
target # maven output
\.classpath # eclipse
\.project # eclipse
\.settings # eclipse
test-output # eclipse junit/testng plugin output
Then you can make your first commit, but beware, hg does not store empty folders in it's repository, so to keep the maven folder structure with no source code in it you have to put a (empty) file in each empty folder, for a simple maven project without any sources it would be in the folders:
- myproject/src/main/java
- myproject/src/main/resources
- myproject/src/test/java
- myproject/src/test/resources
For example I put a file with the name .empty in it with the content "this is a placeholder file, remove if other files are in this folder"
If some of this folders are missing your colleagues would see errors in eclipse if they import your project.
First commit:
In Project explorer right click on the new created maven project
Team -> Commit... -> Select all and enter a commit message -> Finish
Now you can clone it to bitbucket (I don't have experience with bitbucket).
Tell your colleagues to install the two eclipse plugins and then they can get the repo via
File -> New -> Other -> Check out Maven Project from SCM -> enter url to your repo -> Finish
And then you are good to go.
Here are alternatives based on practices at the ASF (though we don't use Mercurial).
To begin with, set up a source tree with Maven build that you check into Hg. Don't touch eclipse yet. You'll want to find some Eclipse plugin for Hg.
Then, look at two alternatives: the maven-eclipse-plugin and M2eclipse.
The maven-eclipse-plugin is a maven plugin. You run it from command line, and it generates .project and .classpath and some of .settings. It's not currently being worked on, but it's quite stable and functional in many common cases. You then import 'existing Eclipse project' and you are good to go.
M2Eclipse is an Eclipse plugin that integrates Maven builds. It's quite ambitious. However, it's current avatar is quite new, and can be full of surprises.
来源:https://stackoverflow.com/questions/5676267/how-to-use-mercurial-maven-and-eclipse-together