Java Components


Build Guide

The build of any component within an xpresso.ai solution is according to the Jenkins Build Pipeline defined for the solution. This, in turn, is governed by the order of stages specified in the Jenkinsfile configuration file, located in the xprbuild folder for each component.

Stages in Jenkins Build Pipeline for Java Components

S. No.

Stage

Description

Steps

Checkout

checks out source code from the code repository and cleans the target folder

Checks out source code from the code repository

Prepare

prepares the build environment

  1. Calls make prepare using the Makefile located at <component root>/xprbuild - this calls <component root>/xprbuild/system/linux/pre_build.sh

  1. Calls make clobber using the Makefile located at <component root>/xprbuild - this calls ‘mvn clean’ and removes the ‘target’ folder if present

Build

Builds the Docker image for the component

Calls make build using the Makefile located at <component root>/xprbuild - this calls <component root>/xprbuild/ docker/build.sh

Test

Tests the new Docker image

Calls make unittest using the Makefile located at <component root>/xprbuild - this calls ‘mvn test’

Archiving Artifact

Archives artifacts generated by build, to enable developers to examine them

Calls a custom stage to store the artifacts in the ‘target’ folder

Docker Push

Pushes the new Docker image into the xpresso.ai Docker registry

Calls make dockerpush using the Makefile located at <component root>/xprbuild - this pushes the Docker image into the Docker registry

Repository Folder Structure

The folder structure for any Java component (Job/Service) is described in detail below:


Folder

File

Description

Developer Tips

/

CHANGELOG.md

Stores a log of changes to the component

Document changes to the component in this file

/

Makefile

Makes the solution

Changes will usually not be required to this file. However, it is a good idea to review the actions being performed on various Make rules, especially clobber, * prepare*, ** build and **dockerpush

/

README.md

Describes the component

Write a brief description of the component and the source files required by it in this file

/

VERSION

Stores the component version number

Write the component version number here

/

pom.xml

Stores the POM for building the component using Maven

Replace this file with the pom.xml file for the component

/data

s ample_data.txt

Dummy data file

Store all the data files required for the component in the /data folder (with sub-folders as required)

/lib

ews-mail.jar

Dummy jar file representing library required by component

Store all library files required by the component in this folder

/src

so urce-code.json

Dummy source code

Store all source code for the component in this folder in this folder (with sub-folders as required)

/xprbuild

Jenkinsfile

Stores the actions performed by the Jenkins pipeline for the component

See Build Guide for details. Review, but do not make changes to this file. Make changes to scripts being called by the pipeline if required

/x prbuild/docker

Dockerfile

Stores commands processed when building the Docker image

Change this file as per the component requirements. See Docker documentation details. Note that for Java “service” components, Tomcat is the default web server supported. To change this to any other web server, the Dockerfile will have to be changed appropriately.

/x prbuild/docker

build.sh

Called during the Build stages of the Jenkins Build Pipeline

Change as per component requirements

/x prbuild/docker

pre-build.sh


Installs various components required by the build. Change as per component requirements

/x prbuild/docker

test.sh



/x prbuild/system

Makefile

Unused


/xprbuil d/system/linux

build.sh

Called during the **Bu ild **stages of the Jenkins Build Pipeline

Calls “mvn clean package”. Change as per component requirements

/xprbuil d/system/linux

post-build.sh

Called during the **Bu ild **stages of the Jenkins Build Pipeline

Empty file. Change as per component requirements (perform any post-build cleanup here)

/xprbuil d/system/linux

pre-build.sh

Called during the Prep are and **Bu ild **stages of the Jenkins Build Pipeline

Sets up JDK and Maven by default (scripts for setting up Node and Tomcat also included). Change as per component requirements

/xprbuil d/system/linux

run.sh

Unused


/xprbuil d/system/linux

test.sh

Unused


/xprbuild/ system/windows

Makefile

Unused

May be required in future to support Windows deployment

/xprbuild/ system/windows

build.bat

Unused

May be required in future to support Windows deployment

/xprbuild/ system/windows

post-build.bat

Unused

May be required in future to support Windows deployment

/xprbuild/ system/windows

pre-build.bat

Unused

May be required in future to support Windows deployment

/xprbuild/ system/windows

run.bat

Unused

May be required in future to support Windows deployment

/xprbuild/ system/windows

test.bat

Unused

May be required in future to support Windows deployment