michaelsembwever commented on code in PR #9545:
URL: https://github.com/apache/netbeans/pull/9545#discussion_r3745099064
##########
java/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/ClasspathsTest.java:
##########
@@ -548,4 +551,114 @@ public void propertyChange(PropertyChangeEvent e) {
assertTrue(cpe2.includes("whatever/"));
}
+ /** A "dir/*.jar" entry expands to every matching JAR in the directory
(#116185). */
+ public void testWildcardClasspath() throws Exception {
+ clearWorkDir();
+ File d = getWorkDir();
+ AntProjectHelper helper = FreeformProjectGenerator.createProject(d, d,
"prj", null);
+ Project p =
ProjectManager.getDefault().findProject(helper.getProjectDirectory());
+ FileObject src = FileUtil.createFolder(new File(d, "src"));
+ File libDir = new File(d, "lib");
+ assertTrue("created lib dir", libDir.mkdirs());
+ File jarA = createJar(new File(libDir, "a.jar"));
+ File jarB = createJar(new File(libDir, "b.jar"));
+ createJar(new File(libDir, "readme.zip")); // does not match *.jar
+ configureCompileClasspath(helper, p, "src", "lib/*.jar");
+
+ ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
+ assertNotNull("have COMPILE classpath for src/", cp);
+ SortedSet<String> expected = new TreeSet<String>();
+ expected.add(jarRoot(jarA));
+ expected.add(jarRoot(jarB));
+ assertEquals("wildcard expanded to the matching jars", expected,
urlsOfCp(cp));
+ }
+
+ /** A bare "dir/*" entry expands to the archives only, skipping other
files. */
+ public void testWildcardClasspathIncludesOnlyArchives() throws Exception {
+ clearWorkDir();
+ File d = getWorkDir();
+ AntProjectHelper helper = FreeformProjectGenerator.createProject(d, d,
"prj", null);
+ Project p =
ProjectManager.getDefault().findProject(helper.getProjectDirectory());
+ FileObject src = FileUtil.createFolder(new File(d, "src"));
+ File libDir = new File(d, "lib");
+ assertTrue("created lib dir", libDir.mkdirs());
+ File jarA = createJar(new File(libDir, "a.jar"));
+ writeText(new File(libDir, "notes.txt"), "not an archive"); // must be
skipped
+ configureCompileClasspath(helper, p, "src", "lib/*");
+
+ ClassPath cp = ClassPath.getClassPath(src, ClassPath.COMPILE);
+ assertNotNull("have COMPILE classpath for src/", cp);
+ assertEquals("only the archive was included",
+ Collections.singleton(jarRoot(jarA)), urlsOfCp(cp));
+ }
+
+ /** JARs produced after the project is opened are picked up without
editing project.xml. */
+ @RandomlyFails // depends on asynchronous filesystem-event delivery +
coalescing
Review Comment:
addressed in
https://github.com/apache/netbeans/pull/9545/changes/c9969aa2f1bef8469db4567b1bd05bac8fb8836e
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
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