How to create an Eclipse/Sloeber IDE project template

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:

  • .project
  • .settings/*
  • Run configurations (among other things): .cproject

Within the workspace directory:

  • Debug configurations: .metadata\.plugins\org.eclipse.debug.core\.launches

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

  1. Make a copy in Windows Explorer (or just git clone a template like mine
  2. Rename the root folder to your new project name (no spaces)
  3. Open a text editor with directory-wide find/replace functionality such as VS Code.
  4. Enter the template project name and replace with your new project name.
  5. Open the project in Eclipse by choosing Menu > File > Open projects from filesystem.
  6. Rename launch configuration files slightly (to avoid interference with other projects and to make it easy to identify).
  7. Import Run configurations via Menu > File > Import…
  8. Build all configurations and test that debugging and unit testing still functions.
  9. Remove the .git folder (if exists) and initialise an empty git repository.

find replace project name Step 3: Find and Replace the project name

Import Launch Configurations Step 7: Import Launch Configurations