uCosminexus Application Server, Application Development Guide

[Contents][Glossary][Index][Back][Next]

7.2.2 Editing or executing build files

The contents coded in a build file (build.xml) differ depending on each type of project. Each build file also needs to be edited based on the type of project. Create the build files in the following order:

  1. Build the EJB project
  2. Build the dynamic Web project
  3. Build the enterprise application project

The following sections describe the editing and execution of the build files for each project in the order in which they are created.

Organization of this subsection
(1) Building an EJB project
(2) Building a dynamic Web project
(3) Building the enterprise application project

(1) Building an EJB project

Code the following contents in the build file of the EJB project. When the build file is executed, an EJB-JAR file will be created.

Table 7-1 Example of the build file of an EJB project

Line number Coding example
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project name="Bank_EJB" default="create" basedir="./">
3
<property environment="myEnv"/>
4
<property name="classPath" value="${myEnv.COSMINEXUS_HOME}/CC/client/lib/j2ee-javax.jar"/>
5
<property name="ejbArchiveName" value="Bank_EJB.jar"/>
6
<property name="javacPath" value="${myEnv.COSMINEXUS_HOME}/jdk/bin/javac.exe"/>
7
<property name="tempFolder" value="ant"/>
8
<target name="create">
9
<delete file="./${ejbArchiveName}"/>
10
<mkdir dir="./${tempFolder}"/>
11
<copy todir="./${tempFolder}">
12
<fileset dir="./src" excludes="**/*.java"/>
13
</copy>
14
<javac srcdir="./src" destdir="./${tempFolder}" executable="${javacPath}" classpath="${classPath}"/>
15
<jar destfile="./${ejbArchiveName}" basedir="./${tempFolder}"/>
16
<delete dir="./${tempFolder}"/>
17
</target>
18
</project>

The meaning of each row of the build file is as follows:

Table 7-2 Coded contents of the build file of an EJB project

Line number Meaning of the coded contents
1 This is the XML declaration.
2 Specifies root of a build file.
3 Adds the settings for referencing system environment variables from the build file, in Properties.
4 Specifies the path of J2EE library of the Application Server, in Properties.
5 Adds the specification of an archive file name to be created in the EJB project, in Properties.
6 Specifies the path of the javac command of the Application Server, in Properties.
7 Specifies the temporary directory name used during build, in Properties. Specify any name as the directory name.
8 This is the start tag of the target create.
9 Deletes the existing archive file.
10 Creates a temporary directory for the purpose of build.
11 Copies the files included in the archive, in the temporary directory used for build.
12 Excludes the Java source from the copy target.
13 This is the end tag of the copy task in the eleventh row.
14 Compiles the Java source. The javac command of the Application Server is used for compilation.
15 Archives the folders and files under a temporary directory for build and created the jar file.
16 Deletes the temporary directory for build.
17 This is the end tag of the target create in the eighth row.
18 This is the end tag of the build file.

(2) Building a dynamic Web project

Code the following contents in the build file of a dynamic Web project. When the build file is executed, the WAR file will be created.

For details on the build file of a dynamic Web project, see the archive file of the EJB project. Before building a dynamic Web project, make sure to build an EJB project.

Table 7-3 Example of the build file of the dynamic Web project

Line number Coding example
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project name="Bank_Web" default="create" basedir="./">
3
<property environment="myEnv"/>
4
<property name="cjjspcdir" value="${myEnv.COSMINEXUS_HOME}/CC/web/bin"/>
5
<property name="ejbJarPath" value="../Bank_EJB/Bank_EJB.jar"/>
6
<property name="classPath" value="${myEnv.COSMINEXUS_HOME}/CC/client/lib/j2ee-javax.jar;${ejbJarPath}"/>
7
<property name="javacPath" value="${myEnv.COSMINEXUS_HOME}/jdk/bin/javac.exe"/>
8
<property name="tempFolder" value="ant"/>
9
<property name="webArchiveName" value="Bank_Web.war"/>
10
<property name="webProjectPath" value="E:/eclipse/workspace/Bank_Web/"/>
11
<property name="webRoot" value="WebRoot"/>
12
<target name="compile">
13
<exec executable="${cjjspcdir}/cjjspc.bat" newenvironment="true">
14
<arg line='-classpath ${ejbJarPath}'/>
15
<arg line='-source 1.5'/>
16
<arg line='-pageencoding UTF-8'/>
17
<arg line='-root "${webProjectPath}/${tempFolder}"'/>
18
</exec>
19
</target>
20
<target name="create">
21
<delete file="./${webArchiveName}"/>
22
<mkdir dir="./${tempFolder}"/>
23
<copy todir="./${tempFolder}">
24
<fileset dir="./${webRoot}" excludes="**/classes/**/*.class"/>
25
</copy>
26
<javac srcdir="./src" destdir="./${tempFolder}/WEB-INF/classes" executable="${javacPath}" classpath="${classPath}"/>
27
<antcall target="compile"/>
28
<war destfile="./${webArchiveName}" basedir="./${tempFolder}" webxml="./${tempFolder}/WEB-INF/web.xml" excludes="WEB-INF/web.xml"/>
29
<delete dir="./${tempFolder}"/>
30
</target>
31
</project>

