This document describes steps to build OpenSpecimen from source code and to set up a development environment. This guide is intended for developers or technical IT staff. Following are high-level steps of building OpenSpecimen code:
- Install/Setup pre-requisite software. These pre-requisites can be downloaded from http://www.openspecimen.org/prerequisites/
- Use the below command to download the source code:
$ git clone --depth 10 https://github.com/krishagni/openspecimen.git
- Above command will checkout the master branch or unreleased version of code. If you wish to build source code of a specific release then use below command before proceeding to build. The list of available release version tags can be view here: https://github.com/krishagni/openspecimen/releases
$ git checkout <release-version-tag>
$ git checkout v6.1.RC7 # example to checkout source code of OpenSpecimen
Do all the pre-requisites setup before deploying WAR file.
gradle to build and deploy the application.
Following table lists pre-requisites and their supported versions.
The recommended memory requirement for the OpenSpecimen app is 2GB. To configure Tomcat follow /wiki/spaces/CAT/pages/83562193
Note: For the database, you can choose between Oracle or MySQL.
You'll also need to place an appropriate connector jar for MySQL/Oracle under the 'lib' directory in the tomcat server.
Following table lists and describes environment variables
The absolute path of the directory where JDK is installed. For example
Please refer to the following variables used throughout the document.
Directory where OpenSpecimen source code is checked-out. For example,
Directory where JDK is installed. For example,
The deployment process involves some database operations which require specific privileges set for the database user. Use the below command to create a database. Refer to Database Configuration and make sure these privileges are assigned before the deployment process.
create database <database-name>
<database-name>: name of the database to be used for storing OS data
create user <username> identified by <password>
<username>, <password> has to be replaced with database username and password
Configure Tomcat context.xml
Note: This section is applicable for the fresh install and upgrading OpenSpecimen from older versions before v5.0.
For Linux, configure the PID.txt path using the instructions here: How to run Tomcat using PID on Linux?
Refer to the attached context.xml for reference.
Configure the data source name in $TOMCAT_HOME/conf/context.xml using the snippet below.
<Resource name="jdbc/openspecimen" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
testOnBorrow="true" validationQuery="select 1 from dual" />
|Driver class name||com.mysql.jdbc.Driver|
|DB URL|| jdbc:mysql://<db_host>:<db_port>/<db_name>||jdbc:oracle:thin:@<db_host>:<db_port>:<dbname>|
Add below XML fragment below
<Resource> tag in $TOMCAT_HOME/conf/context.xml
Note: The word "openspecimen" above could be different based on your configuration. E.g. "os-test", "os-prod" etc.
Note: Please make sure data & plugin directory are present at the specified path.
This field is useful for deploying multiple OpenSpecimen instances on the same Tomcat server. E.g. You can use "os-test" and "os-prod".
|Typically this is "openspecimen".|
|tomcat.dir||The absolute path to the Tomcat directory|
Absolute path to OpenSpecimen data directory.
Create a folder in parallel to 'tomcat.dir' with the name "OpenSpecimen/data"
The folder where the OpenSpecimen logs should be created
If left empty logs are created in "app.data_dir/logs"
|datasource.jndi||Name of datasource configured in "context.xml"||Usually, it is "jdbc/openspecimen".|
"fresh": If your database schema is created by OpenSpecimen from scratch.
"Upgrade": if your database schema is upgraded from a caTissue database.
Note: The name is a bit misleading, we will fix this in v5.2.
|"fresh" or "upgrade"|
|database.type||MySQL or Oracle|
"mysql" or "oracle"
Absolute path to the plugin directory.
Create a folder in parallel to 'tomcat.dir' with the name "OpenSpecimen/plugins"
|Property Name||Description||Default Value||Allowed Values|
The absolute path of the directory where the Tomcat server is extracted and installed.
- Make sure all the above database and Tomcat configuration are done properly.
- Copy the openspecimen.properties from downloaded location to $TOMCAT_HOME/conf directory.
- Before starting deploy make sure no Tomcat process is running.
Steps to deploy
The OpenSpecimen build system uses Gradle to manage code compilation, building web application archives, and deploying the application.
- Open command terminal
- Change to the directory where OpenSpecimen source code is checked-out
- Setup npm & bower dependencies.
- Change directory to root directory of source code.
- Use the following command to build and deploy OpenSpecimen into the app_home directory (Tomcat or JBoss server).
- To only compile Java source files use the following command
- To build OpenSpecimen web app archive without deploying use following command
Once "gradle deploy" is ran successfully, start Tomcat and monitor the log files.
Start and Shut Down the Application Server
Setup OpenSpecimen project in Eclipse or Intellij
OpenSpecimen creates project and classpath files for Eclipse and Intellij IDE. Using that created project file, it is very easy to import OS source code into Eclipse and Intellij.
To create the project setting and classpath file, follow the below steps
- Open command terminal
- Change to directory to root directory i.e
Run below commands for your IDE
For Eclipse :
gradle eclipseThis command creates the
.project, .classpath files and
.settings folder which is essential for project to be recognized as eclipse project.
For Intellij :
gradle ideaThis command create
openspecimen.iml, openspecimen.ipr, openspecimen.iws files which are essential for project to be recognized as Intellij project.
Now import the project into IDE using import from existing sources.
- Open File -> Import -> Existing Projects into Workspace
- Select the root directory of our project (i.e openspecimen). Project will get imported successfully
- Open File -> Open and select the root folder of our project. (i.e openspecimen)
- Click on 'ok' on the next dialog. The project will get imported successfully.