Skip to content

Scala 2.12 support #300

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

Closed
Closed
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
10 changes: 5 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ specs2_junit_repositories()
# test adding a scala jar:
maven_jar(
name = "com_twitter__scalding_date",
artifact = scala_mvn_artifact("com.twitter:scalding-date:0.16.0-RC4"),
sha1 = "659eb2d42945dea37b310d96af4e12bf83f54d14"
artifact = scala_mvn_artifact("com.twitter:scalding-date:0.17.0"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do the version upgrades in master to minimize the diff?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sha1 = "4fede78a279539a9aa394e54d654b2da8f072eb2"
)

# For testing that we don't include sources jars to the classpath
maven_jar(
name = "org_typelevel__cats_core",
artifact = scala_mvn_artifact("org.typelevel:cats-core:0.9.0"),
sha1 = "b2f8629c6ec834d8b6321288c9fe77823f1e1314"
sha1 = "267cebe07afbb365b08a6e18be4b137508f16bee"
)


# test of a plugin
maven_jar(
name = "org_psywerx_hairyfotr__linter",
artifact = scala_mvn_artifact("org.psywerx.hairyfotr:linter:0.1.13"),
sha1 = "e5b3e2753d0817b622c32aedcb888bcf39e275b4")
artifact = scala_mvn_artifact("org.psywerx.hairyfotr:linter:0.1.17"),
sha1 = "4496d757ce23ce84ff91567bb3328f35c52138af")

