Skip to content

Support IDE imports for multiple scripts/projects sharing the same project root #3367

Open
@jackkoenig

Description

@jackkoenig

Is your feature request related to a problem? Please describe.

It's common practice to have grab bags of "utility" scripts that are independent of each other. Often these are written in scripting languages like Python, Perl, or even Bash. Sometimes there will be shared code, sort of "library" files shared by multiple script "application" files. I am working on migrating such "grab bag utility" scripts to Scala Cli, it's awesome but this directory structure conflicts with Scala Cli's model of projects on a directory basis.

Note that it seems to work, except I think when I run different "scripts" in the same directory via scala-cli they are clobbering the .scala-build directory. The problem is most apparent when trying to use Metals with these scripts because it will report errors about multiple definitions (e.g. each top-level "script" has an object Main) and warnings about Using directives detected in multiple files. again due to multiple top-level "scripts".

Describe the solution you'd like

It would be nice if Scala Cli could treat projects on a per-file basis rather than per directory. using file directives in the top-file should be enough to define which files are in a particular project, and then Scala Cli could disambiguate each project based on the "top" file.

I am not sure if this is the same issue or separate, but the complaints about "using directives detected in multiple files" feels related--if I have some "library" files shared between separate projects, those libraries should be able to define their own dependencies. Maybe this is a step too much toward "build tool" land though.

Describe alternatives you've considered

I could define each "script" in its own directory, it makes replicating the behavior of grab bag "script" directories marginally more annoying, but I can just have each "script" actually be a tiny bash script that invokes the actual Scala code which is within its own directory. I already have to do this for various reasons so it's not that bad.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    IDEbspIssues tied to the implementation of BSP (Build Server Protocol)enhancementNew feature or requestscriptingIssues tied to *.sc script inputs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions