aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--WORKSPACE2
-rwxr-xr-xcompile.sh1
-rw-r--r--tools/build_defs/scala/README.md270
-rw-r--r--tools/build_defs/scala/scala.bzl333
-rw-r--r--tools/build_defs/scala/test/BUILD82
-rw-r--r--tools/build_defs/scala/test/Exported.scala11
-rw-r--r--tools/build_defs/scala/test/HelloLib.scala17
-rw-r--r--tools/build_defs/scala/test/HelloLibTest.scala16
-rw-r--r--tools/build_defs/scala/test/JavaBinary.java22
-rw-r--r--tools/build_defs/scala/test/OtherJavaLib.java22
-rw-r--r--tools/build_defs/scala/test/OtherLib.scala10
-rw-r--r--tools/build_defs/scala/test/Runtime.scala5
-rw-r--r--tools/build_defs/scala/test/ScalaBinary.scala7
-rw-r--r--tools/build_defs/scala/test/src/main/resources/scala/test/hellos3
-rw-r--r--tools/build_defs/scala/test/src/main/scala/scala/test/ScalaLibBinary.scala7
-rw-r--r--tools/build_defs/scala/test/src/main/scala/scala/test/ScalaLibResources.scala5
16 files changed, 31 insertions, 782 deletions
diff --git a/WORKSPACE b/WORKSPACE
index 1dbec6ce95..e1d6be54e7 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -2,7 +2,6 @@ load("/tools/build_defs/d/d", "d_repositories")
load("/tools/build_defs/dotnet/csharp", "csharp_repositories")
load("/tools/build_defs/jsonnet/jsonnet", "jsonnet_repositories")
load("/tools/build_defs/sass/sass", "sass_repositories")
-load("/tools/build_defs/scala/scala", "scala_repositories")
load("/tools/build_rules/go/def", "go_repositories")
load("/tools/build_rules/rust/rust", "rust_repositories")
@@ -12,7 +11,6 @@ go_repositories()
jsonnet_repositories()
rust_repositories()
sass_repositories()
-scala_repositories()
# Bind to dummy targets if no android SDK/NDK is present.
bind(
diff --git a/compile.sh b/compile.sh
index 341a163416..485d54c5fa 100755
--- a/compile.sh
+++ b/compile.sh
@@ -154,7 +154,6 @@ if [ $DO_TESTS ]; then
${EXTRA_BAZEL_ARGS} \
--javacopt="-source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
-k --test_output=errors //src/... //third_party/ijar/... //scripts/... \
- //tools/build_defs/scala/test/... \
|| fail "Tests failed"
fi
diff --git a/tools/build_defs/scala/README.md b/tools/build_defs/scala/README.md
index 20b40eadfe..542e018555 100644
--- a/tools/build_defs/scala/README.md
+++ b/tools/build_defs/scala/README.md
@@ -1,271 +1,3 @@
# Scala Rules for Bazel
-<div class="toc">
- <h2>Rules</h2>
- <ul>
- <li><a href="#scala_library">scala_library/scala_macro_library</a></li>
- <li><a href="#scala_binary">scala_binary</a></li>
- <li><a href="#scala_test">scala_test</a></li>
- </ul>
-</div>
-
-## Overview
-
-This rule is used for building [Scala][scala] projects with Bazel. There are
-currently four rules, `scala_library`, `scala_macro_library`, `scala_binary`
-and `scala_test`.
-
-In order to use `scala_library`, `scala_macro_library`, and `scala_binary`,
-you must add the following to your WORKSPACE file:
-```python
-load("@bazel_tools//tools/build_defs/scala:scala.bzl", "scala_repositories")
-scala_repositories()
-```
-
-[scala]: http://www.scala-lang.org/
-
-<a name="scala_library"></a>
-## scala\_library / scala\_macro_library
-
-```python
-scala_library(name, srcs, deps, runtime_deps, exports, data, main_class, resources, scalacopts, jvm_flags)
-scala_macro_library(name, srcs, deps, runtime_deps, exports, data, main_class, resources, scalacopts, jvm_flags)
-```
-
-`scala_library` generates a `.jar` file from `.scala` source files. This rule
-also creates an interface jar to avoid recompiling downstream targets unless
-then interface changes.
-
-`scala_macro_library` generates a `.jar` file from `.scala` source files when
-they contain macros. For macros, there are no interface jars because the macro
-code is executed at compile time. For best performance, you want very granular
-targets until such time as the zinc incremental compiler can be supported.
-
-In order to make a java rule use this jar file, use the `java_import` rule.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <p><code>Name, required</code></p>
- <p>A unique name for this target</p>
- </td>
- </tr>
- <td><code>srcs</code></td>
- <td>
- <p><code>List of labels, required</code></p>
- <p>List of Scala <code>.scala</code> source files used to build the
- library</p>
- </td>
- </tr>
- <tr>
- <td><code>deps</code></td>
- <td>
- <p><code>List of labels, optional</code></p>
- <p>List of other libraries to linked to this library target</p>
- </td>
- </tr>
- <tr>
- <td><code>runtime_deps</code></td>
- <td>
- <p><code>List of labels, optional</code></p>
- <p>List of other libraries to put on the classpath only at runtime. This is rarely needed in Scala.</p>
- </td>
- </tr>
- <tr>
- <td><code>exports</code></td>
- <td>
- <p><code>List of labels, optional</code></p>
- <p>List of targets to add to the dependencies of those that depend on this target. Similar
- to the `java_library` parameter of the same name. Use this sparingly as it weakens the
- precision of the build graph.</p>
- </td>
- </tr>
- <tr>
- <td><code>data</code></td>
- <td>
- <p><code>List of labels, optional</code></p>
- <p>List of files needed by this rule at runtime.</p>
- </td>
- </tr>
- <tr>
- <td><code>main_class</code></td>
- <td>
- <p><code>String, optional</code></p>
- <p>Name of class with main() method to use as an entry point</p>
- <p>
- The value of this attribute is a class name, not a source file. The
- class must be available at runtime: it may be compiled by this rule
- (from <code>srcs</code>) or provided by direct or transitive
- dependencies (through <code>deps</code>). If the class is unavailable,
- the binary will fail at runtime; there is no build-time check.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>resources</code></td>
- <td>
- <p><code>List of labels; optional</code></p>
- <p>A list of data files to be included in the JAR.</p>
- </td>
- </tr>
- <tr>
- <td><code>scalacopts</code></td>
- <td>
- <p><code>List of strings; optional</code></p>
- <p>
- Extra compiler options for this library to be passed to scalac. Subject to
- <a href="http://bazel.io/docs/be/make-variables.html">Make variable
- substitution</a> and
- <a href="http://bazel.io/docs/be/common-definitions.html#borne-shell-tokenization">Bourne shell tokenization.</a>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>jvm_flags</code></td>
- <td>
- <p><code>List of strings; optional</code></p>
- <p>
- List of JVM flags to be passed to scalac after the
- <code>scalacopts</code>. Subject to
- <a href="http://bazel.io/docs/be/make-variables.html">Make variable
- substitution</a> and
- <a href="http://bazel.io/docs/be/common-definitions.html#borne-shell-tokenization">Bourne shell tokenization.</a>
- </p>
- </td>
- </tr>
- </tbody>
-</table>
-
-<a name="scala_binary"></a>
-## scala_binary
-
-```python
-scala_binary(name, srcs, deps, runtime_deps, data, main_class, resources, scalacopts, jvm_flags)
-```
-
-`scala_binary` generates a Scala executable. It may depend on `scala_library`, `scala_macro_library`
-and `java_library` rules.
-
-A `scala_binary` requires a `main_class` attribute.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <p><code>Name, required</code></p>
- <p>A unique name for this target</p>
- </td>
- </tr>
- <td><code>srcs</code></td>
- <td>
- <p><code>List of labels, required</code></p>
- <p>List of Scala <code>.scala</code> source files used to build the
- binary</p>
- </td>
- </tr>
- <tr>
- <td><code>deps</code></td>
- <td>
- <p><code>List of labels, optional</code></p>
- <p>List of other libraries to linked to this binary target</p>
- </td>
- </tr>
- <tr>
- <td><code>runtime_deps</code></td>
- <td>
- <p><code>List of labels, optional</code></p>
- <p>List of other libraries to put on the classpath only at runtime. This is rarely needed in Scala.</p>
- </td>
- </tr>
- <tr>
- <td><code>data</code></td>
- <td>
- <p><code>List of labels, optional</code></p>
- <p>List of files needed by this rule at runtime.</p>
- </td>
- </tr>
- <tr>
- <td><code>main_class</code></td>
- <td>
- <p><code>String, optional</code></p>
- <p>Name of class with main() method to use as an entry point</p>
- <p>
- The value of this attribute is a class name, not a source file. The
- class must be available at runtime: it may be compiled by this rule
- (from <code>srcs</code>) or provided by direct or transitive
- dependencies (through <code>deps</code>). If the class is unavailable,
- the binary will fail at runtime; there is no build-time check.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>resources</code></td>
- <td>
- <p><code>List of labels; optional</code></p>
- <p>A list of data files to be included in the JAR.</p>
- </td>
- </tr>
- <tr>
- <td><code>scalacopts</code></td>
- <td>
- <p><code>List of strings; optional</code></p>
- <p>
- Extra compiler options for this binary to be passed to scalac. Subject to
- <a href="http://bazel.io/docs/be/make-variables.html">Make variable
- substitution</a> and
- <a href="http://bazel.io/docs/be/common-definitions.html#borne-shell-tokenization">Bourne shell tokenization.</a>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>jvm_flags</code></td>
- <td>
- <p><code>List of strings; optional</code></p>
- <p>
- List of JVM flags to be passed to scalac after the
- <code>scalacopts</code>. Subject to
- <a href="http://bazel.io/docs/be/make-variables.html">Make variable
- substitution</a> and
- <a href="http://bazel.io/docs/be/common-definitions.html#borne-shell-tokenization">Bourne shell tokenization.</a>
- </p>
- </td>
- </tr>
- </tbody>
-</table>
-
-<a name="scala_test"></a>
-## scala_test
-
-```python
-scala_test(name, srcs, suites, deps, data, main_class, resources, scalacopts, jvm_flags)
-```
-
-`scala_test` generates a Scala executable which runs unit test suites written
-using the `scalatest` library. It may depend on `scala_library`,
-`scala_macro_library` and `java_library` rules.
-
-A `scala_test` requires a `suites` attribute, specifying the fully qualified
-(canonical) names of the test suites to run. In a future version, we might
-investigate lifting this requirement.
-
+This has page has moved to [bazelbuid/rules_scala](https://github.com/bazelbuild/rules_scala/blob/master/README.md).
diff --git a/tools/build_defs/scala/scala.bzl b/tools/build_defs/scala/scala.bzl
index 6824249953..5175fe35dc 100644
--- a/tools/build_defs/scala/scala.bzl
+++ b/tools/build_defs/scala/scala.bzl
@@ -14,317 +14,44 @@
"""Rules for supporting the Scala language."""
+load(
+ "@io_bazel_rules_scala//scala:scala.bzl",
+ orig_scala_library="scala_library",
+ orig_scala_macro_library="scala_macro_library",
+ orig_scala_binary="scala_binary",
+ orig_scala_test="scala_test",
+ orig_scala_repositories="scala_repositories",
+)
-_scala_filetype = FileType([".scala"])
-
-def _adjust_resources_path(path):
- dir_1, dir_2, rel_path = path.partition("resources")
- if rel_path:
- return dir_1 + dir_2, rel_path
- (dir_1,dir_2,rel_path) = path.partition("java")
- if rel_path:
- return dir_1 + dir_2, rel_path
- return "", path
-
-def _compile(ctx, jars, buildijar):
- res_cmd = ""
- for f in ctx.files.resources:
- c_dir, res_path = _adjust_resources_path(f.path)
- change_dir = "-C " + c_dir if c_dir else ""
- res_cmd = "\n{jar} uf {out} " + change_dir + " " + res_path
- ijar_cmd = ""
- if buildijar:
- ijar_cmd = "\n{ijar} {out} {ijar_out}".format(
- ijar=ctx.file._ijar.path,
- out=ctx.outputs.jar.path,
- ijar_out=ctx.outputs.ijar.path)
- cmd = """
-set -e
-mkdir -p {out}_tmp
-{scalac} {scala_opts} {jvm_flags} -classpath "{jars}" $@ -d {out}_tmp
-# Make jar file deterministic by setting the timestamp of files
-find {out}_tmp -exec touch -t 198001010000 {{}} \;
-touch -t 198001010000 {manifest}
-{jar} cmf {manifest} {out} -C {out}_tmp .
-""" + ijar_cmd + res_cmd
- cmd = cmd.format(
- scalac=ctx.file._scalac.path,
- scala_opts=" ".join(ctx.attr.scalacopts),
- jvm_flags=" ".join(["-J" + flag for flag in ctx.attr.jvm_flags]),
- out=ctx.outputs.jar.path,
- manifest=ctx.outputs.manifest.path,
- jar=ctx.file._jar.path,
- ijar=ctx.file._ijar.path,
- jars=":".join([j.path for j in jars]),)
- outs = [ctx.outputs.jar]
- if buildijar:
- outs.extend([ctx.outputs.ijar])
- ctx.action(
- inputs=list(jars) +
- ctx.files.srcs +
- ctx.files.resources +
- ctx.files._jdk +
- ctx.files._scalasdk +
- [ctx.outputs.manifest, ctx.file._jar, ctx.file._ijar],
- outputs=outs,
- command=cmd,
- progress_message="scala %s" % ctx.label,
- arguments=[f.path for f in ctx.files.srcs])
-
-def _write_manifest(ctx):
- # TODO(bazel-team): I don't think this classpath is what you want
- manifest = "Class-Path: %s\n" % ctx.file._scalalib.path
- if getattr(ctx.attr, "main_class", ""):
- manifest += "Main-Class: %s\n" % ctx.attr.main_class
-
- ctx.file_action(
- output = ctx.outputs.manifest,
- content = manifest)
-
-
-def _write_launcher(ctx, jars):
- content = """#!/bin/bash
-cd $0.runfiles
-{java} -cp {cp} {name} "$@"
-"""
- content = content.format(
- java=ctx.file._java.path,
- name=ctx.attr.main_class,
- deploy_jar=ctx.outputs.jar.path,
- cp=":".join([j.short_path for j in jars]))
- ctx.file_action(
- output=ctx.outputs.executable,
- content=content)
-
-def _args_for_suites(suites):
- args = ["-o"]
- for suite in suites:
- args.extend(["-s", suite])
- return args
-
-def _write_test_launcher(ctx, jars):
- content = """#!/bin/bash
-cd $0.runfiles
-{java} -cp {cp} {name} {args} "$@"
-"""
- content = content.format(
- java=ctx.file._java.path,
- name=ctx.attr.main_class,
- args=' '.join(_args_for_suites(ctx.attr.suites)),
- deploy_jar=ctx.outputs.jar.path,
- cp=":".join([j.short_path for j in jars]))
- ctx.file_action(
- output=ctx.outputs.executable,
- content=content)
-
-def _collect_jars(targets):
- """Compute the runtime and compile-time dependencies from the given targets"""
- compile_jars = set() # not transitive
- runtime_jars = set() # this is transitive
- for target in targets:
- found = False
- if hasattr(target, "scala"):
- compile_jars += [target.scala.outputs.ijar]
- compile_jars += target.scala.transitive_compile_exports
- runtime_jars += target.scala.transitive_runtime_deps
- runtime_jars += target.scala.transitive_runtime_exports
- found = True
- if hasattr(target, "java"):
- # see JavaSkylarkApiProvider.java, this is just the compile-time deps
- # this should be improved in bazel 0.1.5 to get outputs.ijar
- # compile_jars += [target.java.outputs.ijar]
- compile_jars += target.java.transitive_deps
- runtime_jars += target.java.transitive_runtime_deps
- found = True
- if not found:
- # support http_file pointed at a jar. http_jar uses ijar, which breaks scala macros
- runtime_jars += target.files
- compile_jars += target.files
- return struct(compiletime = compile_jars, runtime = runtime_jars)
-
-def _lib(ctx, use_ijar):
- jars = _collect_jars(ctx.attr.deps)
- (cjars, rjars) = (jars.compiletime, jars.runtime)
- _write_manifest(ctx)
- _compile(ctx, cjars, use_ijar)
-
- rjars += [ctx.outputs.jar]
- rjars += _collect_jars(ctx.attr.runtime_deps).runtime
-
- ijar = None
- if use_ijar:
- ijar = ctx.outputs.ijar
- else:
- # macro code needs to be available at compile-time, so set ijar == jar
- ijar = ctx.outputs.jar
-
- texp = _collect_jars(ctx.attr.exports)
- scalaattr = struct(outputs = struct(ijar=ijar, class_jar=ctx.outputs.jar),
- transitive_runtime_deps = rjars,
- transitive_compile_exports = texp.compiletime,
- transitive_runtime_exports = texp.runtime
- )
- runfiles = ctx.runfiles(
- files = list(rjars),
- collect_data = True)
- return struct(
- scala = scalaattr,
- runfiles=runfiles)
-
-def _scala_library_impl(ctx):
- return _lib(ctx, True)
-
-def _scala_macro_library_impl(ctx):
- return _lib(ctx, False) # don't build the ijar for macros
-
-# Common code shared by all scala binary implementations.
-def _scala_binary_common(ctx, cjars, rjars):
- _write_manifest(ctx)
- _compile(ctx, cjars, False) # no need to build an ijar for an executable
-
- runfiles = ctx.runfiles(
- files = list(rjars) + [ctx.outputs.executable] + [ctx.file._java] + ctx.files._jdk,
- collect_data = True)
- return struct(
- files=set([ctx.outputs.executable]),
- runfiles=runfiles)
-
-def _scala_binary_impl(ctx):
- jars = _collect_jars(ctx.attr.deps)
- (cjars, rjars) = (jars.compiletime, jars.runtime)
- cjars += [ctx.file._scalareflect]
- rjars += [ctx.outputs.jar, ctx.file._scalalib, ctx.file._scalareflect]
- rjars += _collect_jars(ctx.attr.runtime_deps).runtime
- _write_launcher(ctx, rjars)
- return _scala_binary_common(ctx, cjars, rjars)
-
-def _scala_test_impl(ctx):
- jars = _collect_jars(ctx.attr.deps)
- (cjars, rjars) = (jars.compiletime, jars.runtime)
- cjars += [ctx.file._scalareflect, ctx.file._scalatest, ctx.file._scalaxml]
- rjars += [ctx.outputs.jar, ctx.file._scalalib, ctx.file._scalareflect, ctx.file._scalatest, ctx.file._scalaxml]
- rjars += _collect_jars(ctx.attr.runtime_deps).runtime
- _write_test_launcher(ctx, rjars)
- return _scala_binary_common(ctx, cjars, rjars)
+def warning(rule):
+ return """This rule has moved out of @bazel_tools!
-_implicit_deps = {
- "_ijar": attr.label(executable=True, default=Label("//tools/defaults:ijar"), single_file=True, allow_files=True),
- "_scalac": attr.label(executable=True, default=Label("@scala//:bin/scalac"), single_file=True, allow_files=True),
- "_scalalib": attr.label(default=Label("@scala//:lib/scala-library.jar"), single_file=True, allow_files=True),
- "_scalaxml": attr.label(default=Label("@scala//:lib/scala-xml_2.11-1.0.4.jar"), single_file=True, allow_files=True),
- "_scalasdk": attr.label(default=Label("@scala//:sdk"), allow_files=True),
- "_scalareflect": attr.label(default=Label("@scala//:lib/scala-reflect.jar"), single_file=True, allow_files=True),
- "_jar": attr.label(executable=True, default=Label("@bazel_tools//tools/jdk:jar"), single_file=True, allow_files=True),
- "_jdk": attr.label(default=Label("//tools/defaults:jdk"), allow_files=True),
-}
+The scala rules have moved to https://github.com/bazelbuild/scala_rules, you
+should now refer them via @io_bazel_rules_scala, use:
-# Common attributes reused across multiple rules.
-_common_attrs = {
- "srcs": attr.label_list(
- allow_files=_scala_filetype,
- non_empty=True),
- "deps": attr.label_list(),
- "runtime_deps": attr.label_list(),
- "data": attr.label_list(allow_files=True, cfg=DATA_CFG),
- "resources": attr.label_list(allow_files=True),
- "scalacopts":attr.string_list(),
- "jvm_flags": attr.string_list(),
-}
+load('@io_bazel_rules_scala//scala:scala.bzl', '%s')
-scala_library = rule(
- implementation=_scala_library_impl,
- attrs={
- "main_class": attr.string(),
- "exports": attr.label_list(allow_files=False),
- } + _implicit_deps + _common_attrs,
- outputs={
- "jar": "%{name}_deploy.jar",
- "ijar": "%{name}_ijar.jar",
- "manifest": "%{name}_MANIFEST.MF",
- },
-)
+instead of:
-scala_macro_library = rule(
- implementation=_scala_macro_library_impl,
- attrs={
- "main_class": attr.string(),
- "exports": attr.label_list(allow_files=False),
- "_scala-reflect": attr.label(default=Label("@scala//:lib/scala-reflect.jar"), single_file=True, allow_files=True),
- } + _implicit_deps + _common_attrs,
- outputs={
- "jar": "%{name}_deploy.jar",
- "manifest": "%{name}_MANIFEST.MF",
- },
-)
+load('@bazel_tools//tools/build_defs/scala:scala.bzl', '%s')
+""" % (rule, rule)
-scala_binary = rule(
- implementation=_scala_binary_impl,
- attrs={
- "main_class": attr.string(mandatory=True),
- "_java": attr.label(executable=True, default=Label("@bazel_tools//tools/jdk:java"), single_file=True, allow_files=True),
- } + _implicit_deps + _common_attrs,
- outputs={
- "jar": "%{name}_deploy.jar",
- "manifest": "%{name}_MANIFEST.MF",
- },
- executable=True,
-)
+def scala_library(**kwargs):
+ print(warning("scala_library")
+ original_scala_library(**kwargs):
-scala_test = rule(
- implementation=_scala_test_impl,
- attrs={
- "main_class": attr.string(default="org.scalatest.tools.Runner"),
- "suites": attr.string_list(non_empty=True, mandatory=True),
- "_scalatest": attr.label(executable=True, default=Label("@scalatest//file"), single_file=True, allow_files=True),
- "_java": attr.label(executable=True, default=Label("@bazel_tools//tools/jdk:java"), single_file=True, allow_files=True),
- } + _implicit_deps + _common_attrs,
- outputs={
- "jar": "%{name}_deploy.jar",
- "manifest": "%{name}_MANIFEST.MF",
- },
- executable=True,
- test=True,
-)
+def scala_macro_library(**kwargs):
+ print(warning("scala_macro_library")
+ orig_scala_macro_library(**kwargs):
-SCALA_BUILD_FILE = """
-# scala.BUILD
-exports_files([
- "bin/scala",
- "bin/scalac",
- "bin/scaladoc",
- "lib/akka-actor_2.11-2.3.10.jar",
- "lib/config-1.2.1.jar",
- "lib/jline-2.12.1.jar",
- "lib/scala-actors-2.11.0.jar",
- "lib/scala-actors-migration_2.11-1.1.0.jar",
- "lib/scala-compiler.jar",
- "lib/scala-continuations-library_2.11-1.0.2.jar",
- "lib/scala-continuations-plugin_2.11.7-1.0.2.jar",
- "lib/scala-library.jar",
- "lib/scala-parser-comscala-2.11.7/binators_2.11-1.0.4.jar",
- "lib/scala-reflect.jar",
- "lib/scala-swing_2.11-1.0.2.jar",
- "lib/scala-xml_2.11-1.0.4.jar",
- "lib/scalap-2.11.7.jar",
-])
+def scala_binary(**kwargs):
+ print(warning("scala_binary"))
+ original_scala_binary(**kwargs):
-filegroup(
- name = "sdk",
- srcs = glob(["**"]),
- visibility = ["//visibility:public"],
-)
-"""
+def scala_test(**kwargs):
+ print(warning("scala_test"))
+ original_scala_test(**kwargs):
def scala_repositories():
- native.new_http_archive(
- name = "scala",
- strip_prefix = "scala-2.11.7",
- sha256 = "ffe4196f13ee98a66cf54baffb0940d29432b2bd820bd0781a8316eec22926d0",
- url = "https://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz",
- build_file_content = SCALA_BUILD_FILE,
- )
- native.http_file(
- name = "scalatest",
- url = "https://oss.sonatype.org/content/groups/public/org/scalatest/scalatest_2.11/2.2.6/scalatest_2.11-2.2.6.jar",
- sha256 = "f198967436a5e7a69cfd182902adcfbcb9f2e41b349e1a5c8881a2407f615962",
- )
+ print(warning("scala_repositories"))
+ original_scala_repositories()
diff --git a/tools/build_defs/scala/test/BUILD b/tools/build_defs/scala/test/BUILD
deleted file mode 100644
index 4ef5e95ba7..0000000000
--- a/tools/build_defs/scala/test/BUILD
+++ /dev/null
@@ -1,82 +0,0 @@
-load("//tools/build_defs/scala:scala.bzl", "scala_binary", "scala_library", "scala_test")
-
-# The examples below show how to combine Scala and Java rules.
-# ScalaBinary is the Scala equivalent of JavaBinary.
-
-java_binary(
- name = "JavaBinary",
- srcs = ["JavaBinary.java"],
- main_class = "scala.test.JavaBinary",
- deps = [":lib_import"],
-)
-
-# TODO(bazel-team): Allow java rules to depend directly on scala_library.
-# For now, we have to use a java_import proxy.
-java_import(
- name = "lib_import",
- jars = [":HelloLib_deploy.jar"],
-)
-
-scala_binary(
- name = "ScalaBinary",
- srcs = ["ScalaBinary.scala"],
- main_class = "scala.test.ScalaBinary",
- deps = [":HelloLib"],
-)
-
-scala_library(
- name = "HelloLib",
- srcs = ["HelloLib.scala"],
- deps = [
- "OtherJavaLib",
- "OtherLib",
- ],
-)
-
-scala_test(
- name = "HelloLibTest",
- size = "small", # Not a macro, can pass test-specific attributes.
- srcs = ["HelloLibTest.scala"],
- suites = [
- "scala.test.ScalaSuite",
- "scala.test.JavaSuite",
- ],
- deps = [
- ":HelloLib",
- ],
-)
-
-scala_library(
- name = "OtherLib",
- srcs = ["OtherLib.scala"],
- exports = ["Exported"], # test of exported target
-)
-
-scala_library(
- name = "Exported",
- srcs = ["Exported.scala"],
- runtime_deps = ["Runtime"],
-)
-
-scala_library(
- name = "Runtime",
- srcs = ["Runtime.scala"],
-)
-
-java_library(
- name = "OtherJavaLib",
- srcs = ["OtherJavaLib.java"],
-)
-
-scala_library(
- name = "ScalaLibResources",
- srcs = ["src/main/scala/scala/test/ScalaLibResources.scala"],
- resources = ["src/main/resources/scala/test/hellos"],
-)
-
-scala_binary(
- name = "ScalaLibBinary",
- srcs = ["src/main/scala/scala/test/ScalaLibBinary.scala"],
- main_class = "scala.test.ScalaLibBinary",
- deps = ["ScalaLibResources"],
-)
diff --git a/tools/build_defs/scala/test/Exported.scala b/tools/build_defs/scala/test/Exported.scala
deleted file mode 100644
index 82264ec5de..0000000000
--- a/tools/build_defs/scala/test/Exported.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-package scala.test
-
-object Exported {
- def message: String = {
- // terrible, don't do this in real code:
- val msg = Class.forName("scala.test.Runtime")
- .newInstance
- .toString
- "you all, everybody. " + msg
- }
-}
diff --git a/tools/build_defs/scala/test/HelloLib.scala b/tools/build_defs/scala/test/HelloLib.scala
deleted file mode 100644
index 974c8b7298..0000000000
--- a/tools/build_defs/scala/test/HelloLib.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-package scala.test
-
-object HelloLib {
- def printMessage(arg: String) {
- println(getOtherLibMessage(arg))
- println(getOtherJavaLibMessage(arg))
- println(Exported.message)
- }
-
- def getOtherLibMessage(arg: String) : String = {
- arg + " " + OtherLib.getMessage()
- }
-
- def getOtherJavaLibMessage(arg: String) : String = {
- arg + " " + OtherJavaLib.getMessage()
- }
-}
diff --git a/tools/build_defs/scala/test/HelloLibTest.scala b/tools/build_defs/scala/test/HelloLibTest.scala
deleted file mode 100644
index 7f5cb5f9b7..0000000000
--- a/tools/build_defs/scala/test/HelloLibTest.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-package scala.test
-
-import org.scalatest._
-
-class ScalaSuite extends FlatSpec {
- "HelloLib" should "call scala" in {
- assert(HelloLib.getOtherLibMessage("hello").equals("hello scala!"))
- }
-}
-
-class JavaSuite extends FlatSpec {
- "HelloLib" should "call java" in {
- assert(HelloLib.getOtherJavaLibMessage("hello").equals("hello java!"))
- }
-}
-
diff --git a/tools/build_defs/scala/test/JavaBinary.java b/tools/build_defs/scala/test/JavaBinary.java
deleted file mode 100644
index 9233f4a7de..0000000000
--- a/tools/build_defs/scala/test/JavaBinary.java
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package scala.test;
-
-/** Example class */
-public class JavaBinary {
- public static void main(String[] args) {
- HelloLib.printMessage("Hello");
- }
-}
diff --git a/tools/build_defs/scala/test/OtherJavaLib.java b/tools/build_defs/scala/test/OtherJavaLib.java
deleted file mode 100644
index 53cce195cd..0000000000
--- a/tools/build_defs/scala/test/OtherJavaLib.java
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package scala.test;
-
-/** Example class */
-public class OtherJavaLib {
- public static String getMessage() {
- return "java!";
- }
-}
diff --git a/tools/build_defs/scala/test/OtherLib.scala b/tools/build_defs/scala/test/OtherLib.scala
deleted file mode 100644
index 2f69f68a7b..0000000000
--- a/tools/build_defs/scala/test/OtherLib.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-package scala.test
-
-// It is just to show how a Scala library can depend on another Scala library.
-object OtherLib {
- def getMessage(): String = {
- // This won't compile because Exported is exported, not a dep:
- // Exported.message
- "scala!"
- }
-}
diff --git a/tools/build_defs/scala/test/Runtime.scala b/tools/build_defs/scala/test/Runtime.scala
deleted file mode 100644
index e64c06d82b..0000000000
--- a/tools/build_defs/scala/test/Runtime.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package scala.test
-
-class Runtime {
- override def toString = "I am Runtime"
-}
diff --git a/tools/build_defs/scala/test/ScalaBinary.scala b/tools/build_defs/scala/test/ScalaBinary.scala
deleted file mode 100644
index 5b023a97de..0000000000
--- a/tools/build_defs/scala/test/ScalaBinary.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-package scala.test
-
-object ScalaBinary {
- def main(args: Array[String]) {
- HelloLib.printMessage("Hello");
- }
-}
diff --git a/tools/build_defs/scala/test/src/main/resources/scala/test/hellos b/tools/build_defs/scala/test/src/main/resources/scala/test/hellos
deleted file mode 100644
index 2d28d85dd5..0000000000
--- a/tools/build_defs/scala/test/src/main/resources/scala/test/hellos
+++ /dev/null
@@ -1,3 +0,0 @@
-Hello
-Guten Tag
-Bonjour
diff --git a/tools/build_defs/scala/test/src/main/scala/scala/test/ScalaLibBinary.scala b/tools/build_defs/scala/test/src/main/scala/scala/test/ScalaLibBinary.scala
deleted file mode 100644
index 58f1a2a9cf..0000000000
--- a/tools/build_defs/scala/test/src/main/scala/scala/test/ScalaLibBinary.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-package scala.test
-
-object ScalaLibBinary {
- def main(args:Array[String]) {
- ScalaLibResources.getGreetings foreach println
- }
-}
diff --git a/tools/build_defs/scala/test/src/main/scala/scala/test/ScalaLibResources.scala b/tools/build_defs/scala/test/src/main/scala/scala/test/ScalaLibResources.scala
deleted file mode 100644
index d2086e6d0f..0000000000
--- a/tools/build_defs/scala/test/src/main/scala/scala/test/ScalaLibResources.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package scala.test
-
-object ScalaLibResources {
- def getGreetings() = scala.io.Source.fromInputStream(getClass.getResourceAsStream("hellos")).getLines.toList
-}