While exploring Android development, I've wanted to keep my application and test projects together in a single repository. It's (hopefully) obvious that you'd want to track changes to your application code and test code alongside each other so they're always in sync. But for some reason, adding these two separate projects to a single repository is not intuitive to do from inside Eclipse, at least while using the MercurialEclipse plugin.
There is probably a better way to do this, but here's how I've gotten things working. It relies on a combination of MercurialEclipse and an external-from-Eclipse tool. I recommend the excellent TortoiseHg.
Finally, these steps were outlined pretty quickly and I haven't tested all scenarios. Your mileage may vary.
Finally, these steps were outlined pretty quickly and I haven't tested all scenarios. Your mileage may vary.
Creating a new repository and adding projects:
- If needed, create a new workspace in Eclipse.
- Create a new directory underneath your workspace to contain your repository, and init a new repository there.
- Open the workspace in Eclipse.
- Add one or more new projects. You can try unchecking "Use default location" and adding them under the repository root, but it still always adds them to my workspace root for me.
- Close Eclipse.
- Manually move the project folder inside the repository folder.
- Commit the project's contents to your repository.
- Open the workspace in Eclipse.
- There will still be an entry in your Package Explorer for the project that you moved, which references the old project location. Delete it (right-click -> Delete). We'll re-add it momentarily.
- File -> Import -> Mercurial -> Projects from Local Mercurial Repository
- Browse to the root of your repository directory. Eclipse should detect the projects inside your repository directory, including any that might already be listed in your Package Explorer.
- Check only the project(s) you just created, and click Finish.
Importing projects from an existing repository:
- If you haven't done so yet, clone the repository to a directory inside your workspace using an external tool.
- Open the workspace in Eclipse.
- File -> Import -> Mercurial -> Projects from Local Mercurial Repository
- Browse to the root of your repository directory. Eclipse should detect the projects inside your repository directory.
- Select the project(s) you want, and click Finish.
Reference links:
- Here's an article explaining how to add projects inside a "repository" folder inside the workspace.
- And here's the StackOverflow answer that made the whole thing click.
No comments:
Post a Comment