Implement Java Pro-Code Projects
Prerequisites
Java SDK
A Java 8 SDK is needed to develop Java based pro-code projects.
Please download either the Oracle 8 JDK from https://www.oracle.com/technetwork/java/javaee/downloads/index.html or the Open JDK from https://openjdk.java.net/ and follow the installation instructions of the JDK.
Maven
Maven version >=3.6.1 is required to develop custom implementation Java based projects.
Please download and install maven from https://maven.apache.org.
Eclipse
You can develop Java based pro-code projects in the IDE of your choice.
We recommend using Eclipse in the latest version which can be downloaded from: https://www.eclipse.org/downloads/
Eclipse Plug-ins
We recommend installing the following Eclipse plug-ins and utilities
Download Dependencies
In order to build and run Java based pro-code projects, some Solution Envoy dependencies are required that come with many already configured tools.
Open the Solution Envoy dashboard (e.g. <http://myproject.apps.openshift.mycluster.cloud>
). Navigate to the Infrastructure tab, click and download all the dependencies listed under Maven Dependencies.
Install Dependencies
The downloaded dependencies must be installed in the local maven repository. Here is an example how the dependencies can be installed via maven.
mvn install:install-file -Dfile=cp-framework-sdk-autoconfiguration-2.1.18.jar -DpomFile=cp-framework-sdk-autoconfiguration-2.1.18.pom
mvn install:install-file -Dfile=cp-framework-sdk-parent-2.1.18.pom -DpomFile=cp-framework-sdk-parent-2.1.18.pom
Running/Building Projects
Create Pro-Code Projects
Open Solution Designer and create a new project by clicking on the Create button. Fill out the project-specific details but from the Type drop-down make sure to select Pro-Code Project and set Implementation Language to Java.
Clone Git Project to Local Machine
In order to build and run the project, the Git project should be cloned to the user's workspace. In order to checkout a Pro-Code Project open the project after creation, navigate to the General Information and copy the Git Repository URI.
Alter the URL and add the Git user so it looks like the following:
Before:
https://auto-devops-url/managed-solutions/SOLJAVA.git
After:
https://git@auto-devops-url/managed-solutions/SOLJAVA.git
Open a terminal and clone the project. You will be prompted for a password. Please use your personal access token as password:
git clone https://git@auto-devops-url/managed-solutions/SOLJAVA.git
Unit Tests for Pro-Code Projects
It's highly recommended to write unit tests for your Java projects. The unit tests will be executed during the project pipeline execution as part of the maven build.
By default, JUnit 5 is set as the test library in Spring Boot. If you want to use JUnit 4, you have to add the following dependency in pom.xml.
org.junit.vintage junit-vintage-engine test org.hamcrest hamcrest-core