Skip to content
Open
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
4 changes: 2 additions & 2 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
platforms:
ubuntu1404:
ubuntu1604:
shell_commands:
# Disable local disk caching on CI.
- mv tools/bazel.rc.buildkite tools/bazel.rc
Expand All @@ -9,7 +9,7 @@ platforms:
- "//test/..."
test_targets:
- "//test/..."
ubuntu1604:
ubuntu1804:
shell_commands:
# Disable local disk caching on CI.
- mv tools/bazel.rc.buildkite tools/bazel.rc
Expand Down
9 changes: 4 additions & 5 deletions .bazelrc.travis
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# This is from Bazel's former travis setup, to avoid blowing up the RAM usage.
startup --host_jvm_args=-Xmx2500m
startup --host_jvm_args=-Xms2500m
startup --host_jvm_args=-Xmx3072m
startup --host_jvm_args=-Xms1024m
# startup --batch # we actually start many bazels in the test script, we don't want batch
test --ram_utilization_factor=10

# Just making sure that we don't OOM with parallel builds
build --local_resources 2048,.5,1.0
build --local_resources 3072,.5,1.0

# This is so we understand failures better
build --verbose_failures
Expand All @@ -17,7 +16,7 @@ build --verbose_failures
# runs stuff in a container, and since Travis already runs its script
# in a container (unless you require sudo in your .travis.yml) this
# fails to run tests.
build --strategy=Scalac=worker --strategy=ScroogeRule=worker --worker_max_instances=3
build --strategy=Scalac=worker --strategy=ScroogeRule=worker --worker_max_instances=2
#test --test_strategy=standalone

# Below this line, .travis.yml will cat the default bazelrc.
Expand Down
58 changes: 37 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sudo: required
# xcode8 has jdk8
osx_image: xcode8
# Not technically required but suppresses 'Ruby' in Job status message.
language: java
language: sh

cache:
directories:
Expand All @@ -13,38 +13,54 @@ cache:
os:
- linux
- osx
- windows

env:
# Linting is broken. Disable until fixed.
# See https://github.com/bazelbuild/rules_scala/pull/622
# we want to test the last release
#- V=0.16.1 TEST_SCRIPT=test_lint.sh
- V=0.23.1 TEST_SCRIPT=test_rules_scala.sh
- V=0.23.1 TEST_SCRIPT=test_rules_scala
#- V=0.14.1 TEST_SCRIPT=test_intellij_aspect.sh
- V=0.23.1 TEST_SCRIPT=test_reproducibility.sh
- V=0.23.1 TEST_SCRIPT=test_reproducibility


before_install:
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
OS=darwin
else
sysctl kernel.unprivileged_userns_clone=1
sudo apt-get update -q
sudo apt-get install libxml2-utils -y
OS=linux
fi
if [[ $V =~ .*rc[0-9]+.* ]]; then
PRE_RC=$(expr "$V" : '\([0-9.]*\)rc.*')
RC_PRC=$(expr "$V" : '[0-9.]*\(rc.*\)')
URL="https://storage.googleapis.com/bazel/${PRE_RC}/${RC_PRC}/bazel-${V}-installer-${OS}-x86_64.sh"
if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then
choco install jdk8 -params 'installdir=c:\\java8'
choco install bazel --version ${V}
else
URL="https://github.com/bazelbuild/bazel/releases/download/${V}/bazel-${V}-installer-${OS}-x86_64.sh"
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
OS=darwin
else
sudo sysctl kernel.unprivileged_userns_clone=1
sudo add-apt-repository -y ppa:openjdk-r/ppa
sudo apt-get update -q
sudo apt-get install openjdk-8-jdk -y
sudo apt-get install libxml2-utils -y
OS=linux
fi

if [[ $V =~ .*rc[0-9]+.* ]]; then
PRE_RC=$(expr "$V" : '\([0-9.]*\)rc.*')
RC_PRC=$(expr "$V" : '[0-9.]*\(rc.*\)')
URL="https://storage.googleapis.com/bazel/${PRE_RC}/${RC_PRC}/bazel-${V}-installer-${OS}-x86_64.sh"
else
URL="https://github.com/bazelbuild/bazel/releases/download/${V}/bazel-${V}-installer-${OS}-x86_64.sh"
fi
wget -O install.sh "${URL}"
chmod +x install.sh
./install.sh --user
rm -f install.sh
fi
wget -O install.sh "${URL}"
chmod +x install.sh
./install.sh --user
rm -f install.sh
- cat .bazelrc.travis >> .bazelrc

