}
}
String dependsString = commandLine.getValue(Options.DEPENDS_OPTION);
IScriptProject scriptProject = DLTKCore.create(project);
if (!project.getFile(BUILDPATH).exists()) {
IDLTKLanguageToolkit toolkit = getLanguageToolkit(getNatureId());
BuildpathDetector detector = new BuildpathDetector(project, toolkit);
detector.detectBuildpath(null);
IBuildpathEntry[] detected = detector.getBuildpath();
// remove any entries the detector may have added that are not valid for
// this project (currently happens on php projects with the
// org.eclipse.dltk.launching.INTERPRETER_CONTAINER entry).
ArrayList<IBuildpathEntry> entries = new ArrayList<IBuildpathEntry>();
for (IBuildpathEntry entry : detected){
IModelStatus status = BuildpathEntry
.validateBuildpathEntry(scriptProject, entry, true);
if(status.isOK()){
entries.add(entry);
}
}
detected = entries.toArray(new IBuildpathEntry[entries.size()]);
IBuildpathEntry[] depends =
createOrUpdateDependencies(scriptProject, dependsString);
IBuildpathEntry[] buildpath = merge(
new IBuildpathEntry[][]{detected, depends});
//scriptProject.readRawClasspath(), detected, depends, container
scriptProject.setRawBuildpath(buildpath, null);
}
if (interpreter != null){
IBuildpathEntry[] buildpath = scriptProject.getRawBuildpath();
int containerIndex = 0;
for (int i = 0; i < buildpath.length; i++){
if (buildpath[i].getEntryKind() == IBuildpathEntry.BPE_CONTAINER){
containerIndex = i;
break;
}
}
if (containerIndex == 0){
throw new RuntimeException("No container buildpath entry found.");
}
IBuildpathEntry container = buildpath[containerIndex];
buildpath[containerIndex] = DLTKCore.newContainerEntry(
ScriptRuntime.newInterpreterContainerPath(interpreter),
container.getAccessRules(),
container.getExtraAttributes(),
container.isExported());
scriptProject.setRawBuildpath(buildpath, null);
}
scriptProject.makeConsistent(null);
scriptProject.save(null, false);
}