Dieses Beispiel veranschaulicht, wie der Standardbuilder eines MVS-Unterprojekts durch einen neuen Builder ersetzt wird. Der neue Builder kann verwendet werden, um die Art und Weise zu ändern, auf die ein Unterprojekt erstellt wird, wenn eine Buildaktion angefordert wird.

Wenn Sie den Standardbuilder für Unterprojekte durch einen anderen (benutzerdefinierten) Builder ersetzen möchten, klicken Sie mit der rechten Maustaste auf das Unterprojekt und wählen Sie die Aktion API-Beispielaktionen > Standardbuilder ersetzen aus.

Durch diese Aktion werden die Informationen in der XML-Datei aktualisiert. Die Datei wird möglicherweise nicht sofort aktualisiert, die Builderinformationen werden jedoch beim nächsten Schreiben der Datei geändert. Zu diesem Zeitpunkt sieht die Datei ungefähr wie folgt aus:

Wenn Sie den ursprünglichen (Standard-)Builder für Unterprojekte wiederherstellen möchten, wählen Sie die Aktion API-Beispielaktionen > Standardbuilder wiederherstellen aus.
Builder für Unterprojekte in Rational Developer for System z ähneln dem Konzept nach einem Programm zur inkrementellen Projekterstellung in der Eclipse-Basisversion. Sie bieten die Möglichkeit, den Inhalt eines Unterprojekts zu erstellen, indem neue und/oder aktualisierte Buildergebnisse erstellt werden. So können beispielsweise alle COBOL-Quellendateien im Unterprojekt von einem COBOL-Compiler verarbeitet und die Ergebnisdateien (Objektdateien, Listendateien, ausführbare Dateien und so weiter) dem Unterprojekt hinzugefügt werden.
Wenn Sie ein benutzerdefiniertes Projekterstellungsprogramm für ein fernes Unterprojekt definieren möchten, müssen Sie eine Klasse erstellen, die die Schnittstelle ILogicalSubProjectBuilder implementiert. Daher enthält die Klasse SampleBuilder folgenden Code:
public class SampleBuilder implements ILogicalSubProjectBuilder {
......
}
Die Schnittstelle ILogicalSubProjectBuilder ist relativ einfach gehalten. Fügen Sie in SampleBuilder einfach ein privates Feld subproject für die Unterprojektinstanz hinzu. In diesem Beispiel wird eine println-Anweisung ausgeführt, die die Meldung "Sample Builder called for subProject:" ausgibt und den Namen des Unterprojekts enthält.
Sie finden den vollständigen Quellcode in 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;
}
}
Sie finden den vollständigen Quellcode in AddSubProjectBuilderAction.java.
Die Aktion wird mithilfe der Standardergänzungsmechanismen von Eclipse hinzugefügt.
<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;
}
}
Sie finden den vollständigen Quellcode in RemoveSubProjectBuilderAction.java.
Die Aktion wird mithilfe der Standardergänzungsmechanismen von Eclipse hinzugefügt.
<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>