이 샘플에서는 MVS 하위 프로젝트의 기본 빌더를 새 빌더로 바꾸는 방법을 보여줍니다. 새 빌더는 빌드 조치가 요청될 때 하위 프로젝트가 빌드되는 방식을 변경하는 데 사용할 수 있습니다.

기본 하위 프로젝트 빌더를 다른 빌더(사용자 정의 빌더)로 바꾸려면, 하위 프로젝트를 마우스 오른쪽 단추로 클릭하고 API 샘플 조치 > 기본 빌더 바꾸기 조치를 선택하십시오.
이렇게 하면 XML 파일의 정보가 업데이트됩니다. 파일이 즉시 업데이트되지는 않지만 다음에 파일을 작성할 때 빌더 정보가 변경됩니다. 이때, 파일은 다음 그림과 같습니다.

원래(기본) 하위 프로젝트 빌더를 복원하려면 API 샘플 조치 > 기본 빌더 복원 조치를 선택하십시오.
Rational® Developer for System z®의 하위 프로젝트 빌더는 개념상 기본 Eclipse의 증분 프로젝트 빌더와 비슷합니다. 이 빌더는 업데이트되었거나 새로운 빌드 결과를 작성하여 하위 프로젝트의 개념을 빌드하는 방법을 제공합니다. 예를 들어, 하위 프로젝트의 모든 COBOL 파일이 COBOL 컴파일러에 의해 처리되고, 결과 파일(오브젝트, 목록, 실행 파일 등)이 하위 프로젝트에 추가됩니다.
원격 하위 프로젝트의 사용자 정의 프로젝트 빌더를 정의하려면 ILogicalSubProjectBuilder 인터페이스를 구현하는 클래스를 작성해야 합니다. 그러면 SampleBuilder 클래스에 다음과 같은 코드가 포함됩니다.
public class SampleBuilder implements ILogicalSubProjectBuilder {
......
}
ILogicalSubProjectBuilder 인터페이스는 비교적 간단합니다. SampleBuilder에서 하위 프로젝트 인스턴스의 개인 필드 subproject를 추가하면 됩니다. 이 샘플은 "다음 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>