// this constructor creates only java application type
dirFO.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
public void run () throws IOException {
h[0] = createProject(dirFO, name, null, null, null, manifestFile, false, librariesDefinition);
final J2SEProject p = (J2SEProject) ProjectManager.getDefault().findProject(dirFO);
final ReferenceHelper refHelper = p.getReferenceHelper();
try {
ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
public Void run() throws Exception {
Element data = h[0].getPrimaryConfigurationData(true);
Document doc = data.getOwnerDocument();
NodeList nl = data.getElementsByTagNameNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");
assert nl.getLength() == 1;
Element sourceRoots = (Element) nl.item(0);
nl = data.getElementsByTagNameNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); //NOI18N
assert nl.getLength() == 1;
Element testRoots = (Element) nl.item(0);
for (int i=0; i<sourceFolders.length; i++) {
String propName;
if (i == 0) {
//Name the first src root src.dir to be compatible with NB 4.0
propName = "src.dir"; //NOI18N
}
else {
String name = sourceFolders[i].getName();
propName = name + ".dir"; //NOI18N
}
int rootIndex = 1;
EditableProperties props = h[0].getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
while (props.containsKey(propName)) {
rootIndex++;
propName = name + rootIndex + ".dir"; //NOI18N
}
String srcReference = refHelper.createForeignFileReference(sourceFolders[i], JavaProjectConstants.SOURCES_TYPE_JAVA);
Element root = doc.createElementNS (J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
root.setAttribute ("id",propName); //NOI18N
sourceRoots.appendChild(root);
props = h[0].getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
props.put(propName,srcReference);
h[0].putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); // #47609
}
for (int i = 0; i < testFolders.length; i++) {
if (!testFolders[i].exists()) {
testFolders[i].mkdirs();
}
String propName;
if (i == 0) {
//Name the first test root test.src.dir to be compatible with NB 4.0
propName = "test.src.dir"; //NOI18N
}
else {
String name = testFolders[i].getName();
propName = "test." + name + ".dir"; // NOI18N
}
int rootIndex = 1;
EditableProperties props = h[0].getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
while (props.containsKey(propName)) {
rootIndex++;
propName = "test." + name + rootIndex + ".dir"; // NOI18N
}
String testReference = refHelper.createForeignFileReference(testFolders[i], JavaProjectConstants.SOURCES_TYPE_JAVA);
Element root = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "root"); // NOI18N
root.setAttribute("id", propName); // NOI18N
testRoots.appendChild(root);
props = h[0].getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); // #47609
props.put(propName, testReference);