Skip to content

Add --list-targets to expose the full build matrix #4241

@kubukoz

Description

@kubukoz

When a project declares multiple platforms or Scala versions via //> using platform jvm native or //> using scala 3.6.4 3.5.0, there's no way to discover the full declared matrix without parsing source directives manually.

Use case: Tools that wrap scala-cli (e.g. for reproducible Nix builds) need to know all declared platforms and Scala versions upfront to run export --json --platform <p> --scala-version <v> for each target. Currently the only workaround is to parse //> using platform[s] and //> using scala directives from source files — fragile and duplicating logic that scala-cli already handles internally.

Proposed change: A new subcommand or flag that outputs the full matrix of declared targets as JSON:

$ scala-cli list-targets .
[
  { "platform": "jvm",    "scalaVersion": "3.6.4" },
  { "platform": "native", "scalaVersion": "3.6.4" }
]

This would let external tools enumerate targets and call export --json --platform <p> --scala-version <v> for each, without needing to parse directives themselves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    --crossIssues tied to cross compilation/the --cross option.enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions