Skip to content

Latest commit

 

History

History
 
 

scripts

Update/create scala_x_x.bzl repository file script

About

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.

It can be used to create non-existent file for chosen Scala version.

It's using a https://get-coursier.io/docs/ in order to resolve lists the transitive dependencies of dependencies and fetch the JARs of it.

Usage

Usage from the rules_scala root directory:

./scripts/create_repository.py

Examples

Current value of root_scala_versions:

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",
]

To update content of scala_3_4.bzl file:

root_scala_versions = [
    "2.11.12",
    "2.12.19",
    "2.13.14",
    "3.1.3",
    "3.2.2",
    "3.3.3",
    "3.4.4",  # <- updated version
    "3.5.0"
]

To create new scala_3_6.bzl file:

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",  # <- new version
]

Debugging

Certain dependency versions may not support a specific Scala versions, e.g.,

kind_projector_version = "0.13.2" if scala_major < "2.13" else "0.13.3"

There may be situations in which the script won't work. To debug that problem and adjust the values of hard-coded variables:

scalatest_major = "3" if scala_major >= "3.0" else scala_major
scalafmt_major = "2.13" if scala_major >= "3.0" else scala_major
kind_projector_version = "0.13.2" if scala_major < "2.13" else "0.13.3"
scalafmt_version = "2.7.5" if scala_major == "2.11" else SCALAFMT_VERSION

there is an option to print the output of these two subprocesses:

    command = f'cs resolve {' '.join(root_artifacts)}'
    output = subprocess.run(
        command, capture_output=True, text=True, shell=True
    ).stdout.splitlines()

Requirements

Install Coursier and Python 3 before running the script.