script:
- bash $TEST_SCRIPT ci
- |
if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then
powershell -Command 'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'
powershell -File ./${TEST_SCRIPT}.ps1
else
bash ./${TEST_SCRIPT}.sh ci
fi
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ 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 check # check formatting
./lint.sh fix # fix formatting
```

Expand Down
58 changes: 30 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,46 @@
<li><a href="#scala_library">scala_library/scala_macro_library</a></li>
<li><a href="#scala_binary">scala_binary</a></li>
<li><a href="#scala_test">scala_test</a></li>
<li><a href="#scala_repl">scala_repl</a></li>
<li><a href="#scala_library_suite">scala_library_suite</a></li>
<li><a href="#scala_test_suite">scala_test_suite</a></li>
<li><a href="#thrift_library">thrift_library</a></li>
<li><a href="#scalapb_proto_library">scalapb_proto_library</a></li>
<li><a href="#scala_toolchain">scala_toolchain</a></li>
</ul>
</div>

## Overview

This rule is used for building [Scala][scala] projects with Bazel. There are
currently four rules, `scala_library`, `scala_macro_library`, `scala_binary`
and `scala_test`.
These rules are used for building [Scala][scala] projects with Bazel. There are
currently rules for building binaries (and repl apps), libraries, tests, and
protobuf and thrift libraries.

## Getting started

In order to use `scala_library`, `scala_macro_library`, and `scala_binary`,
you must have bazel 0.5.3 or later and add the following to your WORKSPACE file:
In order to use these rules you must have bazel 0.23 or later and add the
following to your WORKSPACE file:

```python

rules_scala_version="a89d44f7ef67d93dedfc9888630f48d7723516f7" # update this as needed

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_scala",
url = "https://github.com/bazelbuild/rules_scala/archive/%s.zip"%rules_scala_version,
type = "zip",
strip_prefix= "rules_scala-%s" % rules_scala_version
)

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
```
To use a particular tag, use the tagged number in `tag = ` and omit the `commit` attribute.
Note that these plugins are still evolving quickly, as is bazel, so you may need to select
the version most appropriate for you.

In addition, you **must** register `scala_toolchain` - To register default empty toolcahin simply add those lines to `WORKSPACE` file:
```python
name = "io_bazel_rules_scala",
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:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
```
[read more here](#scala_toolchain)
This will load the `rules_scala` repository at the commit sha
`rules_scala_version` into your Bazel project and register a [Scala
toolchain](#scala_toolchain) at the default Scala version (2.11.12)

Then in your BUILD file just add the following so the rules will be available:
```python
Expand All @@ -58,7 +57,7 @@ You may wish to have these rules loaded by default using bazel's prelude. You ca
To run with a persistent worker (much faster), you need to add
```
build --strategy=Scalac=worker
test --strategy=Scalac=worker
build --worker_sandboxing
```
to your command line, or to enable by default for building/testing add it to your .bazelrc.

Expand All @@ -70,11 +69,14 @@ specify it when calling `scala_repositories`. `scala_repositories` takes a tuple
as a parameter where `scala_version` is the scala version and `scala_version_jar_shas` is a `dict` with
`sha256` hashes for the maven artifacts `scala_library`, `scala_reflect` and `scala_compiler`:
```python
scala_repositories(("2.12.6", {
"scala_compiler": "3023b07cc02f2b0217b2c04f8e636b396130b3a8544a8dfad498a19c3e57a863",
"scala_library": "f81d7144f0ce1b8123335b72ba39003c4be2870767aca15dd0888ba3dab65e98",
"scala_reflect": "ffa70d522fc9f9deec14358aa674e6dd75c9dfa39d4668ef15bb52f002ce99fa"
}))
scala_repositories((
"2.12.6",
{
"scala_compiler": "3023b07cc02f2b0217b2c04f8e636b396130b3a8544a8dfad498a19c3e57a863",
"scala_library": "f81d7144f0ce1b8123335b72ba39003c4be2870767aca15dd0888ba3dab65e98",
"scala_reflect": "ffa70d522fc9f9deec14358aa674e6dd75c9dfa39d4668ef15bb52f002ce99fa"
}
))
```
If you're using any of the rules `twitter_scrooge`, `tut_repositories`, `scala_proto_repositories`
or `specs2_junit_repositories` you also need to specify `scala_version` for them. See `./test_version/WORKSPACE.template`
Expand Down
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ format_repositories()

http_archive(
name = "bazel_toolchains",
sha256 = "4b1468b254a572dbe134cc1fd7c6eab1618a72acd339749ea343bd8f55c3b7eb",
strip_prefix = "bazel-toolchains-d665ccfa3e9c90fa789671bf4ef5f7c19c5715c4",
sha256 = "5962fe677a43226c409316fcb321d668fc4b7fa97cb1f9ef45e7dc2676097b26",
strip_prefix = "bazel-toolchains-be10bee3010494721f08a0fccd7f57411a1e773e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/d665ccfa3e9c90fa789671bf4ef5f7c19c5715c4.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/d665ccfa3e9c90fa789671bf4ef5f7c19c5715c4.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/be10bee3010494721f08a0fccd7f57411a1e773e.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/be10bee3010494721f08a0fccd7f57411a1e773e.tar.gz",
],
)

Expand Down
Loading