Hello Stephen,

as it's Your source code, the right place for questions is here.

I haven't used ProjectClassPathModifier or ProjectClassPathExtender yet, but from the JavaDoc I'd guess You should probably be able to use "ProjectClassPathExtender pcpe = pcpm.extenderForModifier(pcpe);". While I understand this shouldn't be the final solution, I'd try this first, as this uses something You found to work for You.

Well, in the second step You'll want to use the project as construction parameter, but there may be a pitfall: The JavaDoc says "Similar to extenderForModifier(ProjectClassPathModifierImplementation) but permits the new SPI to be created lazily.". Probably there's a problem with the SPI, I'll have a look at it.

Kind regards

Peter




Am 25.05.2018 um 12:59 schrieb sgpa...@mainscreen.com:
Hi Peter,
Thanks for the quick reply.
The plugin adds a library to the classpath, currently by rewriting the projevct 
properties file. I am trying to use the API instead. I can get it working using 
ProjectClassPathExtender but not ProjectClassPathModifier, which gives me:
Java.lang.UnsupportedOperationException: Project in 
C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication16 of 
class org.netbeans.modules.java.j2seproject.J2SEProject has a 
ProjectClassPathModifierImplementation but it will not handle classpath/compile 
for C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication16 
extensible source groups: 
C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication16\src
at 
org.netbeans.api.java.project.classpath.ProjectClassPathModifier.findExtensible(ProjectClassPathModifier.java:388)

The code I have been trying, including the three different variations I have 
tried follows:
             FileObject projectRoot = project.getProjectDirectory();
             Sources sources = ProjectUtils.getSources(project);
             SourceGroup sourceGroup = 
sources.getSourceGroups(Sources.TYPE_GENERIC)[0];
             FileObject sgRoot = sourceGroup.getRootFolder();
             Library lib = libraryManager.getLibrary(LIB_NAME);
             ProjectClassPathModifier pcpm = 
projectLookup.lookup(ProjectClassPathModifier.class);
             ProjectClassPathExtender pcpe = pcpm.extenderForModifier(project);
             pcpe.addLibrary(lib); // Works but deprecated
             pcpm.addLibraries(new Library[]{lib}, projectRoot, 
ClassPath.COMPILE); // Fails regardless
             pcpm.addLibraries(new Library[]{lib}, sgRoot, ClassPath.COMPILE); 
// Fails regardless


On 2018/05/25 10:11:41, Peter Nabbefeld <peter.nabbef...@gmx.de> wrote:
Hi Stephen,

what does it mean, You "cannot get it working"? Which problems
(behaviour or exceptions) do You have exactly?

Kind regards
Peter


Am 25.05.2018 um 11:50 schrieb sgpa...@mainscreen.com:
Hi,
Can someone please direct me to the correct place for asking questions 
regarding plugin devlopment?
I am having trouble contributing a fix to a bug in a third-party NB 8 plugin - 
I have a fix using the deprecated ProjectClassPathExtender class but I want to 
use the replacement ProjectClassPathModifier class, but I cannot get it working.
Thanks
Stephen Parry

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@netbeans.incubator.apache.org
For additional commands, e-mail: dev-h...@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@netbeans.incubator.apache.org
For additional commands, e-mail: dev-h...@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists






---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@netbeans.incubator.apache.org
For additional commands, e-mail: dev-h...@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@netbeans.incubator.apache.org
For additional commands, e-mail: dev-h...@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to