I think I have worked out the problem and a solution:
Sources sources = ProjectUtils.getSources(project);
SourceGroup sourceGroup =
sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)[0];
FileObject sgRoot = sourceGroup.getRootFolder();
Library lib = libraryManager.getLibrary(LIB_NAME);
ProjectClassPathModifier pcpm =
projectLookup.lookup(ProjectClassPathModifier.class);
pcpm.addLibraries(new Library[]{lib}, sgRoot, ClassPath.COMPILE);
// works
The key is using the Java source type, not generic. The addLibraries call will
not work on the main project folder; it needs a java source folder.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists