|
| 1 | +# Update/create scala_x_x.bzl repository file script |
| 2 | + |
| 3 | +- [About](#about) |
| 4 | +- [Usage](#usage) |
| 5 | +- [Examples](#examples) |
| 6 | +- [Debugging](#debugging) |
| 7 | +- [Requirements](#requirements) |
| 8 | + |
| 9 | +### About |
| 10 | +The script allows to update a certain scala_x_x.bzl file and its content (artifact, sha, dependencies), by changing the value of `root_scala_version` variable. |
| 11 | +It can be used to create non-existent file for chosen Scala version. <br> |
| 12 | +It's using a [https://get-coursier.io/docs/](coursier) in order to **resolve** lists the transitive dependencies of dependencies and **fetch** the JARs of it. |
| 13 | + |
| 14 | +### Usage |
| 15 | +Usage from `/rules_scala/scripts`: |
| 16 | +```` |
| 17 | +python3 create_repository.py |
| 18 | +```` |
| 19 | + |
| 20 | +### Examples |
| 21 | +Current value of `root_scala_versions`: |
| 22 | +``` |
| 23 | +root_scala_versions = ["2.11.12", "2.12.19", "2.13.14", "3.1.3", "3.2.2", "3.3.3", "3.4.3", "3.5.0"] |
| 24 | +``` |
| 25 | + |
| 26 | +To **update** content of `scala_3_4.bzl` file: |
| 27 | +``` |
| 28 | +root_scala_versions = ["2.11.12", "2.12.19", "2.13.14", "3.1.3", "3.2.2", "3.3.3", "3.4.4", "3.5.0"] |
| 29 | + ^^^^^^^ <- updated version |
| 30 | +``` |
| 31 | + |
| 32 | +To **create** new `scala_3_6.bzl` file: |
| 33 | +``` |
| 34 | +root_scala_versions = ["2.11.12", "2.12.19", "2.13.14", "3.1.3", "3.2.2", "3.3.3", "3.4.3", "3.5.0", "3.6.0"] |
| 35 | + ^^^^^^^ <- new version |
| 36 | +``` |
| 37 | + |
| 38 | +### Debugging |
| 39 | +Certain dependency version may not have a support for chosen Scala version e.g. |
| 40 | +``` |
| 41 | +kind_projector_version = "0.13.2" if scala_major < "2.13" else "0.13.3" |
| 42 | +``` |
| 43 | + |
| 44 | +In order of that, there may be situations that script won't work. To debug that problem and adjust the values of hard-coded variables: |
| 45 | +``` |
| 46 | +scala_test_major = "3" if scala_major >= "3.0" else scala_major |
| 47 | +scala_fmt_major = "2.13" if scala_major >= "3.0" else scala_major |
| 48 | +kind_projector_version = "0.13.2" if scala_major < "2.13" else "0.13.3" |
| 49 | +f"org.scalameta:scalafmt-core_{scala_fmt_major}:{"2.7.5" if scala_major == "2.11" else scala_fmt_version}" |
| 50 | +``` |
| 51 | +there is an option to print the output of these two subprocesses: |
| 52 | + |
| 53 | +`output = subprocess.run(f'cs fetch {artifact}', capture_output=True, text=True, shell=True).stdout.splitlines()` <br> |
| 54 | + |
| 55 | +``` |
| 56 | + command = f'cs resolve {' '.join(root_artifacts)}' |
| 57 | + output = subprocess.run(command, capture_output=True, text=True, shell=True).stdout.splitlines() |
| 58 | +``` |
| 59 | + |
| 60 | +### Requirements |
| 61 | +Installed [Coursier](https://get-coursier.io/) and [Python 3](https://www.python.org/downloads/) |
0 commit comments