调用存根生成器 CSG.xml 文件
CSG.xml 文件提供如何使用 <csg> 定制任务从 Ant 或在 Rational® Application Developer 中作为 Ant 构建启动 COBOL 调用存根生成器的完整示例。
CSG.xml 输入属性
下表描述了 CSG.xml 输入属性。如果您在 Rational Application Developer 图形界面中运行 <csg> 任务,那么可以使用 -Dproperty_name=property_value 格式来定义属性。
名称 | 必需还是可选 | 描述 |
---|---|---|
cobolSource | 必需 | 指定 COBOL 源文件的标准路径。![]() 在 Rational Application Developer 图像界面中,可以使用 ${resource_loc} 内置变量,此变量由“软件包资源管理器”上当前选定的资源的标准路径替代。 |
workSpace | 必需 | 指定要用于创建 Java™ 数据绑定类的 Rational Application Developer 或 Eclipse 工作空间的根目录标准路径。 在 Rational Application Developer 图形界面中,可以使用 ${workspace_loc} 内置变量,此变量由当前活动工作空间的标准路径替代。 |
eclipseProjectName | 必需 | 指定用于为所生成的 Java 类提供主目录的 Rational Application Developer 或 Eclipse 工作空间中项目的名称。 在 Rational Application Developer 图形界面中,可以使用 ${project_name} 内置变量,此变量由“软件包资源管理器”上当前选定的资源的项目名称替代。 在运行调用存根生成器之前,该项目必须已经存在。 |
callStubPackage | 必需 | 指定要用于生成的调用存根的软件包名称。 在 Rational Application Developer 图形界面中,可以使用 ${string_prompt:callStubPackage} 内置变量。运行时,Rational Application Developer 会提示您输入字符串值。提示对话框的标题为 callStubPackage。 |
文件位置
CSG.xml Ant 构建文件具有如下位置:
product_installation_root/CobolCallStubGenerator.V1.2/CSG.xml
CSG.xml 内容
产品中提供的 CSG.xml 文件类似如下示例:
<?xml version="1.0" encoding="UTF-8"?>
<!-- ........................................................................... -->
<!-- This Ant build file is used for invoking the COBOLCallStubGenerator (CSG)
within Rational Application Developer. It has two steps:
1. Calls CSG for the given cobolSource file.
CSG is invoked using the custom <csg> task.
<csg> generates the Java call stub and the data binder Ant file.
2. Invokes the data binder Ant file that is generated by <csg>.
The data binder Ant file invokes the data binder and generates
the data binding Java classes for the COBOL parameters.
To configure this file for use within Rational Application Developer:
1. Run -> External Tools -> External Tools Configuration.
2. New Ant Build
Buildfile: full_path_to_this_file.xml
Arguments: -DcobolSource=${resource_loc}
-DworkSpace=${workspace_loc}
-DeclipseProjectName=${project_name}
-DcallStubPackage=${string_prompt:callStubPackage}
Refresh: project
Build: project
JRE: same as workspace (needs J2C tools installed)
Usage instructions:
1. Load the COBOL source into the project.
2. Select the COBOL source file or source directory in Project Explorer.
3. Click Run -> External Tools -> CSG Ant build. -->
<!-- ........................................................................... -->
<project default="CSG">
<property name="csgDir" value="${basedir}" />
<property name="debug" value="false" />
<!-- Include the <csg> and <radlogcheck> task definitions -->
<taskdef resource="com/ibm/ws/batch/cobol/ant/callstub/antlib.xml"
classpath="${csgDir}/lib/COBOLCallStubGenerator.jar"/>
<!-- These input properties are required. They can be specified as arguments to the Ant build. -->
<property name="cobolSource" value="" /> <!-- full path to COBOL source file -->
<property name="workSpace" value="" /> <!-- full path to Eclipse workspace -->
<property name="eclipseProjectName" value="" />
<property name="callStubPackage" value="" />
<!-- The output from the <csg> task is the data binder Ant build file. The data binder Ant
build file invokes the data binder and generates the data binding classes for all
the COBOL parameters for all the COBOL files processed by <csg>. -->
<property name="antBuildFile" value="${workSpace}/${eclipseProjectName}/src/GenAllBindings.xml" />
<!-- Quick way to get the directory of the input COBOL file, in case you wanted to use it
to specify a list of files in the <fileset> type. -->
<dirname property="cobolSourceDir" file="${cobolSource}" />
<target name="CSG">
<csg configFile="${csgDir}/csg.properties"
workSpace="${workSpace}"
eclipseProjectName="${eclipseProjectName}"
antBuildFile="${antBuildFile}" >
<!-- In this example, the input is a single COBOL file, specified using a <fileset>.
You can modify the input to be a list of COBOL files, using either the
<fileset> or <filelist> types. For example, instead of using the cobolSource
property, you can use the cobolSourceDir property to specify all *.cbl files
in the directory or use <filelist> to list a subset of files in the directory.
Examples for setting the input to a list of files are included here, but commented out. -->
<fileset file="${cobolSource}" />
<!-- Example: Set the input to all *.cbl files in a directory: -->
<!-- <fileset dir="${cobolSourceDir}" includes="**/*.cbl" /> -->
<!-- Example: Set the input to a subset of files in a directory: -->
<!-- <filelist dir="${cobolSourceDir}" files="G10M0802.cbl primitve.ccp natltest.ccp" /> -->
<!-- Example: Associate all the nested files with the specified <cobolModule>: -->
<!-- <cobolModule libname="MyDLLName">
<fileset dir="${cobolSourceDir}" includes="**/*.ccp" />
</cobolModule> -->
<!-- You can specify multiple <cobolModule> elements. -->
<callStubPackage>${callStubPackage}</callStubPackage>
<!-- Example: You can use some internal call stub generator properties as substitution
variables. For example, to include the COBOL PROGRAM-ID ($_ProgramId_$) in the
callStubPackage: -->
<!-- <callStubPackage>${callStubPackage}.$_ProgramId_$</callStubPackage> -->
<!-- If not defined, the package name for the data binding classes is
${callStubPackage}.parameters. -->
<!-- <dataElementsPackage>${callStubPackage}.parameters</dataElementsPackage> -->
<!-- Example: Use substitution variables to prepend the COBOL PROGRAM-ID to the
parameter class name. -->
<!-- <dataElementsClass>$_ProgramId_$_$_DataElementName_$</dataElementsClass> -->
<!-- The Java package and class for the parameter identified by 'name' in COBOL
program 'programId' -->
<!-- <dataElement name="#REQUIRED" programId="#REQUIRED" packageName="" className="" /> -->
<!-- You can specify multiple <dataElement> elements. -->
</csg>
<!-- Refresh the workspace in order to compile the Java call stubs generated by <csg> -->
<eclipse.refreshLocal depth="infinite" resource="${eclipseProjectName}" />
<!-- radlogcheck first takes a snapshot of the Rational Application Developer log
(${workSpace}/.metadata/.log). Later, radlogcheck examines the log and searches
for any errors generated during this data binding step. -->
<radlogcheck workSpace="${workSpace}" stage="begin" />
<!-- Now run the data binder Ant build file that is generated by the <csg> task. -->
<ant antfile="${antBuildFile}" />
<!-- Scan the log for any errors that occured during the data binding step.
If errors are detected, the product writes them to the console. -->
<radlogcheck workSpace="${workSpace}" stage="end" />
<!-- Delete the antBuildFile. It is no longer needed and is merely a build artifact. -->
<delete file="${antBuildFile}" failonerror="false"/>
</target>
</project>