This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I am trying to build a compile classpath for a specified project, by getting the project's Sources, then the Sources SourceGroups, then getting each group's root folder, then calling ClassPath.getClassPath(root, ClassPath.COMPILE). This works for J2SE projects. With a NBM project type (I'm testing with openide/util), the classpath comes back incorrectly as: ClassPath[Entry[jar:file:/work/src/netbeans/nb_all/nbbuild/netbeans/platform6/lib/org-openide-util.jar!/], Entry[jar:file:/work/src/netbeans/nb_all/nbbuild/netbeans/ide6/modules/ext/junit-3.8.1.jar!/], Entry[jar:file:/work/src/netbeans/nb_all/nbbuild/netbeans/testtools/modules/org-netbeans-modules-nbjunit.jar!/], Entry[jar:file:/work/src/netbeans/nb_all/performance/insanelib/dist/insanelib.jar!/]] The org-netbeans-modules-nbjunit.jar doesn't exist at the specified location. The module's unit tests work from Ant, however, but it uses a different classpath (I am using "Run Unit Tests", not "Run Unit Tests using XTest"): /work/src/netbeans/nb_all/openide/util/build/test/unit/classes:\ /work/src/netbeans/nb_all/nbbuild/netbeans/platform6/lib/org-openide-util.jar:\ /work/src/netbeans/nb_all/xtest/lib/junit.jar:\ /work/src/netbeans/nb_all/xtest/lib/nbjunit.jar:\ /work/src/netbeans/nb_all/xtest/lib/nbjunit-ide.jar:\ /work/src/netbeans/nb_all/xtest/lib/insanelib.jar' Shouldn't the COMPILE classpath used for the unit test root match the one Ant uses to build the unit tests? And how should I get the real COMPILE path?
The call is correct... you just need to exclude roots which do not exist. The problem is that there is no very standard way in which nbjunit.jar can be found. For netbeans.org modules w/ xtest checked out, xtest/lib/nbjunit.jar is OK. But in general, for other modules, if you want to use the nbjunit extensions you have to download (or build) the module from AU which bundles this JAR. Since XTest is not officially supported by the apisupport harness, neither is the nbjunit extension - it is not included in the harness and may or may not be available in a particular user's IDE installation. If it's not, they can't use tests which make use of it. No plans to really clean this up for 5.0 (would prefer that nbjunit just go away or be packaged differently, really), but can probably tweak the effective classpath for NBM projects to be *more likely to* produce a valid JAR location than it currently does.
Working on it...
Actually it turns out that there was a reason I was using a different CP in the project evaluator - because the actual Ant CP is no good for code completion; no source associations. So fix will be a bit more complicated.
I don't mind using a different query than code-completion, if that option makes sense.
No, CP.getCP(COMPILE) is correct, it's just going to be tricky to fix right and make a unit test for that isn't overly sensitive to details of your build dir (already a problem for apisupport tests checking netbeans.org module behavior). A sampler: for code completion on junit.jar, you have to include the version of junit.jar which is found in the running IDE installation, to get its Javadoc association; for completion on nbjunit.jar, you actually have to use org-netbeans-modules-nbjunit.jar (a module which refers to nbjunit.jar) to get the reference to xtest/nbjunit/src. Can be hacked to work in a different way, probably. I'll see.
committed * Up-To-Date 1.130 apisupport/project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java committed * Up-To-Date 1.6 apisupport/project/src/org/netbeans/modules/apisupport/project/queries/GlobalJavadocForBinaryImpl.java committed * Up-To-Date 1.5 apisupport/project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java committed * Up-To-Date 1.24 apisupport/project/test/unit/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImplTest.java
Works exactly as expected -- thanks for your prompt response.
Integrated into 'main-golden', will be available in build *201104140401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/02742b70e24b User: Jesse Glick <jglick@netbeans.org> Log: #68685 fix looks to be long obsolete; removing.