How to create new SNAP modules using SNAP maven archetypes

Requirements

  • build SNAP from sources.

  • build the SNAP Archetypes source code

Clone the SNAP Archetypes source code from GIT into a local directory referred to a ${snap-archetypes} from here on:

1 2 cd ${snap-archetypes} git clone https://github.com/senbox-org/snap-archetypes.git

Build SNAP Archetypes:

1 mvn clean install

Setting up the IntelliJ IDEA

  1. Create a new project with the option "Project from existing sources", by choosing the pom.xml from ${snap-archetypes}

    create project screenshot
  2. Set the used JDK for the project.

    select the JDK for new pro

Usage of SNAP Archetypes

After making sure that snap-archetypes are successfully build, these can be used when creating new SNAP modules.

Assuming that snap-engine, snap-desktop and the preferred toolboxes (s1tbx, s2tbx, s3tbx) are locally cloned and build under ${snap} directory, one can chose a project (among the above enumerated) where a new module using a SNAP archetypes will be added.

From IntelliJ, being positioned on the parent project where a new module will be added, the steps are the following:

  • File -> New Module

    new module screenshot
  • check the "Create from Archetype" checkbox

    check create from archetype screenshot
  • first register the needed SNAP archetype by Add Archetype button (make sure to write here the details that are in the specific pom.xml of the chosen achetype (found under ${snap-archetypes})

    add archetype screenshot
  • select the newly added archetype from the list, as the archetype to be used for the new module

    select archetype for new module screenshot
  • enter the artifactId for the new module

    enter the artifact id screenshot
  • confirm the properties for the new module (here extra properties can be added when needed)

    confirm the properties of new module screenshot
  • finish the setup

    finish the setup screenshot
  • check the log of Intelij IDEA to check if the new module was successfully created.

    expected log output for successfully new module creation screenshot
  • build the newly created module to check if correctly integrated with parent module

    expected log for build of new module screenshot

Note

If something goes wrong (e.g. wrong details provided when adding an archetype), these can be found under:

1 %userdir%\.IdeaIC[version]\system\Maven\Indices\UserArchetypes.xml

This is an XML file that can be easily modified. For deleting a wrong registered archetype, just delete the corresponding element, inside list.

Further read How to run and debug SNAP from an IDE.