-
-
Notifications
You must be signed in to change notification settings - Fork 286
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,15 +26,16 @@ load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_depen | |
|
||
buildifier_dependencies() | ||
|
||
load("@io_bazel_rules_scala//:version.bzl", "bazel_version") | ||
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config") | ||
|
||
bazel_version(name = "bazel_version") | ||
scala_config() | ||
|
||
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") | ||
load("//scala:scala.bzl", "scala_repositories") | ||
|
||
scala_repositories(fetch_sources = True) | ||
|
||
load("//scala:scala_cross_version.bzl", "default_maven_server_urls") | ||
load("//scala:scala_cross_version.bzl", "default_maven_server_urls", "scala_mvn_artifact") | ||
load("//scala:scala_maven_import_external.bzl", "scala_maven_import_external") | ||
load("//twitter_scrooge:twitter_scrooge.bzl", "twitter_scrooge") | ||
|
||
|
@@ -64,13 +65,6 @@ scalafmt_default_config() | |
|
||
scalafmt_repositories() | ||
|
||
load( | ||
"//scala:scala_cross_version.bzl", | ||
"default_scala_major_version", | ||
"default_scala_version", | ||
"scala_mvn_artifact", | ||
) | ||
|
||
MAVEN_SERVER_URLS = default_maven_server_urls() | ||
|
||
# needed for the cross repo proto test | ||
|
@@ -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 commentThe 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 commentThe 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. |
||
), | ||
artifact_sha256 = "3ca705cba9dc0632e60477d80779006f8c636c0e2e229dda3410a0c314c1ea1d", | ||
server_urls = MAVEN_SERVER_URLS, | ||
|
@@ -207,5 +201,4 @@ repositories( | |
"org_spire_math_kind_projector", | ||
], | ||
maven_servers = MAVEN_SERVER_URLS, | ||
scala_version = default_scala_version(), | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
load("@bazel_skylib//lib:versions.bzl", "versions") | ||
load("//scala:scala_cross_version.bzl", "extract_major_version") | ||
|
||
def _default_scala_version(): | ||
"""return the scala version for use in maven coordinates""" | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Maybe replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, good point! |
||
repository_ctx.file("BUILD", "exports_files(['def.bzl'])") | ||
|
||
scala_version = repository_ctx.attr.scala_version | ||
scala_major_version = extract_major_version(scala_version) | ||
|
||
config_file_content = "\n".join([ | ||
"BAZEL_VERSION='" + bazel_version + "'", | ||
"SCALA_VERSION='" + scala_version + "'", | ||
"SCALA_MAJOR_VERSION='" + scala_major_version + "'", | ||
]) | ||
|
||
repository_ctx.file("config.bzl", config_file_content) | ||
|
||
_config_repository = repository_rule( | ||
implementation = _store_config, | ||
attrs = { | ||
"scala_version": attr.string( | ||
mandatory = True, | ||
), | ||
}, | ||
) | ||
|
||
def scala_config(scala_version = _default_scala_version()): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
_config_repository( | ||
name = "io_bazel_rules_scala_config", | ||
scala_version = 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.
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