List<IProject> projs = RunJettyRunSourceLookupUtil.findMavenRelatedProjects(configuration);
if(projs.size() == 0 ){
return ;
}
ISourceLookupDirector sourceDir = new JavaSourceLookupDirector();
ILaunchConfigurationWorkingCopy workCopy = configuration.getWorkingCopy();
String initMemento = workCopy.getAttribute(
ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "");
if (initMemento != null && !initMemento.trim().equals("")) {
sourceDir.initializeFromMemento(initMemento);
}
ISourceContainer[] existContainers = sourceDir
.getSourceContainers();
List<ISourceContainer> realContainers = new ArrayList<ISourceContainer>();
//add exsits source containers
for (ISourceContainer container : existContainers) {
realContainers.add(container);
}
//check default source container
ISourceContainer defaultContainer = new DefaultSourceContainer();
if (!contains(existContainers, defaultContainer)) {
realContainers.add(defaultContainer);
}
for (IProject dependency : projs) {
// handle projects in current workspace
ISourceContainer newContainer = new JavaProjectSourceContainer(
JavaCore.create((IProject) dependency));
if (!contains(existContainers, newContainer)) {
realContainers.add(newContainer);
}
}
sourceDir.setSourceContainers(realContainers
.toArray(new ISourceContainer[realContainers.size()]));
workCopy.setAttribute(
ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO,
sourceDir.getMemento());
workCopy.doSave();
} catch (Exception e) {
// something wrong, skip add sources
}