Skip to content

Commit

Permalink
Add defs.bzl with core rules and notice about evolving APIs (#955)
Browse files Browse the repository at this point in the history
* Add defs.bzl with core rules

* move to unstable directory
  • Loading branch information
andyscott authored Jan 29, 2020
1 parent 5bc432b commit f9c6a4c
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
Empty file added scala/unstable/BUILD
Empty file.
40 changes: 40 additions & 0 deletions scala/unstable/defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Starlark rules for building Scala projects.
These are the core rules under active development. Their APIs are
not guaranteed stable and we anticipate some breaking changes.
We do not recommend using these APIs for production codebases. Instead,
use the stable rules exported by scala.bzl:
```
load(
"@io_bazel_rules_scala//scala:scala.bzl",
"scala_library",
"scala_binary",
"scala_test"
)
```
"""

load(
"@io_bazel_rules_scala//scala/private:rules/scala_binary.bzl",
_make_scala_binary = "make_scala_binary",
)
load(
"@io_bazel_rules_scala//scala/private:rules/scala_library.bzl",
_make_scala_library = "make_scala_library",
)
load(
"@io_bazel_rules_scala//scala/private:rules/scala_test.bzl",
_make_scala_test = "make_scala_test",
)

make_scala_library = _make_scala_library
make_scala_binary = _make_scala_binary
make_scala_test = _make_scala_test

scala_library = _make_scala_library()
scala_binary = _make_scala_binary()
scala_test = _make_scala_test()
27 changes: 27 additions & 0 deletions test/unstable/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load(
"//scala/unstable:defs.bzl",
"scala_binary",
"scala_library",
"scala_test",
)

scala_binary(
name = "binary",
srcs = ["binary.scala"],
main_class = "test.v2.Binary",
deps = [":library"],
)

scala_library(
name = "library",
srcs = ["library.scala"],
deps = [],
)

scala_test(
name = "test",
srcs = ["test.scala"],
deps = [
":library",
],
)
7 changes: 7 additions & 0 deletions test/unstable/binary.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package test.v2

object Binary {
def main(args: Array[String]): Unit = {
println(s"${Library.method1} ${Library.method2}")
}
}
6 changes: 6 additions & 0 deletions test/unstable/library.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package test.v2

object Library {
def method1(): String = "hello"
def method2(): String = "world"
}
13 changes: 13 additions & 0 deletions test/unstable/test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package test.v2

import org.scalatest.FunSuite

class Test extends FunSuite {
test("method1") {
assert(Library.method1 == "hello")
}

test("method2") {
assert(Library.method2 == "world")
}
}

0 comments on commit f9c6a4c

Please sign in to comment.