Build cachedb-import

If you are using IRIS o Caché 2016.2 or higher, skip this step and go to cachedb-import setup.

Please, be aware the compilation is dependant on your Caché installation. So it must be done in a machine with a Caché database installed with developer tools. If you are doing it in a machine different to your production Caché installation, take care to use the same version to maximize compatibility. Also, you can copy files cachedb.jar and cachejdbc.jar from <cache_root>/dev to the lib folder on cachedb-import source code.

1. Install Git

1.1 Visit Git download page, and the latest git for Windows will start to download automatically

1.2 Install the downloaded exe file, selecting your preferred options

2. Get Gradle

2.1 Visit Gradle download page

2.2 Find the latest binary Gradle version, in this example we will get gradle-4.0.1-bin.zip, to your Downloads folder

2.3 Extracts the downloaded file to C:\sonarqube\gradle (or to C:\gradle if you are using it for a more generic purpose)

3. Define system variables

3.1 Open system properties dialog

3.2 Select Advanced System Settings

3.3 Click on Environment Variables... button

3.4 On the Envirnoment Variable dialog, click on system variables New... button

3.5 Define the GRADLE_HOME variable

3.6 Accept changes and edit Path variable to inlcude %GRADLE_HOME%\bin

3.7 Accept changes and close all dialogs

4. Check Gradle installation

4.1 A quick Gradle version check

> gradle -v
------------------------------------------------------------
Gradle 4.0.1
------------------------------------------------------------

Build time:   2017-07-07 14:02:41 UTC
Revision:     38e5dc0f772daecca1d2681885d3d85414eb6826

Groovy:       2.4.11
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_141 (Oracle Corporation 25.141-b15)
OS:           Windows Server 2016 10.0 amd64

5. Get cachedb-import

5.1 Clone the Github project

> git clone https://github.com/litesolutions/cachedb-import.git C:\sonarqube\repositories\cachedb-import

5.2 Copy files <cache_root>\dev\cachedb.jar and <cache_root>\dev\cachejdbc.jar to C:\sonarqube\repositories\cachedb-import\lib folder

Those files are only available on a developer installation of your Caché database

6. Build the project

6.1 Copy cachedb.jar and cachejdbc.jar from your Caché database installation into the lib directory of the cloned project

6.2 Build the jar with gradle. Remember you need JDK8 available on your PATH, and Gradle installed

> cd C:\sonarqube\repositories\cachedb-import
> gradlew.bat shadowJar
:compileJava
:processResources
:classes
:shadowJar

BUILD SUCCESSFUL

Total time: 13.906 secs

6.3 Check the library

> dir C:\sonarqube\repositories\cachedb-import\build\libs
 Volume in drive C has no label.
 Volume Serial Number is AAAA-AAAA

 Directory of C:\sonarqube\repositories\cachedb-import\build\libs

07/20/2017  05:17 PM    <DIR>          .
07/20/2017  05:17 PM    <DIR>          ..
07/20/2017  05:17 PM         2,413,783 cachedb-import.jar
               1 File(s)      2,413,783 bytes
               2 Dir(s)  55,216,111,616 bytes free

7. Prepare the executable environment

7.1 Copy the new library next to sonar path

> mkdir C:\sonarqube\cachedb-import
> copy C:\sonarqube\repositories\cachedb-import\build\libs\cachedb-import.jar C:\sonarqube\cachedb-import

7.2 Prepare the output path

> mkdir C:\sonarqube\cachedb-import\output

1. Install git

1.1 Use your linux distribution to install git

$ sudo apt-get install git

2. Install Gradle

2.1 Visit Gradle download page

2.2 Find the latest binary Gradle version, in this example we will get gradle-3.2.1-bin.zip via wget command to /tmp folder

$ wget -P /tmp https://services.gradle.org/distributions/gradle-3.2.1-bin.zip

2.3 Extracts the downloaded file to /opt/gradle

$ sudo mkdir /opt/gradle

$ sudo unzip /tmp/gradle-3.2.1-bin.zip -d /opt/gradle

$ ls -la /opt/gradle
total 12
drwxr-xr-x  3 root root 4096 Sep 30 12:28 .
drwxr-xr-x  6 root root 4096 Sep 30 12:28 ..
drwxr-xr-x 10 root root 4096 Jul 27  2015 gradle-3.2.1

2.4 For easy upgrades on future it is highly recommended to create the symbolic link

$ sudo ln -s /opt/gradle/gradle-3.2.1 /opt/gradle/default-gradle

2.5 Include Gradle in the PATH for all users

/etc/profile
JAVA_HOME=/opt/java/default-jdk
export JAVA_HOME

GRADLE_HOME=/opt/gradle/default-gradle
export GRADLE_HOME

if [ "`id -u`" -eq 0 ]; then
  PATH="$JAVA_HOME/bin:$GRADLE_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="$JAVA_HOME/bin:$GRADLE_HOME/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
. . .

After you change the /etc/profile file you need to logout and login again

3. Get cachedb-import

3.1 Clone the Github project

$ sudo git clone https://github.com/litesolutions/cachedb-import.git /opt/repositories/cachedb-import

3.2 Copy files <cache_root>/dev/cachedb.jar and <cache_root>/dev/cachejdbc.jar to /opt/repositories/cachedb-impor/lib folder

Those files are only available on a developer installation of your Caché database

4. Build the project

4.1 Copy cachedb.jar and cachejdbc.jar from your Caché database installation into the lib directory of the cloned project

4.2 Build the jar with gradle. Remember you need JDK8 available on your PATH, and Gradle installed

$ cd /opt/repositories/cachedb-import
$ sudo -E ./gradlew shadowJar

4.3 Check the library

$ ls -la /opt/repositories/cachedb-import/build/libs/
total 2368
drwxr-xr-x 2 root root    4096 Sep  2 13:15 .
drwxr-xr-x 7 root root    4096 Sep  2 13:15 ..
-rw-r--r-- 1 root root 2413323 Sep  2 13:15 cachedb-import.jar

5. Prepare the executable environment

5.1 Copy the new library next to sonar path

$ mkdir /opt/sonarqube/cachedb-import
$ cp /opt/repositories/cachedb-import/build/libs/cachedb-import.jar /opt/sonarqube/cachedb-import

5.2 Prepare the output path

$ mkdir /opt/sonarqube/cachedb-import/output
$ chown -R sonar:tomcat8 /opt/sonarqube/cachedb-import

5.3 Set proper permissions to the output path

$ chmod 774 /opt/sonarqube/cachedb-import/output