# Adding New Modules

So that it can be more easily integrated to OpenSensorHub build process, we advise you to package each OSH module (or set of related modules) as a separate Gradle Project.

This guide assumes the following prerequisites:

  • You are using Eclipse Neon (or later) with the BuildShip plugin (version 2 or later)
  • You have cloned at least the osh-core and osh-sensors repositories and correctly imported them into Eclipse.

If you haven't done this initial setup, first follow the Developer's Guide before you create the new module project with the steps below:

# Get the module template project

  • Download the Template Project (opens new window)
  • Unzip it inside one of the repository of your choice (e.g. osh-sensors)
  • Change the folder name. By convention we use names such as sensorhub-{moduletype}-{modulename} (e.g. sensorhub-driver-axis for the Axis camera driver)

Note that this template can only be used within an existing repository because it relies on the parent Gradle project residing at the root of the repository

# Import into Eclipse

  • Right-click on the repository folder in Eclipse (e.g. osh-sensors) or one of its subfolder or subproject
  • Select Gradle > Refresh Gradle Project. This will import the new module into your workspace

Note that if you use Eclipse "Working Sets", the project is usually added to the default working set called "Other Projects" so you'll have to move it to the desired working set manually.

# Modify the Gradle build file

  • Set the description and details fields to something meaningful for your module
  • Also set the OSGi manifest and Maven POM entries so that your package is properly documented
  • Add other dependencies if needed by your module (see Gradle documentation (opens new window) to learn how to do this)
  • If you added new dependencies, select Gradle > Refresh Gradle Project from the project context menu to update Eclipse configuration with the new depended-on libraries.

You're all set!! You can now start writing the code for your module by building to one of OSH Core APIs.

Last Updated: 12/16/2020, 5:46:35 PM