I’m getting back to work on my Conventional Commit plugin after a period of inactivity and ran into an old, but still unresolved, problem: how should a plugin reliably find a configuration file that conceptually lives under the “project root”? Wait, don’t type “there is no project root” yet!
The plugin looks for a conventionalcommit.json file under the “project root” and, if present, uses it instead of the configuration bundled inside the plugin JAR. Back in 2019, when I first introduced that logic, it was already known that using Project.getBasePath or Project.getBaseDir was unreliable. Now this is further complicated by remote development (frontend/backend architecture) and the introduction of multi-project workspaces.
Consequently, questions that come to mind are:
- From the client perspective (where the user actually interacts with the plugin), is a “project root” always backed by
LocalFileSystem? Or can a project be opened through otherVirtualFileSystemimplementations? - The documentation of
Project.getBasePathsays “…if .idea directory is stored not near the project files”. But wait… is that a realistic scenario today? I haven’t found a way to create a fresh project where.ideais stored somewhere else than the “project root". - Can we differentiate between “project root” and “opened folder path”? Many IDEs don’t have a real concept of a project, and the open folder is what extensions look at for something comparable to a “project root”.
- Given the points above, what is the recommended way for a plugin to locate a file that is expected to live under the “opened folder path”?
Project.guessProjectDiris a known candidate, but I don’t like the “guessing” part, plus it seems it hardcodes assumptions aroundLocalFileSystem(see point 1). - With multi-project workspaces, a user might have one
conventionalcommit.jsonfile per added project. In which case:- How should a plugin decide which configuration file to use when a VCS operation involves files from different projects?
- Are there existing APIs/solutions for resolving configuration files in this scenario? (e.g., VCS root-based resolution - although VCS isn’t necessary enabled).
To be honest, this isn’t a question for which I’d expect a straightforward answer, but it’s a way to resurrect the topic and hopefully share some ideas around it.