Anu
Anu

Reputation: 405

How to create more than one source folders programmatically

I want to create more than one source folder in a java project programmatically.Now I am able to create one source folder with the java project .But if I give more than one like /src/main/java & /src/test/java . enter image description here

It is creating like above picture. I am using below code for creating source folders in java project.

 for (String srcPath : projectSrcPath.split("\\s+")) {
final IClasspathEntry[] buildPath = { JavaCore.newSourceEntry(project.getFullPath().append(srcPath)),
                        JavaRuntime.getDefaultJREContainerEntry() };

javaProject.setRawClasspath(buildPath, project.getFullPath().append("bin"), null);
createFolder(project.getFullPath().append(srcPath));
}

Can anyone please tell me what is wrong I am doing here?

Upvotes: 0

Views: 92

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328770

You need to add all source folders to buildPath. Simply create more entries with JavaCore.newSourceEntry() plus the correct path.

Don't forget to create all the folders!

Upvotes: 2

Related Questions