netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Support for relative paths in the source file launcher's paths; automatic expanding of modular paths.

Open lahodaj opened this issue 9 months ago • 2 comments

The VS Code extension supports the (multi-)source file launcher using the RUN CONFIGURATION explorer tab. One can specify the command line options, which are then used when starting a file in the workspace.

There are a few problems with that:

  • options like -classpath could contain relative paths, but NB will not resolve them
  • the default working directory is weird - it is the directory in which the file-to-run resides. That made sense for single-source launcher, but not anymore. And while runtime will resolve relative paths, it will resolve them to this weird working directory
  • for --module-path, the elements specified may be modules, or a directory, which contains the modules. But NB will only see module path which contains modules, and will not resolve modules inside the specified directory

This patch:

  • when needed, computes "relevant" default working directory for files - it is a) the workspace folder that encloses the given file (which should be the common case), or, if that fails to find a workspace folder b) the workspace folder that is enclosed by the file's source root (for the case where the user opens just a part of the source root)
  • this relevant default working directory is then used as the working directory, unless overridden by the user
  • the working directory (either computed as above, or explicit) is used the base to resolve relative paths
  • when a module path contains a directory which does not contain module-info.class, it is interpreted as a directory consisting of a collection of modules, and will expand the module path to include these modules. This includes listening on the directory content, and updates to the module path when the content changes

lahodaj avatar May 16 '24 16:05 lahodaj