Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 32 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
workspace(name = "example")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
Expand All @@ -14,10 +16,10 @@ http_file(

http_file(
name = "ubuntu_20.04_1.3GB",
sha256 = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad",
sha256 = "5035be37a7e9abbdc09f0d257f3e33416c1a0fb322ba860d42d74aa75c3468d4",
urls = [
"https://mirror.math.princeton.edu/pub/ubuntu-iso/focal/ubuntu-20.04.4-live-server-amd64.iso",
"https://mirror.pit.teraswitch.com/ubuntu-releases/focal/ubuntu-20.04.4-live-server-amd64.iso",
"https://mirror.math.princeton.edu/pub/ubuntu-iso/focal/ubuntu-20.04.5-live-server-amd64.iso",
"https://mirror.pit.teraswitch.com/ubuntu-releases/focal/ubuntu-20.04.5-live-server-amd64.iso",
],
)

Expand Down Expand Up @@ -122,3 +124,30 @@ maven_install(
load("@maven//:compat.bzl", "compat_repositories")

compat_repositories()


RULES_SCALA_VERSION = "20220201"

http_archive(
name = "io_bazel_rules_scala",
sha256 = "77a3b9308a8780fff3f10cdbbe36d55164b85a48123033f5e970fdae262e8eb2",
strip_prefix = "rules_scala-%s" % RULES_SCALA_VERSION,
type = "zip",
url = "https://github.com/bazelbuild/rules_scala/archive/%s.zip" % RULES_SCALA_VERSION,
)

load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config()

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")

scala_repositories()

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")

scala_register_toolchains()

load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", "scalatest_toolchain")
scalatest_repositories()
scalatest_toolchain()
13 changes: 13 additions & 0 deletions scala/com/engflow/example/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library", "scala_test")

scala_library(
name = "exampleScala",
srcs = ["ScalaExample.scala"],
#main_class = "com.engflow.example.ScalaExample",
)

scala_test(
name = "exampleScalaTest",
srcs = ["ScalaExampleTest.scala"],
deps = [":exampleScala"],
)
16 changes: 16 additions & 0 deletions scala/com/engflow/example/ScalaExample.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.engflow.example;

object ScalaExample {
def fizzbuzz(i: Int): String = {
if (i % 3 == 0){
if (i % 5 == 0){
return "FizzBuzz";
}
return "Fizz";
} else if (i % 5 == 0){
return "Buzz";
} else {
return Integer.toString(i);
}
}
}
13 changes: 13 additions & 0 deletions scala/com/engflow/example/ScalaExampleTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.engflow.example
import org.scalatest.FunSuite

class ScalaExampleTest extends FunSuite {
test ("engflow scala tests") {
assert("1" == ScalaExample.fizzbuzz(1))
assert("2" == ScalaExample.fizzbuzz(2))
assert("Fizz" == ScalaExample.fizzbuzz(3))
assert("4" == ScalaExample.fizzbuzz(4))
assert("Buzz" == ScalaExample.fizzbuzz(5))
assert("FizzBuzz" == ScalaExample.fizzbuzz(15))
}
}