wiki:AppBuilding

Version 11 (modified by Kevin Milner, 54 years ago) (diff)

--

Application Building

This page describes how to build single applications. For official release and nightly build information/procedures, see Automated Build Process For detailed documentation on each build file, see Important Build Files

OpenSHA uses Apache Ant to automate the build process.

All ant build scripts are located in the ant directory.

Important Files

build.xml

Common build functions, including project building (building the entire project in your working directory, not creating jars) are loacted in this file. This file is also used by other build files to avoid duplication.

Important Targets

  • build (default) - builds the entire project to the "classes" directory (unless the "build" property is overridden)
  • compile - compiles all .java files into the "classes.temp" directory (specified by the "tmpdest" property) as part of the build process.
  • resource.* - targets for copying resources to the output directory
    • resource.erfs.main - copies resources for main ERFs included in applications
    • resource.erfs.dev - This is for ERFs that we won't include in our regular apps because they are underdevelopment
    • resource.erfs.gem - This is for the GEM ERFs...which we may or may not include in our regular apps.
    • resource.erfs.aux - This is for ERFs that we won't include in our regular apps because they require too much data, but may be useful to someone.
    • resource.imrs - This resources required IMR files
    • resource.misc.required - This copies all of the other misc files that are required by most applications
    • resource.all - This calls all of the other resource targets to resource absolutely everything
    • resource.hazard.apps - This calls other resource targets for local mode hazard applications
    • resource.hazard.apps.server - This calls other resource targets for server mode hazard applications (leaves out ERF data)
  • unjar.libs.common - Expands select jars from the lib dir into the output dir
  • rmi.* - tasks for compiling RMI classes using the Rmic Task
  • javadoc - generate JavaDocs? for the entire project

CompleteJar.xml

Creates single jar distributions.

Important Targets

  • jar.full.dist - Builds a jar with all classes and resources.
  • jar.classes.only - Builds a jar with all classes but no resources.

AppBuilder.xml

This is the core app building file. This will build a jar for a single application. It should not be run directly, however. It should be run by a separate build file, with the following properties set:

Properties that must be set

  • app.short.name - (required) The "short" name for the application (should not contain spaces/special characters).
    • example: HazardCurveLocal
  • app.main.class - (required) The Java main class for the application.
    • example: org.opensha.sha.gui.HazardCurveLocalModeApplication
  • javac.includes - (recommended) The javac includes for the application. Multiple patterns/files can be comma separated. If omitted, all .java files will be compiled. See "includes" for the Javac Ant Task for more information.
    • example: org/opensha/sha/gui/HazardCurveLocalModeApplication.java
    • example: org/opensha/sha/gui/HazardCurveLocalModeApplication.java,org/opensha/imr/**/*.java
  • javac.excludes - (optional) The javac excludes for the application. Multiple patterns/files can be comma separated. See "excludes" for the Javac Ant Task for more information.
    • example: org/opensha/sra/'
  • resource.target - (recommended) The target from build.xml that should be executed to copy resources for this application.
    • example: resource.hazard.apps
    • example: resource.hazard.apps.server
    • example: resource.misc.required
  • rmi.target - (optional) The target from build.xml that should be executed to compile RMI classes. Only required for RMI (remote) applications.
    • example: rmi.hazard.curve

MultiAppBuilder.xml

This file is used to actually build the application jar files. It contains targets which call AppBuilder.xml for each application.

Important Targets

  • build.nightly - Should not be run by end users, for more information see BuildProcess
  • build.dist - Should not be run by end users, for more information see BuildProcess
  • build.all - Build all standard local and remote applications
  • build.local - Build only local applications
  • build.server - Build only remote (RMI) applications
  • build.(APP NAME) - build a single application

Example

<target name="build.hc.local">
	<ant antfile="${app.build.file}" target="build.app">
		<property name="app.short.name" value="HazardCurveLocal" />
		<property name="app.main.class" value="${sha.gui.package}.HazardCurveLocalModeApplication" />
		<property name="javac.includes"     value="${sha.gui.dir}/HazardCurveLocalModeApplication.java" />
		<property name="javac.excludes" value="" />
		<property name="rmi.target" value="rmi.hazard.curve" />
		<property name="resource.target" value="resource.hazard.apps" />
	</ant>
</target>

Building Applications

Using Eclipse

To build an application using eclipse, open ant/MultiAppBuilder.xml inside eclipse. If you don't see the "Outline" view (usually on the right side of your eclipse workspace), first make sure you're in the Java perspective. If it still doesn't show up, go to Window -> Show View -> Outline.

Locate the task for the application(s) that you would like to build in the outline. For example:

  • build.hc.local - for Hazard Curve Local Mode Application
  • build.local - for all Local Mode Applications
  • build.atten.rel - for the Attenuation Relationship Plotter Application

Right click on the task, and select "Run As -> Ant Build". Progress will be shown in the console window.