Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bazelbuild/rules_scala
Browse files Browse the repository at this point in the history
  • Loading branch information
softprops committed Jun 19, 2018
2 parents cc037b7 + 59eed5a commit 82b5b0e
Show file tree
Hide file tree
Showing 123 changed files with 5,005 additions and 3,592 deletions.
1 change: 0 additions & 1 deletion .bazel-installer-linux-x86_64.sh.sha256

This file was deleted.

9 changes: 9 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
---
platforms:
ubuntu1404:
shell_commands:
# Disable local disk caching on CI.
- mv tools/bazel.rc.buildkite tools/bazel.rc
build_targets:
- "//test/..."
test_targets:
- "//test/..."
ubuntu1604:
shell_commands:
# Disable local disk caching on CI.
- mv tools/bazel.rc.buildkite tools/bazel.rc
build_targets:
- "//test/..."
test_targets:
- "//test/..."
macos:
shell_commands:
# Disable local disk caching on CI.
- mv tools/bazel.rc.buildkite tools/bazel.rc
build_targets:
- "//test/..."
test_targets:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ bazel-*
*.idea
hash1
hash2
.DS_store
.DS_store
.bazel_cache
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ osx_image: xcode8
# Not technically required but suppresses 'Ruby' in Job status message.
language: java

cache:
directories:
- .bazel_cache

os:
- linux
- osx

env:
# we want to test the last release
- V=0.11.1 TEST_SCRIPT=test_rules_scala.sh
- V=0.11.1 TEST_SCRIPT=test_intellij_aspect.sh
- V=0.13.0 TEST_SCRIPT=test_lint.sh
- V=0.13.0 TEST_SCRIPT=test_rules_scala.sh
- V=0.13.0 TEST_SCRIPT=test_intellij_aspect.sh
- V=0.13.0 TEST_SCRIPT=test_reproducibility.sh

before_install:
- |
Expand All @@ -40,4 +46,3 @@ before_install:

script:
- bash $TEST_SCRIPT ci

14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ the one above, the
[Software Grant and Corporate Contributor License Agreement](https://cla.developers.google.com/about/google-corporate).

### Working with Intellij bazel plugin
For your convenience, you can use [this](scripts/ij.bazelproject) .bazelproject file when you setup the bazel plugin in Intellij
For your convenience, you can use [this](scripts/ij.bazelproject) .bazelproject file when you setup the bazel plugin in Intellij

### Formatting Fixes
Code formatting is checked as part of the CI pipeline. To check/fix formatting
you can use the `lint.sh` script:

```
./ling.sh check # check formatting
./lint.sh fix # fix formatting
```

Note that Skylint failures are ignored and that the fix
command will modify your files in place.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ you must have bazel 0.5.3 or later and add the following to your WORKSPACE file:

```python

rules_scala_version="98dc457356c60b23ccbbdcbf73acfad9e15e8b07" # update this as needed
rules_scala_version="63eab9f4d80612e918ba954211f377cc83d27a07" # update this as needed

http_archive(
name = "io_bazel_rules_scala",
Expand Down Expand Up @@ -628,3 +628,7 @@ bazel test //test/...
```
Note `bazel test //...` will not work since we have a sub-folder on the root folder which is meant to be used in a failure scenario in the integration tests.
Similarly to only build you should use `bazel build //src/...` due to that folder.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for more info.
92 changes: 65 additions & 27 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,85 +1,123 @@
workspace(name = "io_bazel_rules_scala")

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


load("//scala:scala.bzl", "scala_repositories", "scala_mvn_artifact")
scala_repositories()

load("//twitter_scrooge:twitter_scrooge.bzl", "twitter_scrooge", "scrooge_scala_library")

twitter_scrooge()

load("//tut_rule:tut.bzl", "tut_repositories")

tut_repositories()

load("//jmh:jmh.bzl", "jmh_repositories")

jmh_repositories()

load("//scala_proto:scala_proto.bzl", "scala_proto_repositories")

scala_proto_repositories()

load("//specs2:specs2_junit.bzl","specs2_junit_repositories")
load("//specs2:specs2_junit.bzl", "specs2_junit_repositories")

specs2_junit_repositories()

load("//scala:scala_cross_version.bzl", "scala_mvn_artifact")

# test adding a scala jar:
maven_jar(
name = "com_twitter__scalding_date",
artifact = scala_mvn_artifact("com.twitter:scalding-date:0.17.0"),
sha1 = "420fb0c4f737a24b851c4316ee0362095710caa5"
name = "com_twitter__scalding_date",
artifact = scala_mvn_artifact("com.twitter:scalding-date:0.17.0"),
sha1 = "420fb0c4f737a24b851c4316ee0362095710caa5",
)

# 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"
name = "org_typelevel__cats_core",
artifact = scala_mvn_artifact("org.typelevel:cats-core:0.9.0"),
sha1 = "b2f8629c6ec834d8b6321288c9fe77823f1e1314",
)


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

# test of strict deps (scalac plugin UT + E2E)
maven_jar(
name = "com_google_guava_guava_21_0",
name = "com_google_guava_guava_21_0_with_file",
artifact = "com.google.guava:guava:21.0",
sha1 = "3a3d111be1be1b745edfa7d91678a12d7ed38709"
sha1 = "3a3d111be1be1b745edfa7d91678a12d7ed38709",
)

maven_jar(
name = "org_apache_commons_commons_lang_3_5",
artifact = "org.apache.commons:commons-lang3:3.5",
sha1 = "6c6c702c89bfff3cd9e80b04d668c5e190d588c6"
sha1 = "6c6c702c89bfff3cd9e80b04d668c5e190d588c6",
)

http_archive(
name = "com_google_protobuf",
urls = ["https://github.com/google/protobuf/archive/b04e5cba356212e4e8c66c61bbe0c3a20537c5b9.zip"],
strip_prefix = "protobuf-b04e5cba356212e4e8c66c61bbe0c3a20537c5b9",
sha256 = "cf4a434ac3a83040e9f65be92e153d00d075d8cd25e3f6c6d8670879f5796aa0",
sha256 = "118ac276be0db540ff2a89cecc5dfb9606d4d16e91cc4ea8883ae8160acb5163",
strip_prefix = "protobuf-0456e269ee6505766474aa8d7b8bba7ac047f457",
urls = ["https://github.com/google/protobuf/archive/0456e269ee6505766474aa8d7b8bba7ac047f457.zip"],
)

http_archive(
name = "com_google_protobuf_java",
urls = ["https://github.com/google/protobuf/archive/b04e5cba356212e4e8c66c61bbe0c3a20537c5b9.zip"],
strip_prefix = "protobuf-b04e5cba356212e4e8c66c61bbe0c3a20537c5b9",
sha256 = "cf4a434ac3a83040e9f65be92e153d00d075d8cd25e3f6c6d8670879f5796aa0",
sha256 = "118ac276be0db540ff2a89cecc5dfb9606d4d16e91cc4ea8883ae8160acb5163",
strip_prefix = "protobuf-0456e269ee6505766474aa8d7b8bba7ac047f457",
urls = ["https://github.com/google/protobuf/archive/0456e269ee6505766474aa8d7b8bba7ac047f457.zip"],
)

new_local_repository(
name = "test_new_local_repo",
path = "third_party/test/new_local_repo",
build_file_content =
"""
build_file_content =
"""
filegroup(
name = "data",
srcs = glob(["**/*.txt"]),
visibility = ["//visibility:public"],
)
"""
""",
path = "third_party/test/new_local_repo",
)

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

scala_register_toolchains()

load("//scala:scala_maven_import_external.bzl", "scala_maven_import_external", "java_import_external")

scala_maven_import_external(
name = "com_google_guava_guava_21_0",
artifact = "com.google.guava:guava:21.0",
jar_sha256 = "972139718abc8a4893fa78cba8cf7b2c903f35c97aaf44fa3031b0669948b480",
licenses = ["notice"], # Apache 2.0
server_urls = ["https://mirror.bazel.build/repo1.maven.org/maven2"],
)

# bazel's java_import_external has been altered in rules_scala to be a macro based on jvm_import_external
# in order to allow for other jvm-language imports (e.g. scala_import)
# the 3rd-party dependency below is using the java_import_external macro
# in order to make sure no regression with the original java_import_external
load("//scala:scala_maven_import_external.bzl", "java_import_external")

java_import_external(
name = "org_apache_commons_commons_lang_3_5_without_file",
generated_linkable_rule_name = "linkable_org_apache_commons_commons_lang_3_5_without_file",
jar_sha256 = "8ac96fc686512d777fca85e144f196cd7cfe0c0aec23127229497d1a38ff651c",
jar_urls = ["http://central.maven.org/maven2/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar"],
licenses = ["notice"], # Apache 2.0
neverlink = True,
)

## Linting

load("//private:format.bzl", "format_repositories")

format_repositories()
57 changes: 33 additions & 24 deletions jmh/jmh.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ def jmh_repositories():
actual = '@io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm//jar',
)
native.maven_jar(
name = "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection",
artifact = "org.openjdk.jmh:jmh-generator-reflection:1.20",
sha1 = "f2154437b42426a48d5dac0b3df59002f86aed26",
name = "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection",
artifact = "org.openjdk.jmh:jmh-generator-reflection:1.20",
sha1 = "f2154437b42426a48d5dac0b3df59002f86aed26",
)
native.bind(
name = 'io_bazel_rules_scala/dependency/jmh/jmh_generator_reflection',
actual = '@io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection//jar',
name = 'io_bazel_rules_scala/dependency/jmh/jmh_generator_reflection',
actual =
'@io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection//jar',
)
native.maven_jar(
name = "io_bazel_rules_scala_org_ows2_asm_asm",
Expand All @@ -43,7 +44,8 @@ def jmh_repositories():
sha1 = "cdd846cfc4e0f7eefafc02c0f5dce32b9303aa2a",
)
native.bind(
name = "io_bazel_rules_scala/dependency/jmh/net_sf_jopt_simple_jopt_simple",
name =
"io_bazel_rules_scala/dependency/jmh/net_sf_jopt_simple_jopt_simple",
actual = '@io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple//jar',
)
native.maven_jar(
Expand All @@ -52,15 +54,11 @@ def jmh_repositories():
sha1 = "e4ba98f1d4b3c80ec46392f25e094a6a2e58fcbf",
)
native.bind(
name = "io_bazel_rules_scala/dependency/jmh/org_apache_commons_commons_math3",
name =
"io_bazel_rules_scala/dependency/jmh/org_apache_commons_commons_math3",
actual = '@io_bazel_rules_scala_org_apache_commons_commons_math3//jar',
)

jmh_benchmark_generator_tool = Label("//src/scala/io/bazel/rules_scala/jmh_support:benchmark_generator")
jdk_tool = Label("//tools/defaults:jdk")
jar_tool = Label("@local_jdk//:jar")
jar_creator_tool = Label("//src/java/io/bazel/rulesscala/jar:binary")

def _scala_construct_runtime_classpath(deps):
scala_targets = [d.scala for d in deps if hasattr(d, "scala")]
java_targets = [d.java for d in deps if hasattr(d, "java")]
Expand All @@ -78,16 +76,26 @@ def _scala_generate_benchmark(ctx):
outputs = [ctx.outputs.src_jar, ctx.outputs.resource_jar],
inputs = depset([class_jar], transitive = [classpath]),
executable = ctx.executable._generator,
arguments = [ctx.attr.generator_type] + [f.path for f in [class_jar, ctx.outputs.src_jar, ctx.outputs.resource_jar] + classpath.to_list()],
arguments = [ctx.attr.generator_type] + [
f.path
for f in [class_jar, ctx.outputs.src_jar, ctx.outputs.resource_jar] +
classpath.to_list()
],
progress_message = "Generating benchmark code for %s" % ctx.label,
)

scala_generate_benchmark = rule(
implementation = _scala_generate_benchmark,
attrs = {
"src": attr.label(allow_single_file=True, mandatory=True),
"generator_type": attr.string(default='reflection', mandatory=False),
"_generator": attr.label(executable=True, cfg="host", default=Label("//src/scala/io/bazel/rules_scala/jmh_support:benchmark_generator"))
"src": attr.label(allow_single_file = True, mandatory = True),
"generator_type": attr.string(
default = 'reflection', mandatory = False),
"_generator": attr.label(
executable = True,
cfg = "host",
default = Label(
"//src/scala/io/bazel/rules_scala/jmh_support:benchmark_generator"
))
},
outputs = {
"src_jar": "%{name}.srcjar",
Expand Down Expand Up @@ -117,7 +125,8 @@ def scala_benchmark_jmh(**kw):
)

codegen = name + "_codegen"
scala_generate_benchmark(name=codegen, src=lib, generator_type=generator_type)
scala_generate_benchmark(
name = codegen, src = lib, generator_type = generator_type)
compiled_lib = name + "_compiled_benchmark_lib"
scala_library(
name = compiled_lib,
Expand All @@ -129,11 +138,11 @@ def scala_benchmark_jmh(**kw):
resource_jars = ["%s_resources.jar" % codegen],
)
scala_binary(
name = name,
deps = [
"//external:io_bazel_rules_scala/dependency/jmh/net_sf_jopt_simple_jopt_simple",
"//external:io_bazel_rules_scala/dependency/jmh/org_apache_commons_commons_math3",
compiled_lib,
],
main_class = main_class,
name = name,
deps = [
"//external:io_bazel_rules_scala/dependency/jmh/net_sf_jopt_simple_jopt_simple",
"//external:io_bazel_rules_scala/dependency/jmh/org_apache_commons_commons_math3",
compiled_lib,
],
main_class = main_class,
)
10 changes: 7 additions & 3 deletions junit/junit.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ def junit_repositories():
artifact = "junit:junit:4.12",
sha1 = "2973d150c0dc1fefe998f834810d68f278ea58ec",
)
native.bind(name = 'io_bazel_rules_scala/dependency/junit/junit', actual = '@io_bazel_rules_scala_junit_junit//jar')

native.bind(
name = 'io_bazel_rules_scala/dependency/junit/junit',
actual = '@io_bazel_rules_scala_junit_junit//jar')

native.maven_jar(
name = "io_bazel_rules_scala_org_hamcrest_hamcrest_core",
artifact = "org.hamcrest:hamcrest-core:1.3",
sha1 = "42a25dc3219429f0e5d060061f71acb49bf010a0",
)
native.bind(name = 'io_bazel_rules_scala/dependency/hamcrest/hamcrest_core', actual = '@io_bazel_rules_scala_org_hamcrest_hamcrest_core//jar')
native.bind(
name = 'io_bazel_rules_scala/dependency/hamcrest/hamcrest_core',
actual = '@io_bazel_rules_scala_org_hamcrest_hamcrest_core//jar')
Loading

0 comments on commit 82b5b0e

Please sign in to comment.