Author Topic: Update JAR wildcard handling  (Read 197 times)

rygaard

  • Community Member
  • Posts: 49
  • Hero Points: 0
Update JAR wildcard handling
« on: September 11, 2022, 02:38:55 pm »
I'd like to see a change in the behavior in the Build -> Java Options -> Classpath tab when I use the
Quote
Add Jar Wildcard...
button:
  • If the Recursive check box is not selected, then the entry appears as /path/to/directory/* in the Classpath tab.  This entry should be added to the classpath as /path/to/directory/*.
  • If the Recursive check box is selected, then the entry appears as /path/to/directory/*/* in the Classpath tab (or some other visual cue to indicate that it is recursive).  This entry should be added to the classpath as /path/to/directory/*:/path/to/directory/subdirectory1/*:/path/to/directory/subdirectory1/subdirectory11/*:/path/to/directory/subdirectory2/* etc.

Of course, if classpath contraction is invoked, these paths could be altered to relative paths, but they would still have the trailing /*.

This would be more in line with the Java standard.  According to https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html:
Quote
Class Path Wild Cards

Class path entries can contain the base name wildcard character (*), which is considered equivalent to specifying a list of all of the files in the directory with the extension .jar or .JAR. For example, the class path entry mydir/* specifies all JAR files in the directory named mydir. A class path entry consisting of * expands to a list of all the jar files in the current directory. Files are considered regardless of whether they are hidden (have names beginning with '.').

A class path entry that contains an asterisk (*) does not match class files. To match both classes and JAR files in a single directory mydir, use either mydir:mydir/* or mydir/*:mydir. The order chosen determines whether the classes and resources in mydir are loaded before JAR files in mydir or vice versa.

Subdirectories are not searched recursively. For example, mydir/* searches for JAR files only in mydir, not in mydir/subdir1, mydir/subdir2, and so on.

This means all valid wildcard entries have the form
      /path/to/directory/*
and they refer only to JAR files.

It also means classpath entries of the form
      /path/to/directory/*.jar
      /path/to/directory/Version*.jar
      /path/to/directory/Version*.*.jar

are invalid and ignored.

This has other benefits:
  • It absolves SlickEdit of having to select an ordering for the JARs.
  • It absolves SlickEdit of having to decide whether or not to include hidden files.
  • It keeps the classpath shorter.