The meaning of each row of the build file is as follows:

Table 7-4 Coded contents of the build file of a dynamic Web project

Line number Meaning of the coded contents
1 This is the XML declaration.
2 Specifies the root of a build file.
3 Adds the settings for referencing system environment variables from the build file, in Properties.
4 Specifies the path of the command for JSP pre-compile of the Application Server, in Properties.
5 Specifies the path of the archive of EJB project, in Properties.
6 Specifies the path of J2EE library of Cosminexus and archive of EJB project, in Properties.
7 Specifies the path of the javac command of Cosminexus, in Properties.
8 Specifies a temporary directory name used during build, in Properties. Specify any name as the directory name.
9 Specifies the archive file name to be created in the dynamic Web project, in Properties.
10 Specifies the absolute path of a dynamic Web project, in Properties.
11 Specifies the root of the dynamic Web project, in Properties.
12 This is the start tag of the target compile for JSP pre-compile.
13 Executes the command for JSP pre-compile of the Application Server.
14 Specifies the classpath of the EJB project when the classes of the EJB project are referenced by JSP pre-compile.
15 Specifies arguments of the command. Use Java language of the specified version for pre-compilation.
16 Specifies the default character encoding of JSP as the command argument.
17 Specifies the temporary directory in the root of the dynamic Web project as the command argument.
18 This is the end tag of the command execution in the twelfth row.
19 This is the end tag of the target compile in the eleventh row.
20 Specifies the root of the target create.
21 Deletes the existing archive file.
22 Creates a temporary directory for the purpose of build.
23 Copies the files included in the archive, in the temporary directory used for build.
24 Excludes the Java class from the copy target.
25 This is the end tag of the copy task in the twenty first row.
26 Compiles the Java source. The javac command of the Application Server is used for compilation.
27 Invokes the target compile for JSP pre-compilation. These contents are not coded if JSP pre-compile is not performed.
28 Archives the directories and files under the temporary directory and creates the WAR file.
29 Deletes the temporary directory.
30 This is the end tag of the target create in the eighteenth row.
31 This is the end tag of the build file.

During the JSP pre-compilation, if the JSP debug functionality is enabled in the distribution target J2EE server, the -debugging option must be specified for the cjjspc command. For details, see 2.4.2 Procedure for using the JSP debug functionality in the manual uCosminexus Application Server Web Container Functionality Guide.

(3) Building the enterprise application project

Code the following contents in the build file of an enterprise application project. When the build file is executed, the EAR file will be created.

When the enterprise application project is built, the EJB project, the dynamic Web project, and the enterprise application project will be built in that order, and an EAR file containing the EJB-JAR file and WAR file will be created.

Before building an enterprise application project, make sure to create the build file of the EJB project and the dynamic Web project.

Table 7-5 Example of a build file of an enterprise application project

Line number Coding example
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project name="Bank" default="create" basedir="./">
3
<property name="earArchiveName" value="bank.ear"/>
4
<property name="ejbArchiveName" value="Bank_EJB.jar"/>
5
<property name="ejbProjectName" value="Bank_EJB"/>
6
<property name="webArchiveName" value="Bank_Web.war"/>
7
<property name="webProjectName" value="Bank_Web"/>
8
<property name="excludes" value=".classpath,.mymetadata,.project,build-user.xml"/>
9
<target name="create">
10
<ant antfile="../${ejbProjectName}/build.xml" dir="../${ejbProjectName}" inheritall="false"/>
11
<ant antfile="../${webProjectName}/build.xml" dir="../${webProjectName}" inheritall="false"/>
12
<delete file="./${earArchiveName}"/>
13
<ear destfile="./${earArchiveName}" basedir="./" appxml="./META-INF/application.xml" excludes="${excludes}">
14
<fileset file="../${ejbProjectName}/${ejbArchiveName}"/>
15
<fileset file="../${webProjectName}/${webArchiveName}"/>
16
</ear>
17
</target>
18
</project>

The meaning of each row of the build file is as follows:

Table 7-6 Coded contents of the build file of an enterprise application project

Line number Coding example
1 This is the XML declaration.
2 Specifies a root of a build file.
3 Specifies an archive file name to be created in an enterprise application project, in Properties.
4 Specifies an archive file name to be created in an EJB project, in Properties.
5 Specifies name of the EJB project, in Properties.
6 Specifies an archive file name created in a dynamic Web project, in Properties.
7 Specifies name of the dynamic Web project, in Properties.
8 Specifies files excluded during the creation of EAR files, in Properties.
9 This is the start tag of the target create.
10 Executes the build file of the EJB project.
11 Executes the build file of the dynamic Web project.
12 Deletes the existing archive files.
13 Creates an EAR file.
14 Specifies the EJB-JAR file included in the EAR file.
15 Specifies the WAR file included in the EAR file.
16 This is the end tag of the ear task in the thirteenth row.
17 This is the end tag of the target create in the ninth row.
18 This is the end tag of the build file.