Introduction
------------

This README file contains instructions to build the Intel OPA Fabric Manager
GUI artifacts from source. However, you should be aware that the FM GUI jar
distributed by Intel is signed but this build process does not sign the
generated jar and a CA certificate is not distributed with the source.
Distributing the generated jar will result in user machines not being able to
verify the origin of the jar file.

Source Directory Structure
--------------------------

Architecture
The Fabric Manager GUI has a component-based architecture. In this section, the
main components are briefly described, what their function is, and how they can
be found in the source directory structure.

FE Adapter
The FE Adapter is the application interface to Fabric Management (FM) functions
through a Fabric Executive (FE). Its function is to submit FM commands to a FE
and parse their responses into object representations that can be processed by
the application. The package for this component is:

com.intel.stl.fecdriver

Data Manager
The Database Manager is the component in charge of storing configuration 
information as well caching Fabric Management data to a local database. The
packages applicable to this component are:

com.intel.stl.datamanager - interface to application
com.intel.stl.dbengine - interface to SQL engine

User Interface APIs
The User Interface APIs component provides all services available to a UI
component to display Fabric Management data. These services are grouped by
function but in general they are group under the following package:

com.intel.stl.api

User Interface
The User Interface component is the graphical implementation of the Fabric
Manager GUI. It includes all the widgets and logic to display Fabric Management
information. The main package for this component is:

com.intel.stl.ui

Self Maintained Third Party Libraries
The Fabric Manager GUI uses several 3rd party libraries developed by the open
source community.  Some of these libraries have been modified and are now
maintained by Intel.  The source code for these libraries can be found at:

/forked3rdPartyLib


Build Requirements
------------------

Internet access

The Fabric Manager GUI build requires Internet access to download its external
dependencies.

Java Development Kit

The Fabric Manager GUI build requires a Java Development Kit (JDK) 8. 
The JDK 8 binaries can be downloaded from Oracle's Java SE Downloads site:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

To install them, please follow the installation instructions for your target
development environment in the following Oracle guide:

https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html

In particular, please make sure that you have set environment variable
JAVA_HOME to the Java Development Kit installation location in your system.
This variable will be used by Gradle to locate the JDK to use.

Gradle

The Fabric Manager GUI build also requires Gradle 4.3.1. The Gradle tool is
available from the Gradle Build Tool Releases page:

https://www.gradle.org/releases/

Follow the installation instructions available in the Gradle Docs site:

https://docs.gradle.org/current/userguide/installation.html

Make sure that you configure your system environment according to the
installation instructions. In particular, please make sure that the Gradle 
'bin' folder has been added to your PATH environment variable. 

If you are developing behind a HTTP proxy, please follow the instructions at:

https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy

Building the Application
------------------------

After the build requirements have been met, the steps to generate the FM GUI
jar are straightforward:

Open a terminal/command window at the location where you unzipped the FM GUI
distribution source. Start the build process by entering the following command:

    gradle build

Wait for the successful completion of the build process:

    BUILD SUCCESSFUL in 2m 14s
    23 actionable tasks: 23 executed

To start the application, type the following command:

    gradle run

Building Third-party Libraries
------------------------------

Third-party libraries are already prebuilt and included in their respective
folders. To rebuild Intel maintained third-party libraries, please run the
following commands:

    cd forked3rdPartyLib
    gradle build

It will rebuild all the libraries in their respective folders. To rebuild
specific libraries, please use the following command

   gradle <lib1, lib2, ...>

where lib1, lib2 etc are the libraries names, such as jsch, jfreechart etc.

Building from Source RPM
------------------------

If you are using the Fabric Manager GUI's Source RPM to build the application's
binary RPM, first make sure that you meet the following requirements:
 1. Internet access to download external dependencies
 2. Package rpm-build is installed
 3. For RHEL: Package java-1.8.0-openjdk-devel is installed
    For SLES: Package java-1_8_0-openjdk-devel is installed
 4. Gradle 4.3.1 is installed and $GRADLE_HOME/bin is included in environment
    variable PATH

Then follow these steps to build the RPM:

 1. Install the Fabric Manager GUI's source RPM:

    rpm -ivf IntelOPA-FMGUI-<version>.src.rpm

    where <version> is the Fabric Manager GUI version in the form x.x.x.x-build

 2. For RHEL: from directory /root/rpmbuild, invoke rpmbuild using the provided spec:
    For SLES: from directory /usr/src/packages, invoke rpmbuild using the provided spec:

    rpmbuild -ba --target noarch SPECS/fmgui.spec

