| 1 | = OpenSpecimen HowTo Build from Source Code |
| 2 | |
| 3 | Tags: [[OpenSpecimen Summary]] [[HowTo]] |
| 4 | |
| 5 | This is the procedure for building the `war` file. The [[Gradle]] build script can also be used to deploy OpenSpecimen to a local instance, but that is not covered here. |
| 6 | |
| 7 | == Prerequisites |
| 8 | |
| 9 | - Java JDK v1.8 |
| 10 | - Gradle 2.0 |
| 11 | - git |
| 12 | - node.js 10+ |
| 13 | - npm |
| 14 | - bower - `npm install -g bower` |
| 15 | - grunt - `npm install -g grunt-cli` |
| 16 | - `$JAVA_HOME` set to the JDK directory |
| 17 | |
| 18 | === Gotchas |
| 19 | |
| 20 | 1. The first time I build OpenSpecimen using this method I had to upgrade node and npm before installing bower and grunt. |
| 21 | 2. Gradle could not find node because on Ubuntu it is called nodejs so I had to create a symbolic link `sudo ln -s nodejs node` in the directory `/usr/local/bin/`. |
| 22 | |
| 23 | |
| 24 | == Procedure |
| 25 | |
| 26 | 1. Download the source code from the [[https://github.com/krishagni/openspecimen.git|Open Specimen Github Repository]] - **Make sure to get the correct branch for the required version** |
| 27 | 2. Edit the `build.properties` file with the correct values. Here are the values for the university LAMP servers. The other values not in this list can be deleted: |
| 28 | {{{ |
| 29 | #!java |
| 30 | app_home = /local/openspecimen_{version_number}/app |
| 31 | app_data_dir = /local/openspecimen_{version_number}/app/osdata |
| 32 | datasource_jndi = java:/comp/env/jdbc/openspecimen |
| 33 | deployment_type = upgrade |
| 34 | database_type = mysql |
| 35 | show_sql = false |
| 36 | plugin_dir = /local/openspecimen_{version_number}/app/plugins |
| 37 | }}} |
| 38 | 3. `cd` into the `www` directory |
| 39 | 4. Run the command `npm install` |
| 40 | 5. Run the command `bower install` |
| 41 | 6. `cd ..` |
| 42 | 7. Run the command `gradle build` |
| 43 | |
| 44 | == Deploying to [[Tomcat]] |
| 45 | |
| 46 | 1. Copy the `war` file to the [[Tomcat]] `webapps` directory. |
| 47 | 2. Amend the file in the Tomcat directory `conf/context.xml` to set up the resource: |
| 48 | {{{ |
| 49 | #!xml |
| 50 | <Resource name="jdbc/openspecimen" auth="Container" type="javax.sql.DataSource" |
| 51 | maxActive="100" maxIdle="30" maxWait="10000" |
| 52 | username="{database_username}" password="{database_password}" driverClassName="com.mysql.jdbc.Driver" |
| 53 | url="jdbc:mysql://localhost:3306/openspecimen" |
| 54 | validationInterval="3600" |
| 55 | testOnBorrow="true" |
| 56 | validationQuery="Select 1 from dual" |
| 57 | /> |
| 58 | }}} |