Setting up Eclipse projects for tasks such as unit testing and hardware debugging is very time consuming due to the fact there are a million different possible ways to configure a project. Online tutorials get out of date quickly due to software updates in libaries, compilers, builds tools, Arduino board platforms and so on.
I created a Sloeber project template which, so far, includes all the configuration required to enable interactive local debugging and unit testing of C++ microcontroller firmwares from within Eclipse Sloeber.
You can download the project template from Github or use the clone command below.
git clone https://github.com/danobot/sloeber-project-template.git
To backup a project’s configuration and all its settings available in the UI, there are a few important files and directories that should be checked into version control and backed up.
Within the project directory:
- Run configurations (among other things):
Within the workspace directory:
- Debug configurations:
Duplicating an Eclipse project template
Open the above files and hard replace the template project name with the new project name you want to use. Launch configurations are stored in separate files in the project root. Copy and rename the template debug configurations and replace the project name in their title. Note that these files are normally stored in the workspace. Luckily, Eclipse is smart enough to recognise
.launch files and import them for you. If not, there are steps below.
How to duplicate an Eclipse Project Template correctly
- Make a copy in Windows Explorer (or just
git clonea template like mine
- Rename the root folder to your new project name (no spaces)
- Open a text editor with directory-wide find/replace functionality such as VS Code.
- Enter the template project name and replace with your new project name.
- Open the project in Eclipse by choosing Menu > File > Open projects from filesystem.
- Rename launch configuration files slightly (to avoid interference with other projects and to make it easy to identify).
- Import Run configurations via Menu > File > Import…
- Build all configurations and test that debugging and unit testing still functions.
- Remove the .git folder (if exists) and initialise an empty git repository.
Step 3: Find and Replace the project name
Step 7: Import Launch Configurations