|
6 | 6 | - [Debugging](#debugging)
|
7 | 7 | - [Requirements](#requirements)
|
8 | 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`: |
| 9 | +## About |
| 10 | + |
| 11 | +The script allows to update a certain scala_x_x.bzl file and its content |
| 12 | +(artifact, sha, dependencies), by changing the value of `root_scala_version` |
| 13 | +variable. |
| 14 | + |
| 15 | +It can be used to create non-existent file for chosen Scala version. |
| 16 | + |
| 17 | +It's using a [https://get-coursier.io/docs/](coursier) in order to **resolve** |
| 18 | +lists the transitive dependencies of dependencies and **fetch** the JARs of it. |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +Usage from the rules_scala root directory: |
| 23 | + |
| 24 | +```sh |
| 25 | +./scripts/create_repository.py |
22 | 26 | ```
|
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"] |
| 27 | + |
| 28 | +## Examples |
| 29 | + |
| 30 | +Current value of `root_scala_versions`: |
| 31 | + |
| 32 | +```py |
| 33 | +root_scala_versions = [ |
| 34 | + "2.11.12", |
| 35 | + "2.12.19", |
| 36 | + "2.13.14", |
| 37 | + "3.1.3", |
| 38 | + "3.2.2", |
| 39 | + "3.3.3", |
| 40 | + "3.4.3", |
| 41 | + "3.5.0", |
| 42 | +] |
24 | 43 | ```
|
25 | 44 |
|
26 | 45 | 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 |
| 46 | + |
| 47 | +```py |
| 48 | +root_scala_versions = [ |
| 49 | + "2.11.12", |
| 50 | + "2.12.19", |
| 51 | + "2.13.14", |
| 52 | + "3.1.3", |
| 53 | + "3.2.2", |
| 54 | + "3.3.3", |
| 55 | + "3.4.4", # <- updated version |
| 56 | + "3.5.0" |
| 57 | +] |
30 | 58 | ```
|
31 | 59 |
|
32 | 60 | 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 | 61 |
|
38 |
| -### Debugging |
39 |
| -Certain dependency version may not have a support for chosen Scala version e.g. |
| 62 | +```py |
| 63 | +root_scala_versions = [ |
| 64 | + "2.11.12", |
| 65 | + "2.12.19", |
| 66 | + "2.13.14", |
| 67 | + "3.1.3", |
| 68 | + "3.2.2", |
| 69 | + "3.3.3", |
| 70 | + "3.4.3", |
| 71 | + "3.5.0", |
| 72 | + "3.6.0", # <- new version |
| 73 | +] |
40 | 74 | ```
|
| 75 | + |
| 76 | +## Debugging |
| 77 | + |
| 78 | +Certain dependency versions may not support a specific Scala versions, e.g., |
| 79 | + |
| 80 | +```py |
41 | 81 | kind_projector_version = "0.13.2" if scala_major < "2.13" else "0.13.3"
|
42 | 82 | ```
|
43 | 83 |
|
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 |
| 84 | +There may be situations in which the script won't work. To debug that problem |
| 85 | +and adjust the values of hard-coded variables: |
| 86 | + |
| 87 | +```py |
| 88 | +scalatest_major = "3" if scala_major >= "3.0" else scala_major |
| 89 | +scalafmt_major = "2.13" if scala_major >= "3.0" else scala_major |
48 | 90 | 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}" |
| 91 | +scalafmt_version = "2.7.5" if scala_major == "2.11" else SCALAFMT_VERSION |
50 | 92 | ```
|
51 |
| -there is an option to print the output of these two subprocesses: |
52 | 93 |
|
53 |
| -`output = subprocess.run(f'cs fetch {artifact}', capture_output=True, text=True, shell=True).stdout.splitlines()` <br> |
| 94 | +there is an option to print the output of these two subprocesses: |
54 | 95 |
|
| 96 | +```py |
| 97 | + command = f'cs resolve {' '.join(root_artifacts)}' |
| 98 | + output = subprocess.run( |
| 99 | + command, capture_output=True, text=True, shell=True |
| 100 | + ).stdout.splitlines() |
55 | 101 | ```
|
56 |
| - command = f'cs resolve {' '.join(root_artifacts)}' |
57 |
| - output = subprocess.run(command, capture_output=True, text=True, shell=True).stdout.splitlines() |
58 |
| -``` |
59 | 102 |
|
60 |
| -### Requirements |
61 |
| -Installed [Coursier](https://get-coursier.io/) and [Python 3](https://www.python.org/downloads/) |
| 103 | +## Requirements |
| 104 | + |
| 105 | +Install [Coursier](https://get-coursier.io/) and |
| 106 | +[Python 3](https://www.python.org/downloads/) before running the script. |
0 commit comments