Skip to content

Commit

Permalink
Scala 2.12 + Play 2.8 support (#48)
Browse files Browse the repository at this point in the history
* Scala 2.12 + Play 2.8 support

* Separating dependency trees for Play 2.8 to Scala 2.12 and Scala 2.13

play-routes-compiler-cli_2.{12,13} have e.g. scala-library in their dependencies.
If we have them in the same dependency tree, scala-library will be taken
for both versions, effectively overriding the scala-library dependency
for play-routes-compiler-cli_2.12 to scala-library:2.13.2, which causes
compilation errors.

Separate the dependency trees for Play 2.8, by requiring an optional
Scala version argument in play_routes_repositories().

* Updating README with Scala version option for play_routes_repositories
  • Loading branch information
gergelyfabian authored Dec 2, 2021
1 parent 84d6b6e commit 4e94fc8
Show file tree
Hide file tree
Showing 10 changed files with 2,734 additions and 2,103 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ We provide 6 default compilers:
- For Scala 2.11 + Play 2.7: `@io_bazel_rules_play_routes//default-compiler-clis:scala_2_11_play_2_7`
- For Scala 2.12 + Play 2.6: `@io_bazel_rules_play_routes//default-compiler-clis:scala_2_12_play_2_6`
- For Scala 2.12 + Play 2.7: `@io_bazel_rules_play_routes//default-compiler-clis:scala_2_12_play_2_7`
- For Scala 2.12 + Play 2.8: `@io_bazel_rules_play_routes//default-compiler-clis:scala_2_12_play_2_8`
- For Scala 2.13 + Play 2.8: `@io_bazel_rules_play_routes//default-compiler-clis:scala_2_13_play_2_8`

To bind one of the default compilers, simply specify the correct Play version in the call to `play_routes_repositories` and update the bind statement:
```python
play_routes_repositories(<Play Version>)
play_routes_repositories(<Play Version>, <Optional Scala Version, see below>)
load("@play_routes//:defs.bzl", play_routes_pinned_maven_install = "pinned_maven_install")
play_routes_pinned_maven_install()

Expand All @@ -71,8 +72,10 @@ bind(
)
```

Note: play_routes_respositories only needs to know the Play version; there's no special config for the Scala version (just make sure you bind the right compiler label)
Note: play_routes_respositories by default only needs to know the Play version. By default, there's no special config
for the Scala version (just make sure you bind the right compiler label).

You can optionally include the Scala version, this might be needed for certain versions of Play.

## Usage
The `play_routes` rule compiles Play routes files to a source jar that can be used with the `rules_scala` rules. For example,
Expand Down
7 changes: 7 additions & 0 deletions default-compiler-clis/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ java_binary(
runtime_deps = ["@play_routes//:com_lucidchart_play_routes_compiler_cli_2_12"],
)

java_binary(
name = "scala_2_12_play_2_8",
main_class = "rulesplayroutes.routes.CommandLinePlayRoutesCompiler",
visibility = ["//visibility:public"],
runtime_deps = ["@play_routes//:com_lucidchart_play_routes_compiler_cli_2_12"],
)

java_binary(
name = "scala_2_13_play_2_8",
main_class = "rulesplayroutes.routes.CommandLinePlayRoutesCompiler",
Expand Down
258 changes: 129 additions & 129 deletions play_2_5_routes_compiler_cli_install.json

Large diffs are not rendered by default.

396 changes: 198 additions & 198 deletions play_2_6_routes_compiler_cli_install.json

Large diffs are not rendered by default.

368 changes: 184 additions & 184 deletions play_2_7_routes_compiler_cli_install.json

Large diffs are not rendered by default.

611 changes: 611 additions & 0 deletions play_2_8__2_12_routes_compiler_cli_install.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2,816 changes: 1,408 additions & 1,408 deletions play_routes_test_install.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion scripts/gen-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ bazel run @unpinned_play_routes_test//:pin
bazel run @unpinned_play_2_5_routes_compiler_cli//:pin
bazel run @unpinned_play_2_6_routes_compiler_cli//:pin
bazel run @unpinned_play_2_7_routes_compiler_cli//:pin
bazel run @unpinned_play_2_8_routes_compiler_cli//:pin
bazel run @unpinned_play_2_8__2_12_routes_compiler_cli//:pin
bazel run @unpinned_play_2_8__2_13_routes_compiler_cli//:pin
13 changes: 11 additions & 2 deletions workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ Load 3rd party maven dependencies

load("@rules_jvm_external//:defs.bzl", "maven_install")

def play_routes_repositories(play_version):
def play_routes_repositories(play_version, scala_version=None):
"""
Loads 3rd party dependencies and the required play routes compiler CLIs for the specified version of Play
Args:
play_version: (str) Must be either "2.5", "2.6", "2.7" or "2.8"
scala_version: (optional) For Play 2.8, default to Scala 2.13
"""

play_version = play_version.replace(".", "_")

if play_version == "2_8":
if not scala_version:
scala_version = "2.13"
play_version = play_version + "__" + scala_version.replace(".", "_")

play_artifacts = {
"2_5": [
"com.lucidchart:play-routes-compiler-cli_2.11:2.5.19",
Expand All @@ -26,7 +32,10 @@ def play_routes_repositories(play_version):
"com.lucidchart:play-routes-compiler-cli_2.11:2.7.2",
"com.lucidchart:play-routes-compiler-cli_2.12:2.7.3",
],
"2_8": [
"2_8__2_12": [
"com.lucidchart:play-routes-compiler-cli_2.12:2.8.7",
],
"2_8__2_13": [
"com.lucidchart:play-routes-compiler-cli_2.13:2.8.7",
],
}
Expand Down

0 comments on commit 4e94fc8

Please sign in to comment.