Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Initial Bazel integration #9777

Draft
wants to merge 17 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ commons_compress_version = "1.23.0"
commons_lang_version = "3.12.0"
junit_version = "4.13.2"
hamcrest_version = "1.3"
picocli_version = "4.6.1"
minimal_json_version = "0.9.5"

## TODO: Consider replacing maven extension with
## https://github.com/bazeltools/bazel-deps
## The downside of the approach is that a number of other rules rely on it.
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
## After updating a list of artifacts run
## > bazel run @unpinned_maven//:pin
Expand All @@ -80,6 +83,10 @@ maven.install(
"org.apache.commons:commons-lang3:%s" % commons_lang_version,
"junit:junit:%s" % junit_version,
"org.hamcrest:hamcrest-all:%s" % hamcrest_version,

## bazel-distribution dependencies
"info.picocli:picocli:%s" % picocli_version,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need picocli? What does bazel-distribution dependencies mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the comment says, it is a dependency of bazel-distribution rules which are used for generating pom.xml.
This doesn't mean that this dependency is added to any of subprojects. But it has to be listed for the rules so that the dependency (and its version) is discoverable.

"com.eclipsesource.minimal-json:minimal-json:%s" % minimal_json_version,
] + circe,
fail_if_repin_required = True,
lock_file = "//:maven_install.json",
Expand Down
38 changes: 34 additions & 4 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
## https://github.com/bazelbuild/rules_scala/pull/1541

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")


http_archive(
name = "bazel_skylib",
Expand Down Expand Up @@ -55,3 +57,42 @@ scalatest_toolchain()
## https://github.com/bazelbuild/rules_scala/issues/1521
## Workaround is to use our own scala toolchain with custom options.
register_toolchains("//toolchains:enso_toolchain")


## Setup `bazel-distribution` for generating pom.xml
RULES_BAZEL_DISTRIBUTION_SHA = "3f88eb2ff11654039fa64cbc67a8411df1b85fba"

git_repository(
name = "vaticle_bazel_distribution",
commit = RULES_BAZEL_DISTRIBUTION_SHA,
remote = "https://github.com/vaticle/bazel-distribution",
)

### Dependencies of `bazel-distribution`
http_archive(
name = "rules_pkg",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz",
],
sha256 = "8f9ee2dc10c1ae514ee599a8b42ed99fa262b757058f65ad3c384289ff70c4b8",
)
## Uses more up-to-date version of rules_kotlin than what
## @vaticle_bazel_distribution seems to rely on
## as encountered various issues, including a blocker of
## https://github.com/bazelbuild/rules_kotlin/issues/1072.
rules_kotlin_version = "1.9.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need kotlin rules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependency of bazel-distribution unfortunately.

rules_kotlin_sha = "5766f1e599acf551aa56f49dab9ab9108269b03c557496c54acaf41f98e2b8d6"
http_archive(
name = "io_bazel_rules_kotlin",
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v%s/rules_kotlin-v%s.tar.gz" % (rules_kotlin_version, rules_kotlin_version)],
sha256 = rules_kotlin_sha,
)

### Default setup for `baze-distribution`
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
load("@vaticle_bazel_distribution//common:rules.bzl", "workspace_refs")
workspace_refs(name = "enso_org_enso_workspace_refs")
14 changes: 14 additions & 0 deletions lib/scala/cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library", "scala_test")
load("@vaticle_bazel_distribution//maven:rules.bzl", "assemble_maven")

scala_library(
name = "cli",
Expand All @@ -12,6 +13,10 @@ scala_library(
"@maven//:org_slf4j_slf4j_api",
##"@maven//:org_scala_lang_scala_library",
],
tags = [
"maven_coordinates=org.enso:cli:{pom_version}",
],

)

scala_test(
Expand All @@ -28,4 +33,13 @@ scala_test(
"@maven//:org_scala_lang_scala_library",
],
tags = ["unit"]
)

assemble_maven(
name = "assemble_maven",
target = ":cli",
project_name = "Enso CLI",
project_url = "https://enso.org",
project_description = "Project description STUB",
workspace_refs = "@enso_org_enso_workspace_refs//:refs.json",
)
26 changes: 24 additions & 2 deletions maven_install.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": 1841603713,
"__RESOLVED_ARTIFACTS_HASH": 417026400,
"__INPUT_ARTIFACTS_HASH": -1929789347,
"__RESOLVED_ARTIFACTS_HASH": -631810540,
"conflict_resolution": {
"com.google.errorprone:error_prone_annotations:2.3.2": "com.google.errorprone:error_prone_annotations:2.11.0"
},
Expand All @@ -12,6 +12,12 @@
},
"version": "2.3.10"
},
"com.eclipsesource.minimal-json:minimal-json": {
"shasums": {
"jar": "69ff84463d1d7cc5cfdb8baf2b6e5f7af153d351bf0dbee3bbc8916247afac74"
},
"version": "0.9.5"
},
"com.fasterxml.jackson.core:jackson-annotations": {
"shasums": {
"jar": "04e21f94dcfee4b078fa5a5f53047b785aaba69d19de392f616e7a7fe5d3882f"
Expand Down Expand Up @@ -114,6 +120,12 @@
},
"version": "1.2"
},
"info.picocli:picocli": {
"shasums": {
"jar": "2a6e03310db149f8a11eb058aa78e775c229ef816333c9687379762d22833ad6"
},
"version": "4.6.1"
},
"io.circe:circe-core_2.13": {
"shasums": {
"jar": "a560267179eef5420fad41c83cf2ce69adbff9b2541236c40f5e88a230e091e9"
Expand Down Expand Up @@ -557,6 +569,9 @@
"shapeless.syntax.std",
"shapeless.test"
],
"com.eclipsesource.minimal-json:minimal-json": [
"com.eclipsesource.json"
],
"com.fasterxml.jackson.core:jackson-annotations": [
"com.fasterxml.jackson.annotation"
],
Expand Down Expand Up @@ -695,6 +710,9 @@
"org.apache.commons.logging",
"org.apache.commons.logging.impl"
],
"info.picocli:picocli": [
"picocli"
],
"io.circe:circe-core_2.13": [
"io.circe",
"io.circe.cursor",
Expand Down Expand Up @@ -1234,6 +1252,7 @@
"repositories": {
"https://repo.maven.apache.org/maven2/": [
"com.chuusai:shapeless_2.13",
"com.eclipsesource.minimal-json:minimal-json",
"com.fasterxml.jackson.core:jackson-annotations",
"com.fasterxml.jackson.core:jackson-core",
"com.fasterxml.jackson.core:jackson-databind",
Expand All @@ -1251,6 +1270,7 @@
"commons-codec:commons-codec",
"commons-io:commons-io",
"commons-logging:commons-logging",
"info.picocli:picocli",
"io.circe:circe-core_2.13",
"io.circe:circe-generic_2.13",
"io.circe:circe-jawn_2.13",
Expand Down Expand Up @@ -1296,6 +1316,7 @@
],
"https://repo1.maven.org/maven2/": [
"com.chuusai:shapeless_2.13",
"com.eclipsesource.minimal-json:minimal-json",
"com.fasterxml.jackson.core:jackson-annotations",
"com.fasterxml.jackson.core:jackson-core",
"com.fasterxml.jackson.core:jackson-databind",
Expand All @@ -1313,6 +1334,7 @@
"commons-codec:commons-codec",
"commons-io:commons-io",
"commons-logging:commons-logging",
"info.picocli:picocli",
"io.circe:circe-core_2.13",
"io.circe:circe-generic_2.13",
"io.circe:circe-jawn_2.13",
Expand Down