Build Procedure

The Build procedure can be divided into the following two parts: 1) Building Java Components 2) Building C++ Components While building a project which comprises both Java and C++ components, we use an additional master build file. This file (mostly a batch file) calls the builds of both Java and C++ components in the order required. 1) Building Java Components Introduction to Ant For building Java components, we use Ant Scripts. For this you first need to have Ant on your system. If you do not have Ant, do the following: a) Copy apache-ant-1.6.2-bin from \\Install\Java to say D: b) Unzip The Folder. c) In System Variables, update the path variable as D:\apache-ant-1.6.2\bin. Next you need to write Ant build scripts. By default, ant looks for a build file named build.xml in the current directory. This build file follows a very simple structure. Each <project> contains one or more <target>s; each target can depend on zero or more other targets. When you run ant, you specify which target you want ant to build; ant then runs all the targets that one depends on first, then runs the target you asked for. The following gives an introduction to some basic terms used in Ant. Properties Properties (that is, variables) are a very important part of Ant. Generally, the important strings -- directory names, file names, the classpath -- are declared as <property> elements. This allows you to easily change their value later on, even if you refer to them in several places. It also allows you to easily override their values, using (a) -Dfoo=bar on the command line, (b) the <ant> task, calling one ant file from another one, or (c) <property file="...">. The <property file="..."> construct is usually used to include a file called This is a convention used so that you can override default values for your local build environment, without having to modify build.xml. Property precedence in Ant is a little upside down. The rule is, the first line that sets a property wins. That means that a value on the command line comes first, then a value set in a whatever build.xml file called this one, then the first value set in this file. (This

means that, to be effective, must be included very early in the script.) To illustrate, the following ant script: <property name="foo" value="from build.xml"/> <property file=""/> <property name="bar" value="from build.xml"/> <property name="foo" value="a different value"/> <echo message="foo=${foo} bar=${bar}"/> with the following content inside foo=from bar=from will output the following: foo=from build.xml bar=from Note that you can declare <property> elements directly as children of the <project> (although I prefer to set them inside the "init" task). Also note that using <property name="..." location="..."/> tells ant to expand the file/directory names to absolute paths, which can help resolve some possible confusions. (Be careful to go back to <property name="..." value="..."/> for non-file properties!) init target Here you should set up all the properties used by other targets, as well as creating the build directory structure. All other targets depend on "init," which means that "init" will always be run first. clean target This target removes all compiled files and starts fresh. Here we delete all class files, JARs or WARs. compile target
This compiles your target java files. You can provide the path where you want the resulting class files to go. Javadoc target The javadoc target simply runs javadoc on the source tree WAR target

This builds the WAR file to be deployed directly on your web server.

Below is an example build.xml file. In this, we have compiled the Java sources separately in VL and CL layers. This is as per Siemens CMU structure.

Batch Script for Build: Once we have our build.xml file ready, we write a batch script which sets various environment variables and runs the Ant command. An example batch file is given below:


Note that we write our batch file in such a way that we can run it giving a command in the following pattern: MappingTool_JAVA –s <Source Folder> -d <Target Folder (bin)> -f Release

2) Building C++ Components For building C++ components, we need to have Visual Studio installed on our machine. We use the NMake tool to build C++ files. For this, we write makefiles. An example makefile is as follows:

Also for Siemens, we use TCL scripts which may call other TCL scripts or makefiles. A sample TCL file is as given below.

3) Putting it All Together The below steps would summarize the build process as a whole. This is according to the CMU structure needed for Siemens projects:

a) Add the following variable to the PATH environment variable <FolderName>\src\ant_TP\apache-ant-1.6.1\bin (Can be added in the build batch script) b) Create a new environment variable “JAVA_HOME” & set it to the following <FolderName>\src\Jdk_TP (Can be added in the build batch script) c) Go to command prompt Go to the directory <FolderName>\src\***_BUILD directory. Then SET PROJECT=DE_5855_RICS (Can be added in the build batch script) d) Run the batch script as following: RCWEBUI –s <Source Folder> -d <Target Folder (bin)> -f Release e) At the end of build, *.WAR would be created in target folder (bin). Copy this *.WAR to <FolderName>\src\Tomcat_TP\webapps. (Can be added in build.xml as a part of build process)