Development tips

Tomcat application deployment

For faster development we recommend not deploying OpenKM.war directly; instead, create in $TOMCAT_HOME/webapps a folder alias of target/openkm:

To create symbolic links in Windows, use the "junction.exe" application.

More information at http://technet.microsoft.com/en-us/sysinternals/bb896768.

Compile only the GWT frontend module

To compile GWT modules individually execute the command:

$ mvn gwt:compile -Dgwt.module=com.openkm.frontend.Main

Configure GWT build from Eclipse

Go to "Run configurations", choose "Maven build" and click the "right mouse button" to "add" a new Maven build.

Compile only one GWT frontend permutation

GWT, by default, compiles six permutations, each for different browsers. Each permutation consumes a lot of hardware resources (RAM and CPUs).

For faster development and shorter compilation time, enable only a single permutation.

Decreasing the number of enabled permutations will decrease the total compilation time needed.

You can also declare several permutations at the same time; for example, to enable Firefox and Chrome you can use:

<set-property name="user.agent" value="gecko1_8, safari"/>

Enable only Firefox permutation

Edit the main.gwt.xml file in the OpenKM project:

<!-- Compile for Firefox only -->
<set-property name="user.agent" value="gecko1_8"/>

Enable only Chrome permutation

Edit the main.gwt.xml file in the OpenKM project:

<!-- Compile for Firefox only -->
<set-property name="user.agent" value="safari"/>

Enable only IE permutation

Edit the main.gwt.xml file in the OpenKM project:

<!-- Compile for Firefox only -->
<set-property name="user.agent" value="ie8"/>

Depending on the GWT version, ie6, ie9, and ie10 values are also allowed.

More information at UserAgent.gwt.xml.

Configure the number of CPUs to be used for compiling the GWT frontend

Increasing the number of CPUs used when compiling GWT will decrease the total compilation time needed.

The GWT compilation process can use more than one CPU. You can set the number of CPUs to be used with "localWorkers" parameter.

Important: depending on the number of cores and available memory, decrease the number of GWT instances compiled at the same time by lowering localWorkers; otherwise your computer may hang.

Edit the pom.xml project file.

<plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>${gwt.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <!-- <goal>generateAsync</goal> -->
              <!-- <goal>test</goal> -->
            </goals>
          </execution>
        </executions>
        <configuration>
          <runTarget>com.openkm.frontend.Main/index.html</runTarget>
          <modules>
            <module>com.openkm.frontend.Main</module>
          </modules>
          <localWorkers>4</localWorkers>
        </configuration>
      </plugin>

If you're making a lot of changes in the OpenKM UI (GWT), we recommend disabling the "compile" directive.

Deploying script sample

You can use a deployment script:

#!/bin/bash
# @author: Kenneth Walter
 
#Cleans and re-compiles the source files
mvn -Dmaven.test.skip=true clean gwt:compile install $*
 
#Set the TARGET_DIRECTORY to the path of your tomcat installation
TARGET_DIRECTORY=~/Downloads/tomcat-8.5.69/
FILE_TO_MOVE=target/openkm.war
#This will only attempt to replace the existing WAR if the new WAR exists
if [ -f $FILE_TO_MOVE ]
then
   echo 'Deploying WAR to Tomcat Directory'
   cp -v $FILE_TO_MOVE $TARGET_DIRECTORY/webapps/.
   echo 'Done'
fi