Hi Stephen,

I've found the following source code:

    @SuppressWarnings("deprecation")
    public static org.netbeans.spi.java.project.classpath.ProjectClassPathExtender extenderForModifier(final Project p) {         return new org.netbeans.spi.java.project.classpath.ProjectClassPathExtender() {             @Override public boolean addLibrary(Library library) throws IOException {                 ProjectClassPathModifierImplementation pcpmi = p.getLookup().lookup(ProjectClassPathModifierImplementation.class);                 return pcpmi != null ? extenderForModifier(pcpmi).addLibrary(library) : false;
            }
    ...

As the J2SE implementation is rather old, I'd guess it does not provide its own ProjectClassPathModifierImplementation - could You check its exact type (FQCN)? That will probably make things more clear (and easier to find the implementation code).

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