bazel-contrib / bazel-contrib/rules_scala

Issue with scala_specs2_unit_test + --strict_java_deps=ERROR

Open
#338 11 comments 1 reaction 0 assignees View on GitHub
dep-tracking
Dominant language
Starlark
Stars
384
Forks
292
Avg merge
2d 21h
Merged PRs (30d)
46

Description

Hi everyone!

When I build some of our `scala_specs2_junit_test` targets using `--strict_java_deps=ERROR`, I get errors that I'm not sure how to resolve.

```
error: Target 'Unknown label of file bazel-out/local-fastbuild/genfiles/external/scala/_ijar/scala-parser-combinators/external/scala/lib/scala-parser-combinators_2.11-1.0.4-ijar.jar which came from @io_bazel_rules_scala//specs2:specs2' is used but isn't explicitly declared, please add it to the deps.
You can use the following buildozer command:
buildozer 'add deps Unknown label of file bazel-out/local-fastbuild/genfiles/external/scala/_ijar/scala-parser-combinators/external/scala/lib/scala-parser-combinators_2.11-1.0.4-ijar.jar which came from @io_bazel_rules_scala//specs2:specs2' //util:test

error: Target 'Unknown label of file bazel-out/local-fastbuild/genfiles/external/scala/_ijar/scala-xml/external/scala/lib/scala-xml_2.11-1.0.5-ijar.jar which came from @io_bazel_rules_scala//specs2:specs2' is used but isn't explicitly declared, please add it to the deps.
You can use the following buildozer command:
buildozer 'add deps Unknown label of file bazel-out/local-fastbuild/genfiles/external/scala/_ijar/scala-xml/external/scala/lib/scala-xml_2.11-1.0.5-ijar.jar which came from @io_bazel_rules_scala//specs2:specs2' //util:test
two errors found
two errors found
```

Normally I would add the jar to the deps list, but I'm not sure how to do that here. Both scala-parser-combinators and scala-xml are `maven_jar`s in my `WORKSPACE` file. I've added them to the `deps` list for the test target, but it doesn't seem to change anything.

If there's a bug, I'm happy to provide debug info and fix it. If this is an issue with my ignorance of bazel, then I'm happy to update docs somewhere to help others avoid this in the future.

Here are the rules from the `BUILD` file

```
shared_deps = [
"//a",
"//b",
"//c",
"//d",
"@com_typesafe_scala_logging_scala_logging_2_11//jar:file",
"@com_fasterxml_jackson_core_jackson_annotations//jar",
"@com_fasterxml_jackson_core_jackson_core//jar",
"@com_fasterxml_jackson_core_jackson_databind//jar",
"@com_typesafe_config//jar",
"@com_typesafe_play_play_datacommons_2_11//jar",
"@com_typesafe_play_play_functional_2_11//jar",
"@com_typesafe_play_play_iteratees_2_11//jar",
"@com_typesafe_play_play_json_2_11//jar",
"@commons_io_commons_io//jar",
"@joda_time_joda_time//jar",
"@org_apache_httpcomponents_httpclient//jar",
"@org_apache_httpcomponents_httpcore//jar",
"@org_apache_httpcomponents_httpmime//jar",
"@org_scala_lang_modules_scala_parser_combinators_2_11//jar",
"@org_scala_lang_modules_scala_xml_2_11//jar",
"@org_scala_lang_plugins_scala_continuations_library_2_11//jar",
"@org_slf4j_slf4j_api//jar",
]

scala_macro_library(
name = "util",
srcs = glob(["src/main/**/*.scala"]) + glob(["src/main/**/*.java"]),
resources = glob(["src/main/resources/**"]),
visibility = ["//visibility:public"],
deps = shared_deps + [
"//e",
"//f",
"//g",
"//e",
"@com_amazonaws_aws_java_sdk_core//jar",
"@com_amazonaws_aws_java_sdk_sts//jar",
"@com_github_nscala_time_nscala_time_2_11//jar",
"@com_lucidchart_thread_context//jar",
"@commons_codec_commons_codec//jar",
"@net_sf_ehcache_ehcache_core//jar",
"@org_apache_httpcomponents_httpasyncclient//jar",
"@org_scala_lang_modules_scala_java8_compat_2_11//jar",
"@org_scalaz_scalaz_core_2_11//jar:file",
]
)

scala_specs2_junit_test(
name = "test",
srcs = glob(["src/test/**/*.scala"]),
resources = glob(["src/test/resources/**"]),
deps = shared_deps + [
":util",
"@junit_junit//jar",
"@org_mockito_mockito_core//jar",
"@org_objenesis_objenesis//jar",
"@org_specs2_specs2_mock_2_11//jar",
],
suffixes = ["Spec", "Test"],
timeout = "short",
print_discovered_classes = True,
)
```

Contributor guide

Open the contributing guide

Research direction

Start with the WORKSPACE maven_jar declarations and the BUILD file's shared_deps, util, and test rules. Reproduce the scala_specs2_junit_test build with --strict_java_deps=ERROR, then trace why the specs2 dependencies are not recognized; done means the target builds without the reported undeclared scala-parser-combinators and scala-xml errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.