开发者

Project setup with Eclipse and Mercurial

I would like some advice on setting up a multi-project workspace using Eclipse. In other words, I intend to create some application which will use two or more projects for its final build. The projects will be stored in some version control system. This is pretty easy to do.

The advice I am seeking is how I should set up the version control or Eclipse workspace to make setting up a new developer/new machine* very simple. Ideally, that new developer or developer on a new machine would simply issue one command (to something: it could be Eclipse, the version control system, some build system, or even a script); that command will set up an environment from which it would be possible to build the code.

I will use Java for a language and Mercurial for version control, if that matters for a solution. I am open to using a build system, although I have no almost no familiarity with any of them.

Essentially, I am to hoping to learn

  • where the projects should be stored in the repository
  • how Eclipse should import or otherwise discover the projects
  • how to i开发者_JS百科nitiate the discovery mentioned above

*In this case, a new machine means a machine with necessary applications (such as Eclipse and TortoiseHg) but without checkouts of the code or any workspaces


Each Eclipse installation will need to install the MercurialEclipse plugin which can be installed through 'Install New Software...' by pointing it at the following URL: http://cbes.javaforge.com/update

Theses are the steps I usually use when setting up a new application:

  1. Setup my projects in Eclipse
  2. Go to the command line, create an hg repository and then move my projects into the folder that contains the repository.
  3. Delete the bin directories (so they don't get checked into Mercurial)
  4. Issue the 'hg add' at the root of your Mercurial repository.
  5. In Eclipse delete your projects (don't click the 'Delete project contents on disk' checkbox or you will get an error)
  6. In the File menu choose import. Select 'Existing Projects into Workspace' under the General folder.
  7. Select the 'Browse...' button next to 'Select root directory' and select your mercurial repository root folder.
  8. Click Select All in the import dialog and then click Finish.
  9. Open up the navigator view (so you can see bin folders), right click on the bin directory in one project, go to 'Team' and 'Ignore...'. Select 'Only this folder ('bin')' and click OK.
  10. Select all of the projects, right click, select 'Team' and choose 'Commit'

At this point your workspace is completely connected to a local Mercurial repository and all your folder structures are set up correctly.

When you are ready to share this with someone else you push your repository to a shared location. In another Eclipse environment (probably on another computer) Go to the 'Window' menu and select 'Show View' and 'Other...'. In the Mercurial folder select 'Mercurial Repositories' and click 'OK'. In the Mercurial Repositories view which just showed up click the 'Create Repository...' button. It looks like a team repository with the words HG and a plus sign. Put in your shared repository URL and any authentication information if needed. Right click on the repository just created and click 'Clone Repository'. That is it. All of the Eclipse setup is pulled from Mercurial and everything is set up for the second developer.

This may sound like a lot of steps but I am able to do this in less than two minutes now that I have practiced doing it a few times.


I recommend to use Maven as your build system:

  • integrates well with Eclipse
  • Eclipse-independent
  • scriptable/ can be invoked from a continuous integration server

Create somewhere a "main-golden" mercurial repository and add the multi-module POM directly at the root level. Developers then can clone this repository and call "mvn clean install" at the root level to build everything.

Create a subfolder for every subproject. You can nest them as deep as you need.


MercurialEclipse is currently being hosted at this address: https://bitbucket.org/mercurialeclipse/main/

Update site: http://mercurialeclipse.eclipselabs.org.codespot.com/hg.wiki/update_site/stable

via https://stackoverflow.com/a/2091928/916586

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