Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Maven

...

Properties (Build)

Any application can use Maven properties in a pom.xml file or in any resource that is being processed by the Maven Resource plugin’s filtering features.

...

A complete reference for the POM structure is available at http://maven.apache.org/ref/3.0.3/maven-model/maven.html. Anything in a Maven POM can be referenced with a property. 

Maven Settings Properties (ONAP Oparent settings.xml)

These are the  properties in the Maven Local Settings file which is usually stored in ~/.m2/settings.xml. This file contains user-specific configuration such as the location of the local repository and any servers, profiles, and mirrors configured by a specific user. These properties should not be redefined in CPS, unless we need to override the values. Like:

...

Note: CPS has redefined these properties with almost the same values. 

Environment Variable Properties

...

While they are available, you should always use the Java System properties wherever available. This would help in creating a more portable build adhering to the Write-Once-Run-Anywhere (WORA) promise of the Java platform.CPS uses very few environment variables which are defined from the OOM(Helm) charts and they are being used in Application.yml. Eg :

  • CPS_USERNAME : Username for basic authorization of CPS Rest APIs which is set to cpsuser.
  • CPS_PASSWORD : Password for cps Rest APIs which is auto generated.
  • DB_USERNAME : Username for the postgres DB which is set to cps.
  • DB_PASSWORD : Username for the postgres DB which is auto generated.

Any additional environment variable can be configured during deployment of the application by using 'helm' Spring profile in the application-helm.yml file.

Java System Properties

Maven exposes all properties from java.lang.System. Anything you can retrieve from System.getProperty() can be referenced as a Maven property and could be used anywhere in the pom.xml. Since these properties would be mostly related to the entire application, it is suggested to define them in parent pom.xml.

Eg : java.version is used in CPS.

User-defined Properties (CPS)

In addition to the implicit properties provided by the POM, Maven Settings, environment variables, and the Java System properties, you have the ability to define your own arbitrary properties. Properties can be defined in a POM or in a Profile. Period character should be used as a separator in property names. 

  • Common dependencies to be used by the entire application should be defined as properties in cps-dependencies pom.xml
    • Eg: groovy.version, spock-spring.version
  • Other common properties to be used by the entire application should be defined as properties in cps-parent pom.xml. Eg: 
    • nexus.public.repo : the nexus public repo used for test containers
    • nexus.repository: the docker image push repository
    • base.image: the base image used for dockerizing CPS using jib plugin spring-boot-maven-plugin.version, java.version, minimum-coverage, base.image
  • Each module can specify the properties which is exclusively used by the module. In case a module needs to override a property defined in the cps-parent pom.xml, that could also be done in the properties section. 
  • In case a property is only used in a particular profile, then it is advised to define the property inside the profile. In case a profile needs to override a property defined in the pom, that could also be done in the profile's properties section. CPS has different profiles defined namely cps-docker, ncmp-docker and cps-ncmp-docker for building different docker images. Each profile could define their own image.name property to be used for deriving their own docker image name.
    • Eg : image.name is set to cps-service in cps-docker profile
    • image.name is set to cps-and-ncmp in cps-ncmp-docker profile

These  properties can also be overridden in the CI-CD jobs.

CPS Environment Variables (Runtime)

CPS uses very few environment variables which are defined from the OOM(Helm) charts and they are being used in Application.yml. Eg :

  • CPS_USERNAME : Username for basic authorization of CPS Rest APIs which is set to cpsuser.
  • CPS_PASSWORD : Password for cps Rest APIs which is auto generated.
  • DB_USERNAME : Username for the postgres DB which is set to cps.
  • DB_PASSWORD : Username for the postgres DB which is auto generated.

Any additional environment variable can be configured during deployment of the application by using 'helm' Spring profile in the application-helm.yml file.