OpenGTS Web Applications (war)

A war file is a complete web application and contains more than Java *.class and *.jar files. The creation of *.war files adds resources to deploy a web application. The dependency graph can cause confusion, if you're not used to look at an ant build process. Another way to approach the process is to execute the targets one by one and look at the ant outputs on the console and the appearance of the new files.

ant build output

In order to do this you should open the console and

run C:\prox\OpenGTS_2.4.3>ant -buildfile buildLite.xml all to make sure everything works.

You should be aware that the initial target clean deletes the output folder: 

<target name="clean" 
    <delete dir="${build.home}"/>

And prepare creates two new folders as the starting point 

<target name="prepare" 
    <mkdir dir="${build.home}"/>
    <mkdir dir="${build.lib}"/>

which can be seen in the output:

    [mkdir] Created dir: C:\prox\OpenGTS_2.4.1\build
    [mkdir] Created dir: C:\prox\OpenGTS_2.4.1\build\lib

Note that ant is smart enough to check existing files in the output to validate, if a compilation is necessary.

If you reverse engineer the execution order of the targets

<target name="all" depends="... compile
<target name="compile" depends="compile.base ..." 
<target name="compile.base" depends="gtsutils ..." 
<target name="gtsutils" depends="gtsutils.jar"/>

and run ant -buildfile buildLite.xml gtsutils.compile for the first time 
the output reveals the compilation process:

    [javac] Compiling 58 source files to C:\prox\OpenGTS_2.4.3\build

according to the xml file:

+56 <include name="org/opengts/util/**/*.java"/>
   0 <exclude name="org/opengts/util/"/>     (not present in standard version)
 - 1 <exclude name="org/opengts/util/"/>
+ 3 <include name="org/opengts/google/**/*.java"/>
=58 source files

Finally you can look at the fresh build folder to find only the three folders (or packages)


After this you can create the gtsutils.jar with ant -buildfile buildLite.xml gtsutils

      [jar] Building jar: C:\prox\OpenGTS_2.4.3\build\lib\gtsutils.jar

Comparing the timestamps of the *.class files to the *.jar file reveals that ant is smart enough not to repeat dependent targets, if they were executed earlier. Ant also takes care of creating the gtsutils.jar\META-INF\MANIFEST.MF file. An finally it should be noted that the process has also copied 14 *.properties files into the jar.

building the war files

After reverse engineering the process

from Java sources C:\prox\OpenGTS_2.4.3\src\org
   to Class files C:\prox\OpenGTS_2.4.3\build\org
   to Jar files C:\prox\OpenGTS_2.4.3\build\lib 

we can approach the building of the web archives - the highest level packages, which also add non Java sources to complete the web application.

One interesting observation is that the servlets (war files) do not depend on the servers:

<target name="compile.base" depends="gtsutils,gtsdb,tools" 
<target name="compile.servers" depends="compile.base,tk10x,template" 
<target name="compile.servlets" depends="compile.base,track,events,gc101,gprmc" 

building track.war

track.war is the biggest web application in the OpenGTS distribution.
It provides full access via Webbrowser to the GTS database.
The building process is pretty straight forward.

For the target track.prepare a target directory is created:

 <property name="build.track" value="${build.home}/track"/>

then subdirectories are created and a bunch of files are copied into it:

<!-- create required directories -->
<!-- .conf files -->
<!-- .xml files -->
<!-- copy "private/private*" files -->
<!-- copy images -->
<!-- copy other non-Java files (js, css, png, etc) -->

Note that the compilation step is restricted to the org/opengts/war/track/ directory ...

<!-- Target: track.compile -->
<delete file="${build.home}/track.war"/>
<!-- compile track servlet -->
<javac srcdir="${src.gts}"
   <include name="org/opengts/war/track/**/*.java"/>

The four org.opengts.war.track... packages depend on each other

Nevertheless they can not compile or run without additional packages of the Tracking System. In order to achieve an isolated track web application the previously compiled jars are simply moved into the war. The Ant program does all the work with a few simple directives:

<target name="track.war" depends="track.prepare" 
    <delete file="${build.home}/track.war"/>
    <!-- create track.war file -->
    <war warfile="${build.home}/track.war" webxml="${build.track}/WEB-INF/web.xml">
        <classes dir="${build.track}/WEB-INF/classes">
        <lib dir="${build.lib}">
       <fileset dir="${build.track}">

The point in applying ant is that all dependent compilations are executed to create an up to date web archive and the move the compiled classes and jars into this archive. Finally the resulting track.war file can be deployed to any Tomcat server without depending on any other binary files or any files in %GTS_HOME%. The dependency graph reveals dependencies to plain Java executed in a Java Virtual Machine (gtsutils and gtsdb) and dependencies to servlet APIs executed by a servlet container (wartools):




Now we have gone through the various steps of creating the complete GTS with ant. Yet there is still no need to go into the Java source, since OpenGTS offers a load of possibilities to configure the existing system without modifying Java. This external view should be well understood before starting any programming to avoid conflicts or reinventing existing mechanics of the system. - And even the process of investigating OpenGTS configurations can be experienced without using an IDE by using an ant target that is not part of the ant all compilation, yet depending on various steps. The track.deploy target offers a great setup to interactively test different configurations on the next page.


 « OpenGTS Lite configuration »