Skip to content
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

Move scala_binary to its own file #813

Merged
merged 7 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Before you start working on a larger contribution, you should get in touch
with us first. Use the issue tracker to explain your idea so we can help and
possibly guide you.

### Code organization

Core Scala rules (including their implementations) and macros go in [./scala/private/rules/](./scala/private/rules/)
and [./scala/private/macros/](./scala/private/macros/), respectively, and are re-exported for public use
in [./scala/scala.bzl](./scala/scala.bzl).

### Code reviews and other contributions.
**All submissions, including submissions by project members, require review.**
Please follow the instructions in [the contributors documentation](http://bazel.io/contributing.html).
Expand Down
137 changes: 137 additions & 0 deletions scala/private/common_attributes.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
"""Shared attributes for rules"""

load(
"@io_bazel_rules_scala//scala/private:coverage_replacements_provider.bzl",
_coverage_replacements_provider = "coverage_replacements_provider",
)
load(
"@io_bazel_rules_scala//scala:plusone.bzl",
_collect_plus_one_deps_aspect = "collect_plus_one_deps_aspect",
)

common_attrs_for_plugin_bootstrapping = {
"srcs": attr.label_list(allow_files = [
".scala",
".srcjar",
".java",
]),
"deps": attr.label_list(
aspects = [
_collect_plus_one_deps_aspect,
_coverage_replacements_provider.aspect,
],
providers = [[JavaInfo]],
),
"plugins": attr.label_list(allow_files = [".jar"]),
"runtime_deps": attr.label_list(providers = [[JavaInfo]]),
"data": attr.label_list(allow_files = True),
"resources": attr.label_list(allow_files = True),
"resource_strip_prefix": attr.string(),
"resource_jars": attr.label_list(allow_files = True),
"scalacopts": attr.string_list(),
"javacopts": attr.string_list(),
"jvm_flags": attr.string_list(),
"scalac_jvm_flags": attr.string_list(),
"javac_jvm_flags": attr.string_list(),
"expect_java_output": attr.bool(
default = True,
mandatory = False,
),
"print_compile_time": attr.bool(
default = False,
mandatory = False,
),
}

common_attrs = {}

common_attrs.update(common_attrs_for_plugin_bootstrapping)

common_attrs.update({
# using stricts scala deps is done by using command line flag called 'strict_java_deps'
# switching mode to "on" means that ANY API change in a target's transitive dependencies will trigger a recompilation of that target,
# on the other hand any internal change (i.e. on code that ijar omits) WON’T trigger recompilation by transitive dependencies
"_dependency_analyzer_plugin": attr.label(
default = Label(
"@io_bazel_rules_scala//third_party/dependency_analyzer/src/main:dependency_analyzer",
),
allow_files = [".jar"],
mandatory = False,
),
"unused_dependency_checker_mode": attr.string(
values = [
"warn",
"error",
"off",
"",
],
mandatory = False,
),
"_unused_dependency_checker_plugin": attr.label(
default = Label(
"@io_bazel_rules_scala//third_party/unused_dependency_checker/src/main:unused_dependency_checker",
),
allow_files = [".jar"],
mandatory = False,
),
"unused_dependency_checker_ignored_targets": attr.label_list(default = []),
"_code_coverage_instrumentation_worker": attr.label(
default = "@io_bazel_rules_scala//src/java/io/bazel/rulesscala/coverage/instrumenter",
allow_files = True,
executable = True,
cfg = "host",
),
})

implicit_deps = {
"_singlejar": attr.label(
executable = True,
cfg = "host",
default = Label("@bazel_tools//tools/jdk:singlejar"),
allow_files = True,
),
"_zipper": attr.label(
executable = True,
cfg = "host",
default = Label("@bazel_tools//tools/zip:zipper"),
allow_files = True,
),
"_java_toolchain": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_toolchain"),
),
"_host_javabase": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
cfg = "host",
),
"_java_runtime": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
),
"_scalac": attr.label(
default = Label(
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac",
),
),
"_exe": attr.label(
executable = True,
cfg = "host",
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/exe:exe"),
),
}

launcher_template = {
"_java_stub_template": attr.label(
default = Label("@io_bazel_rules_scala//java_stub_template/file"),
),
}

# Single dep to allow IDEs to pickup all the implicit dependencies.
resolve_deps = {
"_scala_toolchain": attr.label_list(
default = [
Label(
"//external:io_bazel_rules_scala/dependency/scala/scala_library",
),
],
allow_files = False,
),
}
8 changes: 8 additions & 0 deletions scala/private/common_outputs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Common outputs used in rule outputs"""

common_outputs = {
"jar": "%{name}.jar",
"deploy_jar": "%{name}_deploy.jar",
"manifest": "%{name}_MANIFEST.MF",
"statsfile": "%{name}.statsfile",
}
Loading