6

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 initiate 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

Eric
  • 18,512
  • 4
  • 29
  • 34
  • So you want an easy way to duplicate your developer environment? – JPelletier Feb 07 '11 at 16:29
  • Yes, I want an easy way to have a development environment set up on another machine and I hope to do it from some central repository. But more than that, I am hoping to get advice on the best way to set up the environment in the first place. – Eric Feb 07 '11 at 16:33

3 Answers3

8

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.

rancidfishbreath
  • 3,944
  • 2
  • 30
  • 44
  • 1
    Isn't it easier to add a line to `.hgignore` manually to ignore the `bin/` directory before creating the repo, and create it in-place, rather than creating it in an empty directory and pulling the files in? – Daisy Leigh Brenecki Mar 20 '11 at 01:31
  • Yes it would be easier to create the .hgignore manually. In order to put your projects into the repo in one step you can do it one of two ways. First off create the repo in your workspace directory (this won't work if you want to be able to put different projects in different repos) or second, when you create your new project unclick the "Use default location" and browse to where you put your repo. – rancidfishbreath Mar 21 '11 at 13:00
  • I think (right click on project) -> Team -> Share Project creates a repo whose root is the project (rather than the workspace) root as well. I'd have to check whether it automatically does an add and initial commit, however I don't think it does which means you can get your `.hgignore` in there that way too. – Daisy Leigh Brenecki Mar 21 '11 at 22:20
  • What is the point of creating your projects and then deleting your projects? – Noumenon May 09 '18 at 02:02
  • This was a long time ago, and I remember struggling with some early bugs in MercurialEclipse. Maybe this step was a work around? I am guessing that deleting isn't necessary any more, but I haven't been in the Mecurial ecosystem in awhile. – rancidfishbreath May 09 '18 at 04:46
1

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.

Puce
  • 37,247
  • 13
  • 80
  • 152
0

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

Community
  • 1
  • 1
Professor Tom
  • 352
  • 3
  • 16