# test of strict deps (scalac plugin UT + E2E)
maven_jar(
Expand Down
1 change: 1 addition & 0 deletions scala/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java_library(name = "transitive_scalatest", exports = ["@scalatest//jar", "@scalactic//jar"])
31 changes: 22 additions & 9 deletions scala/scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ scala_repl = rule(

def scala_version():
"""return the scala version for use in maven coordinates"""
return "2.11"
return "2.12"

def scala_mvn_artifact(artifact):
gav = artifact.split(":")
Expand All @@ -985,13 +985,13 @@ SCALA_BUILD_FILE = """
# scala.BUILD
java_import(
name = "scala-xml",
jars = ["lib/scala-xml_2.11-1.0.5.jar"],
jars = ["lib/scala-xml_2.12-1.0.6.jar"],
visibility = ["//visibility:public"],
)

java_import(
name = "scala-parser-combinators",
jars = ["lib/scala-parser-combinators_2.11-1.0.4.jar"],
jars = ["lib/scala-parser-combinators_2.12-1.0.6.jar"],
visibility = ["//visibility:public"],
)

Expand All @@ -1012,22 +1012,35 @@ java_import(
jars = ["lib/scala-reflect.jar"],
visibility = ["//visibility:public"],
)

java_library(
name = "transitive_scalatest",
exports = ["@scalatest//jar", "@scalactic//jar"],
visibility = ["//visibility:public"],
)
"""

def scala_repositories():
native.new_http_archive(
name = "scala",
strip_prefix = "scala-2.11.11",
sha256 = "12037ca64c68468e717e950f47fc77d5ceae5e74e3bdca56f6d02fd5bfd6900b",
url = "https://downloads.lightbend.com/scala/2.11.11/scala-2.11.11.tgz",
strip_prefix = "scala-2.12.3",
sha256 = "2b796ab773fbedcc734ba881a6486d54180b699ade8ba7493e91912044267c8c",
url = "https://downloads.lightbend.com/scala/2.12.3/scala-2.12.3.tgz",
build_file_content = SCALA_BUILD_FILE,
)

# scalatest has macros, note http_jar is invoking ijar
native.http_jar(
name = "scalatest",
url = "http://mirror.bazel.build/oss.sonatype.org/content/groups/public/org/scalatest/scalatest_2.11/2.2.6/scalatest_2.11-2.2.6.jar",
sha256 = "f198967436a5e7a69cfd182902adcfbcb9f2e41b349e1a5c8881a2407f615962",
url = "http://oss.sonatype.org/content/groups/public/org/scalatest/scalatest_2.12/3.0.3/scalatest_2.12-3.0.3.jar",
sha256 = "353f7c2bdde22c4286ee6a3ae0e425a9463b102f4c4cf76055a24f4666996762",
)

# scalatest has macros, note http_jar is invoking ijar
native.http_jar(
name = "scalactic",
url = "https://oss.sonatype.org/content/groups/public/org/scalactic/scalactic_2.12/3.0.3/scalactic_2.12-3.0.3.jar",
sha256 = "245ad1baab6661aee70c137c5e1625771c2624596b349b305801d94618673292",
)

native.maven_server(
Expand Down Expand Up @@ -1065,7 +1078,7 @@ def scala_repositories():

native.bind(name = "io_bazel_rules_scala/dependency/scala/scala_xml", actual = "@scala//:scala-xml")

native.bind(name = "io_bazel_rules_scala/dependency/scalatest/scalatest", actual = "@scalatest//jar")
native.bind(name = "io_bazel_rules_scala/dependency/scalatest/scalatest", actual = "@scala//:transitive_scalatest")

def _sanitize_string_for_usage(s):
res_array = []
Expand Down
28 changes: 14 additions & 14 deletions scala_proto/scala_proto.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def scala_proto_repositories():

native.maven_jar(
name = "scala_proto_rules_scalapb_plugin",
artifact = "com.trueaccord.scalapb:compilerplugin_2.11:0.6.5",
sha1 = "290094c632c95b36b6f66d7dbfdc15242b9a247f",
artifact = "com.trueaccord.scalapb:compilerplugin_2.12:0.6.5",
sha1 = "d119bb24e976dacae8f55a678a027d59bc50ffac",
server = "scala_proto_deps_maven_server",
)

Expand All @@ -33,8 +33,8 @@ def scala_proto_repositories():

native.maven_jar(
name = "scala_proto_rules_protoc_bridge",
artifact = "com.trueaccord.scalapb:protoc-bridge_2.11:0.3.0-M1",
sha1 = "73d38f045ea8f09cc1264991d1064add6eac9e00",
artifact = "com.trueaccord.scalapb:protoc-bridge_2.12:0.3.0-M1",
sha1 = "1de84a8176cf0192b68b2873364e26cb4da61a7a",
server = "scala_proto_deps_maven_server",
)

Expand All @@ -45,8 +45,8 @@ def scala_proto_repositories():

native.maven_jar(
name = "scala_proto_rules_scalapbc",
artifact = "com.trueaccord.scalapb:scalapbc_2.11:0.6.5",
sha1 = "b204d6d56a042b973af5b6fe28f81ece232d1fe4",
artifact = "com.trueaccord.scalapb:scalapbc_2.12:0.6.5",
sha1 = "7dd00d1d5b03be9879194bf917738d69b0126fab",
server = "scala_proto_deps_maven_server",
)

Expand All @@ -57,8 +57,8 @@ def scala_proto_repositories():

native.maven_jar(
name = "scala_proto_rules_scalapb_runtime",
artifact = "com.trueaccord.scalapb:scalapb-runtime_2.11:0.6.5",
sha1 = "ac9287ff48c632df525773570ee4842e3ddf40e9",
artifact = "com.trueaccord.scalapb:scalapb-runtime_2.12:0.6.5",
sha1 = "5375ad64f0cc26b8e8a9377811f9b97645d24bac",
server = "scala_proto_deps_maven_server",
)

Expand All @@ -69,8 +69,8 @@ def scala_proto_repositories():

native.maven_jar(
name = "scala_proto_rules_scalapb_runtime_grpc",
artifact = "com.trueaccord.scalapb:scalapb-runtime-grpc_2.11:0.6.5",
sha1 = "9dc3374001f4190548db36a7dc87bd4f9bca6f9c",
artifact = "com.trueaccord.scalapb:scalapb-runtime-grpc_2.12:0.6.5",
sha1 = "64885c5d96be6ecdfccdb27ca2bdef3ed9ce9fb4",
server = "scala_proto_deps_maven_server",
)

Expand All @@ -81,8 +81,8 @@ def scala_proto_repositories():

native.maven_jar(
name = "scala_proto_rules_scalapb_lenses",
artifact = "com.trueaccord.lenses:lenses_2.11:0.4.12",
sha1 = "c5fbf5b872ce99d9a16d3392ccc0d15a0e43d823",
artifact = "com.trueaccord.lenses:lenses_2.12:0.4.12",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we used scala_mvn_artifact here we wouldn't have this change and others in the file.

sha1 = "d97d2958814bcfe2f19e1ed2f0f03fd9da5a3961",
server = "scala_proto_deps_maven_server",
)

Expand All @@ -93,8 +93,8 @@ def scala_proto_repositories():

native.maven_jar(
name = "scala_proto_rules_scalapb_fastparse",
artifact = "com.lihaoyi:fastparse_2.11:0.4.4",
sha1 = "f065fe0afe6fd2b4557d985c37362c36f08f9947",
artifact = "com.lihaoyi:fastparse_2.12:0.4.4",
sha1 = "aaf2048f9c6223220eac28c9b6a442f27ba83c55",
server = "scala_proto_deps_maven_server",
)

Expand Down
20 changes: 10 additions & 10 deletions specs2/specs2.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ def specs2_repositories():

native.maven_jar(
name = "io_bazel_rules_scala_org_specs2_specs2_core",
artifact = "org.specs2:specs2-core_2.11:" + specs2_version(),
sha1 = "495bed00c73483f4f5f43945fde63c615d03e637",
artifact = "org.specs2:specs2-core_2.12:" + specs2_version(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we used scala_mvn_artifact we wouldn't have this change here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went wholesale on this in #303

sha1 = "86cb72427e64e1423edcbf082e8767a60493bbcc",
)
native.bind(name = 'io_bazel_rules_scala/dependency/specs2/specs2_core', actual = '@io_bazel_rules_scala_org_specs2_specs2_core//jar')

native.maven_jar(
name = "io_bazel_rules_scala_org_specs2_specs2_common",
artifact = "org.specs2:specs2-common_2.11:" + specs2_version(),
sha1 = "15bc009eaae3a574796c0f558d8696b57ae903c3",
artifact = "org.specs2:specs2-common_2.12:" + specs2_version(),
sha1 = "83bd14fb54f81a886901fa7ed136bcf887322440",
)
native.bind(name = 'io_bazel_rules_scala/dependency/specs2/specs2_common', actual = '@io_bazel_rules_scala_org_specs2_specs2_common//jar')

native.maven_jar(
name = "io_bazel_rules_scala_org_specs2_specs2_matcher",
artifact = "org.specs2:specs2-matcher_2.11:" + specs2_version(),
sha1 = "d2e967737abef7421e47b8994a8c92784e624d62",
artifact = "org.specs2:specs2-matcher_2.12:" + specs2_version(),
sha1 = "921d9ef6bf98c3e5a59d535e1139b5522625d6ba",
)
native.bind(name = 'io_bazel_rules_scala/dependency/specs2/specs2_matcher', actual = '@io_bazel_rules_scala_org_specs2_specs2_matcher//jar')

native.maven_jar(
name = "io_bazel_rules_scala_org_scalaz_scalaz_effect",
artifact = "org.scalaz:scalaz-effect_2.11:7.2.7",
sha1 = "824bbb83da12224b3537c354c51eb3da72c435b5",
artifact = "org.scalaz:scalaz-effect_2.12:7.2.7",
sha1 = "5d0bbd74323d8c7467cde95dcdc298eb3d9dcdb1",
)
native.bind(name = 'io_bazel_rules_scala/dependency/scalaz/scalaz_effect', actual = '@io_bazel_rules_scala_org_scalaz_scalaz_effect//jar')

native.maven_jar(
name = "io_bazel_rules_scala_org_scalaz_scalaz_core",
artifact = "org.scalaz:scalaz-core_2.11:7.2.7",
sha1 = "ebf85118d0bf4ce18acebf1d8475ee7deb7f19f1",
artifact = "org.scalaz:scalaz-core_2.12:7.2.7",
sha1 = "ee06c07e856bad6ce112b2a5b96e1df1609ad57f",
)
native.bind(name = 'io_bazel_rules_scala/dependency/scalaz/scalaz_core', actual = '@io_bazel_rules_scala_org_scalaz_scalaz_core//jar')

Expand Down
8 changes: 4 additions & 4 deletions specs2/specs2_junit.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ def specs2_junit_repositories():
junit_repositories()
# Aditional dependencies for specs2 junit runner
native.maven_jar(
name = "io_bazel_rules_scala_org_specs2_specs2_junit_2_11",
artifact = "org.specs2:specs2-junit_2.11:" + specs2_version(),
sha1 = "1dc9e43970557c308ee313842d84094bc6c1c1b5",
name = "io_bazel_rules_scala_org_specs2_specs2_junit_2_12",
artifact = "org.specs2:specs2-junit_2.12:" + specs2_version(),
sha1 = "aa6af850ccd428673add3840652cdd8e82791391",
)
native.bind(name = 'io_bazel_rules_scala/dependency/specs2/specs2_junit', actual = '@io_bazel_rules_scala_org_specs2_specs2_junit_2_11//jar')
native.bind(name = 'io_bazel_rules_scala/dependency/specs2/specs2_junit', actual = '@io_bazel_rules_scala_org_specs2_specs2_junit_2_12//jar')

def specs2_junit_dependencies():
return specs2_dependencies() + ["//external:io_bazel_rules_scala/dependency/specs2/specs2_junit"]
6 changes: 6 additions & 0 deletions src/java/io/bazel/rulesscala/scalac/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ java_binary(
"ScalacProcessor.java",
],
main_class = "io.bazel.rulesscala.scalac.ScalaCInvoker",
# this probably should be set globally for the entire rules_scala
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this needs to be in the scala.bzl?
If so we need to also test that the user gets a clear error message when they request a lower version.
And also they can request a higher version and it's ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a pattern of enforcing minimal Java version on clients of the rule?

# but I don't know how to do it
javacopts = [
"-source 1.8",
"-target 1.8"
],
visibility = ["//visibility:public"],
deps = [
"//src/java/com/google/devtools/build/lib:worker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ object BenchmarkGenerator {
val generator = new JMHGenerator

collectClassesFromJar(benchmarkJarPath).foreach { path =>
// this would fail due to https://github.com/bazelbuild/rules_scala/issues/295
// let's throw a useful message instead
sys.error("jmh in rules_scala doesn't work with Java 8 bytecode: https://github.com/bazelbuild/rules_scala/issues/295")
source.processClass(Files.newInputStream(path))
}
generator.generate(source, destination)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Compiler {
skipIncludes = false,
documentCache
)
parser.logger.setLevel(Level.OFF) // scrooge warns on file names with "/"
parser.logger.setUseParentHandlers(false) // scrooge warns on file names with "/"
val doc = parser.parseFile(inputFile).mapNamespaces(namespaceMappings.toMap)

if (verbose) println("+ Compiling %s".format(inputFile))
Expand Down
4 changes: 2 additions & 2 deletions test/aspect/aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _rule_impl(ctx):
"scala_test" : [
"//test/aspect:scala_test",
"@scala//:scala-library",
"@scalatest//jar:jar",
"@scala//:transitive_scalatest",
],
"scala_junit_test" : [
"//test/aspect:scala_junit_test",
Expand All @@ -52,7 +52,7 @@ def _rule_impl(ctx):
"@scala//:scala-library",
"@scala//:scala-reflect",
# From specs2/specs2_junit.bzl:specs2_junit_dependencies()
"@io_bazel_rules_scala_org_specs2_specs2_junit_2_11//jar:jar",
"@io_bazel_rules_scala_org_specs2_specs2_junit_2_12//jar:jar",
],
}
content = ""
Expand Down
11 changes: 6 additions & 5 deletions test/jmh/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ scala_library(
visibility = ["//visibility:public"],
)

scala_benchmark_jmh(
name = "test_benchmark",
srcs = ["TestBenchmark.scala"],
deps = [":add_numbers"],
)
# Disable the jmh test due to https://github.com/bazelbuild/rules_scala/issues/295
# scala_benchmark_jmh(
# name = "test_benchmark",
# srcs = ["TestBenchmark.scala"],
# deps = [":add_numbers"],
# )
4 changes: 2 additions & 2 deletions tut_rule/tut.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def tut_repositories():

native.maven_jar(
name = "io_bazel_rules_scala_org_tpolecat_tut_core",
artifact = "org.tpolecat:tut-core_2.11:0.4.8",
sha1 = "fc723eb822494580cc05d6b3b3a6039d2280a5a0",
artifact = "org.tpolecat:tut-core_2.12:0.4.8",
sha1 = "b68b5a52474bf249d1156f5002033498054b813c",
server = "tut_repositories_maven_server",
)
native.bind(name = 'io_bazel_rules_scala/dependency/tut/tut_core', actual = '@io_bazel_rules_scala_org_tpolecat_tut_core//jar')
Expand Down
22 changes: 12 additions & 10 deletions twitter_scrooge/twitter_scrooge.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ load("//scala:scala.bzl",
def twitter_scrooge():
native.maven_server(
name = "twitter_scrooge_maven_server",
url = "http://mirror.bazel.build/repo1.maven.org/maven2/",
url = "http://repo1.maven.org/maven2/",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use the Bazel mirror?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can't remember the reason to switch, switched back

)

native.maven_jar(
Expand All @@ -22,33 +22,33 @@ def twitter_scrooge():

native.maven_jar(
name = "scrooge_core",
artifact = scala_mvn_artifact("com.twitter:scrooge-core:4.6.0"),
sha1 = "84b86c2e082aba6e0c780b3c76281703b891a2c8",
artifact = scala_mvn_artifact("com.twitter:scrooge-core:4.18.0"),
sha1 = "8a10e4da9fd636a8225a5068aa0b57072142a30b",
server = "twitter_scrooge_maven_server",
)
native.bind(name = 'io_bazel_rules_scala/dependency/thrift/scrooge_core', actual = '@scrooge_core//jar')

#scrooge-generator related dependencies
native.maven_jar(
name = "scrooge_generator",
artifact = scala_mvn_artifact("com.twitter:scrooge-generator:4.6.0"),
sha1 = "cacf72eedeb5309ca02b2d8325c587198ecaac82",
artifact = scala_mvn_artifact("com.twitter:scrooge-generator:4.18.0"),
sha1 = "d456f18b5c478b6356e2e09f4be4784cd4f05765",
server = "twitter_scrooge_maven_server",
)
native.bind(name = 'io_bazel_rules_scala/dependency/thrift/scrooge_generator', actual = '@scrooge_generator//jar')

native.maven_jar(
name = "util_core",
artifact = scala_mvn_artifact("com.twitter:util-core:6.33.0"),
sha1 = "bb49fa66a3ca9b7db8cd764d0b26ce498bbccc83",
artifact = scala_mvn_artifact("com.twitter:util-core:6.45.0"),
sha1 = "d7bbc819d90d06dfd4c76c25b82869b27048c886",
server = "twitter_scrooge_maven_server",
)
native.bind(name = 'io_bazel_rules_scala/dependency/thrift/util_core', actual = '@util_core//jar')

native.maven_jar(
name = "util_logging",
artifact = scala_mvn_artifact("com.twitter:util-logging:6.33.0"),
sha1 = "3d28e46f8ee3b7ad1b98a51b98089fc01c9755dd",
artifact = scala_mvn_artifact("com.twitter:util-logging:6.45.0"),
sha1 = "b83552e8980557b5dd767de40db1d44c3a39c400",
server = "twitter_scrooge_maven_server",
)
native.bind(name = 'io_bazel_rules_scala/dependency/thrift/util_logging', actual = '@util_logging//jar')
Expand Down Expand Up @@ -260,11 +260,13 @@ def scrooge_scala_library(name, deps=[], remote_jars=[], jvm_flags=[], visibilit
deps = deps + remote_jars + [
srcjar,
"//external:io_bazel_rules_scala/dependency/thrift/libthrift",
"//external:io_bazel_rules_scala/dependency/thrift/scrooge_core"
"//external:io_bazel_rules_scala/dependency/thrift/scrooge_core",
"//external:io_bazel_rules_scala/dependency/thrift/util_core",
],
exports = deps + remote_jars + [
"//external:io_bazel_rules_scala/dependency/thrift/libthrift",
"//external:io_bazel_rules_scala/dependency/thrift/scrooge_core",
"//external:io_bazel_rules_scala/dependency/thrift/util_core",
],
jvm_flags = jvm_flags,
visibility = visibility,
Expand Down