-
-
Notifications
You must be signed in to change notification settings - Fork 287
Introduce Scala config #1133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce Scala config #1133
Conversation
scala_config.bzl
Outdated
return "2.12.11" | ||
|
||
def _store_config(repository_ctx): | ||
bazel_version = versions.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe replace versions.get()
with native.bazel_version
? This is what skylib
does under the hood. As it is now it requires skylib
to be declared before scala_config
. Maybe not an issue though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good point!
README.md
Outdated
@@ -50,8 +50,9 @@ http_archive( | |||
sha256 = "8c48283aeb70e7165af48191b0e39b7434b0368718709d1bced5c3781787d8e7", | |||
) | |||
|
|||
load("@io_bazel_rules_scala//:version.bzl", "bazel_version") | |||
bazel_version(name = "bazel_version") | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually a mistake - I forgot to add documentation text here
}, | ||
) | ||
|
||
def scala_config(scala_version = _default_scala_version()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about scala_config
naming. It contains only versions so maybe versions
would be more appropriate. But as I understand it is a placeholder for other things as well. Maybe just config
as it contains non scala related thing like BAZEL_VERSION
? Either way I'm fine as it is currently. So you can just ignore this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have intentionally named it config to allow other configuration to be stored in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment with a snippet on the PR with what people need to do to upgrade?
@@ -177,7 +171,7 @@ jvm_maven_import_external( | |||
name = "org_typelevel__cats_core", | |||
artifact = scala_mvn_artifact( | |||
"org.typelevel:cats-core:0.9.0", | |||
default_scala_major_version(), | |||
SCALA_MAJOR_VERSION, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change from method to const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to wrap the const inside a function? The default version functions are removed, ant the stored version should be a single source of truth.
Done |
The directions for project setup in README.md are now wrong: the suggested version a2f5852 does not contain scala_config.bzl. This makes it pretty confusing for even a very savvy Bazel user to get started with rules_scala. |
Thanks! Is it only the version that's wrong? cc @liucijus |
I updated to head and fixed the sha, and it seemed to work. Have any good scala tutorials to point me at? :) |
It's a big question and I really don't know why you need it and how much time you want to allocate :) Some Scala exercises (like coding katas) https://www.scala-exercises.org/std_lib/asserts Hope it helps |
Thanks! I've been wanting to learn, so this year I'm planning to do https://adventofcode.com/ in Scala as a forcing function. |
Awesome! Welcome aboard to our community :) |
* Add scala config repository to store global configuration options * Fix example workspace * Add docs * Get bazel version directly * Remove unused skylib load
This is a breaking change!
To support multiple versions of Scala within rules codebase we need a way to check for current Scala version in rule and macro code. For example, to support Scala 2.13 properly we need to be able to pass different scalac opts to some targets. This will allow to do conditionals like this:
In addition, I moved
bazel_version
underscala_config
to simplify thingsrules_scala
users need to configure. It will allow us to add more configuration options with default values without breaking an existing user code.How to upgrade:
In
WORKSPACE
file replacewith
or if non-default Scala version is in use, with explicit Scala version specified: