このサンプルは、MVS サブプロジェクトのデフォルト・ビルダーを新しいビルダーに置き換える方法を示します。新しいビルダーを使用すると、ビルド・アクションが要求されたときにサブプロジェクトをビルドする方法を変更できます。

デフォルトのサブプロジェクト・ビルダーを別の (ユーザー定義の) ビルダーに置き換えるには、サブプロジェクトを右クリックして、「API サンプル・アクション」->「デフォルト・ビルダーの置換」アクションを選択します。

このアクションにより、XML ファイル内の情報が更新されます。 このファイルは、すぐに更新されない場合がありますが、次にファイルが書き込まれるときにはビルダー情報が変更されます。現時点では、ファイルは次のように表示されます。

オリジナル (デフォルト) のサブプロジェクト・ビルダーを復元するには、「API サンプル・アクション」->「デフォルト・ビルダーの復元」アクションを選択します。
Rational® Developer for System z® のサブプロジェクト・ビルダーは、ベース Eclipse の増分プロジェクト・ビルダーに概念が似ています。これらは、新規作成や更新などのサブプロジェクトの内容を構築する手段を提供します。例えば、サブプロジェクト内のすべての COBOL ソース・ファイルを COBOL コンパイラーで処理すると、結果のファイル (オブジェクト、リスト、実行可能ファイルなど) はサブプロジェクトに追加されます。
リモート・サブプロジェクト用のカスタム・プロジェクト・ビルダーを定義するには、ILogicalSubProjectBuilder インターフェースを実装するクラスを作成する必要があります。 したがって、SampleBuilder クラスの内容は、以下のようになります。
public class SampleBuilder implements ILogicalSubProjectBuilder {
......
}
ILogicalSubProjectBuilder インターフェースは、比較的簡単です。SampleBuilder では、サブプロジェクト・インスタンスの subproject 専用フィールドを追加するのみです。このサンプルは、「サブプロジェクト用にサンプル・ビルダーが呼び出された」ことを示す println ステートメントを発行し、サブプロジェクトの名前を組み込みます。
完全なソース・コードは、SampleBuilder.java で参照できます。
IBuildCommand[] buildCommands = subProject.getBuildSpec();
// look through the existing build commands for the "standard"
// RDz builder for MVS subprojects, and if found substitute the
// sample builder in its place
for (int i = 0; i < buildCommands.length; ++i) {
if (buildCommands[i].getBuilderName().equals(IProjectCoreConstants.ZOS_BUILDER_ID)) {
// copy the commands preceding the RDz builder
IBuildCommand[] newCommands = new IBuildCommand[buildCommands.length];
if (i > 0) {
System.arraycopy(buildCommands, 0, newCommands, 0, i - 1);
}
// create a new command for the sample builder
IBuildCommand buildCommand = getSubProject().newCommand();
buildCommand.setBuilderName("com.ibm.ftt.api.samples.samplebuilder");
// add the new command
newCommands[i] = buildCommand;
// copy the rest of the build commands
if (i < buildCommands.length) {
System.arraycopy(
buildCommands,
i + 1,
newCommands,
i,
buildCommands.length - i - 1);
}
// store the new set of build commands
subProject.setBuildSpec(newCommands);
System.out.println("Sample builder replaces RDz builder");
break;
}
}
完全なソース・コードは、AddSubProjectBuilderAction.java で参照できます。
アクションは、標準の Eclipse の機構を使用して提供されます。
<objectContribution
adaptable=“false”
objectClass=“com.ibm.ftt.projects.core.logical.ILogicalSubProject”
id=“com.ibm.ftt.api.samples.addbuilder”>
<visibility>
<not>
<objectState
name=“projectBuilder”
value=“com.ibm.ftt.api.samples.samplebuilder”>
</objectState>
</not>
</visibility>
<action
label=“
class=“com.ibm.ftt.api.samples.builders.AddSubProjectBuilderAction”
menubarPath=“com.ibm.ftt.api.samples.PopupMenu/group1”
id=“com.ibm.ftt.api.samples.addbuilderaction”/>
</objectContribution>
IBuildCommand[] buildCommands = subProject.getBuildSpec();
// look through the existing build commands for the sample
// builder, and if found substitute the "standard" RDz builder
// in its place
for (int i = 0; i < buildCommands.length; ++i) {
if (buildCommands[i].getBuilderName().equals("com.ibm.ftt.api.samples.samplebuilder")) {
// copy the commands preceding the sample builder
IBuildCommand[] newCommands = new IBuildCommand[buildCommands.length];
if (i > 0) {
System.arraycopy(buildCommands, 0, newCommands, 0, i - 1);
}
// create a new command for the RDz builder
IBuildCommand buildCommand = getSubProject().newCommand();
buildCommand.setBuilderName(IProjectCoreConstants.ZOS_BUILDER_ID);
// add the new command
newCommands[i] = buildCommand;
// copy the rest of the build commands
if (i < buildCommands.length) {
System.arraycopy(
buildCommands,
i + 1,
newCommands,
i,
buildCommands.length - i - 1);
}
// store the new set of build commands
subProject.setBuildSpec(newCommands);
System.out.println("RDz builder replaces Sample builder");
break;
}
}
完全なソース・コードは、RemoveSubProjectBuilderAction.java で参照できます。
アクションは、標準の Eclipse の機構を使用して提供されます。
<objectContribution
adaptable=“false”
objectClass=“com.ibm.ftt.projects.core.logical.ILogicalSubProject”
id=“com.ibm.ftt.api.samples.removebuilder”>
<filter
value=“com.ibm.ftt.api.samples.samplebuilder”
name=“projectBuilder”/>
<action
label=“
class=“com.ibm.ftt.api.samples.builders.RemoveSubProjectBuilderAction”
menubarPath=“com.ibm.ftt.api.samples.PopupMenu/group1”
id=“com.ibm.ftt.api.samples.removebuilderaction”/>
</objectContribution>