if (!project.getFile(CLASSPATH).exists()) {
ArrayList<IClasspathEntry> classpath = new ArrayList<IClasspathEntry>();
boolean source = false;
boolean container = false;
ClassPathDetector detector = new ClassPathDetector(project, null);
for (IClasspathEntry entry : detector.getClasspath()){
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE){
source = true;
} else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER){
container = true;
}
classpath.add(entry);
}
// default source folder
if (!source){
IResource src;
IPreferenceStore store = PreferenceConstants.getPreferenceStore();
String name = store.getString(PreferenceConstants.SRCBIN_SRCNAME);
boolean srcBinFolders = store.getBoolean(
PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ);
if (srcBinFolders && name.length() > 0) {
src = javaProject.getProject().getFolder(name);
} else {
src = javaProject.getProject();
}
classpath.add(
new CPListElement(
javaProject, IClasspathEntry.CPE_SOURCE, src.getFullPath(), src)
.getClasspathEntry());
File srcPath = new File(
ProjectUtils.getFilePath(project, src.getFullPath().toString()));
if (!srcPath.exists()){
srcPath.mkdirs();
}
}
// default containers
if (!container){
for (IClasspathEntry entry : PreferenceConstants.getDefaultJRELibrary()){
classpath.add(entry);
}
}
// dependencies on other projects
for (IClasspathEntry entry : createOrUpdateDependencies(javaProject, depends)){
classpath.add(entry);
}
javaProject.setRawClasspath(
classpath.toArray(new IClasspathEntry[classpath.size()]), null);
// output location
IPath output = detector.getOutputLocation();
if (output == null){
output = BuildPathsBlock.getDefaultOutputLocation(javaProject);
}
javaProject.setOutputLocation(output, null);
}