diff --git a/WORKSPACE b/WORKSPACE index c379ca98..45b3fd9d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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") @@ -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", ], ) @@ -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() diff --git a/scala/com/engflow/example/BUILD b/scala/com/engflow/example/BUILD new file mode 100644 index 00000000..4da5450a --- /dev/null +++ b/scala/com/engflow/example/BUILD @@ -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"], +) diff --git a/scala/com/engflow/example/ScalaExample.scala b/scala/com/engflow/example/ScalaExample.scala new file mode 100644 index 00000000..f279f807 --- /dev/null +++ b/scala/com/engflow/example/ScalaExample.scala @@ -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); + } + } +} diff --git a/scala/com/engflow/example/ScalaExampleTest.scala b/scala/com/engflow/example/ScalaExampleTest.scala new file mode 100644 index 00000000..13d8da43 --- /dev/null +++ b/scala/com/engflow/example/ScalaExampleTest.scala @@ -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)) + } +}