Skip to content

WTI Build Package Details

John Clevenger edited this page Apr 17, 2020 · 6 revisions

Overview

The Web Team Interface (WTI) project provides the ability for teams to access a PC² Server using a web browser. This wiki page describes the details of the two Ant files used to build and package the WTI project. The first, buildWTI.xml, compiles all of the components required for the project into a "build" directory. The second, packageWTI.xml, collects together the project components, along with supporting documentation, into a "distribution" directory in the form of two files: a .zip file and a .tar.gz.

More information on the WTI project can be found at the following wiki pages: Web Access and Web Team Interface Implementation.

Note: in the following descriptions, a term like ${name} refers to a property with value name defined at the top of (or within) either buildWTI.xml or packageWTI.xml.

buildWTI.xml

The buildWTI.xml Ant file has a default target of build. The build target depends on (executes) additional targets in the following order:

  • clean, which removes any previously-existing ${bin} and ${build.dir} directories .

  • init, which creates a timestamp for the build process.

  • compile, which creates a directory ${bin} and then compiles the Java source code in ${src} and ${websockets} into ${bin}.

  • mergelibs, which depends on a separate target unzip which unzips all of the .jar files in the WTI library (defined by ${liblocation}) into a temp directory in ${build.dir}. Once unzip is finished, mergelibs then invokes a locally-defined Ant task named merge-services which merges all the services defined in the extracted library .jars into a single set of services, stored in the same temp directory.

  • collect, which depends on a target ngbuild to build the WTI-UI Angular front-end code.

    • ngbuild depends on (executes) target npminstall, which executes an OS platform-specific command (Windows or Unix) to run the command npm install, which installs the Node modules required by the WTI-UI front-end code. Once npminstall is finished, ngbuild executes an OS platform-specific command to run npm run-script build, which builds the WTI-UI Angular front-end code in the directory ${frontendlocation}.
    • Once ngbuild is finished, collect does the following:
      • moves the contents of ${frontendlocation}/dist (which is where ngbuild puts the results of building the Angular front-end) to ${build.dir}/WebContent. This puts a directory WTI-UI in the WebContent folder.
      • copies the contents of WebContent/webapp (which is the Swagger API for the WTI-API project) to ${build.dir}/WebContent/webapp.
      • copies the file WebTeamInterface.ini to ${build.dir}.

The end result of the above build dependencies is a collection of the following things:

  • in ${bin}, the compiled Java class files for the WTI project;
  • in ${build.dir}, a directory WebContent containing both the front-end and back-end web application code (in sub-directories WTI-UI and webapp, respectively), plus a copy of the WebTeamInterface.ini file;
  • in ${build.dir}/temp, a collection of the (merged) services provided by the libraries referenced by the WTI project.

At this point, build creates a jar file containing all of the .class files from ${bin} plus all the (merged) library services in ${build.dir}/temp, and stores this jar file in ${build.dir}. The jar file includes a manifest specifying ${main-class} as the main class to be executed. The value of property ${main-class} as of this writing is config.JettyConfig, which is the entry point in the Java code which constructs and starts the Jetty web team server. (Thus, running the runnable jar file starts the Jetty web team server).

When build completes, it deletes the ${build.dir}/temp directory, leaving in ${build.dir} a complete self-contained build of the WTI project, consisting of:

  • the WebTeamInterface-x.y.jar file.
  • the WebTeamInterface.ini file.
  • the WebContent folder containing the front- and back-end services provide by the Web Team Interface.

Note that the above comprises (as of this writing) approximately 50MB. This includes the following:

  • 12.7MB of com libraries (Jackson, Google, and Sun)
  • 18.8MB of org libraries (aopalliance, apache, eclipse, glassfish, hamcrest, jvnet, mockito, objenesis, osgi, pescuma, and slf4j)
  • 7.9MB of net libraries (bytebuddy)
  • 6.8MB of PC2 code (the entire PC2 system is included, as a result of the merge step which merges all the libraries listed under WebContent/WEB-INF/lib, which includes pc2.jar).

It seems likely that at least some of the above could be removed in order to reduce the 50MB size of the project.

packageWTI.xml

The packageWTI.xml Ant file is invoked automatically by the PC² project build file pc2v9/build.xml (although it can also be invoked manually). The default target for packageWTI.xml is archives. The overall function of archives is to create both a .zip and a .tar.gz file, each containing the WTI "distribution", and store them in the ${staging.dist.dir} folder.

The archives target depends on (executes) two targets: stage_files followed by gitversion. stage_files in turn depends on targets cleandist, which removes any previous distribution files, and build, which is imported from buildWTI.xml (see above).

Once build has finished, stage_files copies the following files and folders to the ${staging.dist.dir} staging area:

  • the core WTI files (WebTeamInterface.jar, WebTeamInterface.ini, and the WebContent directory)
  • the scripts defined in the WTI project scripts directory
  • the WTI "User Guide" PDF

Once stage_files has completed, archives invokes the gitversion dependency, which executes git to obtain the number of the most recent relevant Git commit in the repository and assigns that value (or a default) to property ${repo.version}, which is used in assigning names to the output archive files (see below).

Once its stage_files and gitversion dependencies have been executed, archives constructs names for the output archive files and then makes an antcall to target gzip, which depends on (executes) target zip. The zip target creates a .zip file of all the files in the distribution staging area (${staging.dist.dir}), then creates MD5 and SHA checksum files for the zip file, saving them also in ${staging.dist.dir}. Once zip has completed, gzip uses the Ant tar task to create a .tar.gz file of the staged files (the same ones as in the .zip file), and finishes by constructing MD5 and SHA checksum files for the .tar.gz file.

The end result of the above is a set of .zip, .tar.gz, MD5, and SHA files in the ${staging.dist.dir} directory. These files comprise a downloadable/executable distribution of the WTI project.

See Also

PC2 Logo

Clone this wiki locally