bazelbuild / rules_scala

Scala rules for Bazel
Apache License 2.0
359 stars 266 forks source link

Configure rules behaviour/toolchain attributes via build settings #1570

Open simuons opened 2 months ago

simuons commented 2 months ago

Description

Configure rules via build settings instead of attributes on toolchain.

Eventually toolchain should contain only attributes that are scala version specific (ie jars, scalac opts, executables)

For backwards compatibility make this behaviour configurable (ie either use attributes on toolchain or build flags) by //scala/settings:scala_toolchain_flags boolean flag which defaults to false meaning keep current behaviour.

Flags are put under //scala/settings:* with names matching to toolchain attributes.

Motivation

Many scala toolchain attributes are not dependent on scala version, but rather control rules behaviour or enables some features. This becomes more relevant when multiple scala versions are used during the build, which would require setting same attributes to same values for each scala version.

This would prevent having different configs per scala version, but it's doable fairly easily. On the other hand I'm not sure this is needed. For example when strict_deps are enabled most likely it's irrelevant what scala version is used.

TODOS: add docs, add tests, remove toolchains for tests that flip single flag.