Speeding up new projects with Maven Archetype

Alex Nasarre
Strands Tech Corner
4 min readJan 14, 2019
Photo by HBO

One of the main challenges our Professional Services team faces is to adapt Strands products to our end clients’ needs.

For this purpose, our Technology team develops and provides us with the latest stable version of our products and we make the necessary changes to fit the client’s requirements. These requirements are both functional and architectural.

Detecting improvements

After carrying out this process a few more times than we’d like to admit, it became clear that it was quite repetitive, and that we were doing it manually for the most part. Setting up a new project for a client could take up to a day, and we sometimes missed a dependency or added something we didn’t need, only to discover this a few days later. To improve this process, we decided to automate it in a way that it would:

  1. Reduce the time needed to setup a client’s project
  2. Simplify the creation of new projects for clients, being able to parametrize:
  • Project name, following a standard
  • Modules to implement
  • Database connection details
  • Infrastructure (database vendor, application server, etc)

3. Standardize project creation

  • Naming conventions
  • Inherit all coding standards and core dependencies from Strands main products

Maven Archetype to the rescue

After considering several options, we decided to proceed with Maven Archetype, a system which allowed us to define a template for every new client project. This archetype would be developed as a module of our Strands Parent project with the following structure:

Image 1: artifact structure

Setting it up in Strands Finance

Firstly, we configured the pom on the archetype-module directory. This needed to have the packaging type “maven-archetype” and has our core backend parent, com.strands.finance, as a parent.

Image 2: pom.xml file basics

We then configured the archetype-metadata.xml file, which contains important details in three sections:

  • RequiredProperties: We defined some global variables here that helps us configuring the each project with different customizations. Most of the variables here will be asked to the user when creating the project, and others will be generated based on them.
  • FileSets: Here, we determined what file extensions were going to be exported to the project, managed the encoding, and ascertained whether we needed to inject the variables or not.
  • Modules: These are the modules that were going to be created for the project. These modules can be parametrized to adapt their names to the client’s codename.
Image 3: archetype-metadata.xml file

Results

On executing the archetype, we are asked a few questions about the project we want to generate. These fill the variables we previously defined in archetype-metadata.xml and works like a wizard, allowing us to define:

  1. Product to implement (PFM, BFM, etc)
  2. Module providers (Strands Invoicing, external invoicing, etc)
  3. Database providers (Oracle, PostgreSQL, etc)
  4. Database connection details
  5. Naming conventions
  • Client’s name as a three-character abbreviation (XYZ)
  • Project and module names (xyz-pfm-budgets)

We also parametrize and included all the necessary resources (directories and files) in the archetype-resources directory to have access to:

  • Basic directories and files from our backend core
  • API Documentation based on Swagger
  • DockerFiles to be able to run the project as a docker image
  • Autogeneration of JenkinsFile to create the necessary CI jobs
  • .gitignore file
  • Autogeneration of README files including all necessary information to work on the new project.
Image 4: archetype wizard example

Next steps

Once this implementation had been carried out with the core module, the outcome was very positive. For that reason, we are currently working on preparing all the other modules so they follow the same procedure.

On the one hand, this will allow the technical team constant access to the latest version, to be able to develop customized solutions for specific customers without delay. On the other hand, Strands will be able to offer the ‘out-of-the-box’ version of a product, adapted to suit individual customer needs much more quickly.

For the above scenario to be possible, improving both time-to-market and time-to-delivery, the following options are being taken into consideration:

Improve the existing archetype to increase the number of capabilities and add-ons, offer the possibility of selecting the chosen application server to automatically generate the necessary configuration.

Extend the implementation of archetypes for all other Strands’ products (realtime, ui) etc.

This new project has been improved greatly since it began, and we are happy with the decision we made to pursue this idea, so much so that we are now extending this to other projects and teams within Strands. We have continued to work on the archetype project itself, adding new functionalities and options, and offering more control over the application server and database configurations.

--

--