I am developing m2e connector for out maven plugin, which actually generates some sources. I need to add generated sources(folder) to workspace as source folder.
I used JavaCore for edit .classpath file:
IJavaProject javaProject = JavaCore.create(proj);
IClasspathEntry[] entries = javaProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
Path myPath = new Path("target/generated-sources");
IClasspathEntry myEntry = JavaCore.newSourceEntry(myPath);
newEntries[entries.length] = JavaCore.newSourceEntry(myEntry.getPath());
javaProject.setRawClasspath(newEntries, null);
But this code doesn't work it says: Path for IClasspathEntry must be absolute
If I tried to use absolute path, it has been written to .classpath but in eclipse it wasn't displayed as source folder.
Have anyone any suggestion? It should be easy task but I cannot figure out how to solve it.