Skip to content

Commit

Permalink
Keep all maven deps in the central place for easier version management (
Browse files Browse the repository at this point in the history
bazelbuild#1113)

* Move external artifact versions and shas to central place per Scala version

* Move scalafmt deps to repositories

* Move jmh deps to repositories

* Move junit deps to repositories

* Move specs2 deps to repositories

* Move specs2-junit deps to repositories

* Move proto deps to repositories

* Move tut deps to repositories

* Move scrooge deps to repositories

* Move WORKSPACE test deps to repositories files

* Move dep back to workspace to explicitly use jvm_maven_import_external, to address dep analyzer tests

* Fix Scala version tests

* Use repository deps for scrooge

* Add scrooge version tests back

* Keep current twitter scrooge repository interface
  • Loading branch information
Vaidas Pilkauskas authored Oct 11, 2020
1 parent 773c992 commit d8f5bd9
Show file tree
Hide file tree
Showing 25 changed files with 1,332 additions and 1,438 deletions.
142 changes: 39 additions & 103 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ scala_repositories(fetch_sources = True)

load("//scala:scala_cross_version.bzl", "default_maven_server_urls")
load("//scala:scala_maven_import_external.bzl", "scala_maven_import_external")
load("//twitter_scrooge:twitter_scrooge.bzl", "scrooge_scala_library", "twitter_scrooge")
load("//twitter_scrooge:twitter_scrooge.bzl", "twitter_scrooge")

twitter_scrooge()

Expand Down Expand Up @@ -55,7 +55,12 @@ scalafmt_default_config()

scalafmt_repositories()

load("//scala:scala_cross_version.bzl", "default_scala_major_version", "scala_mvn_artifact")
load(
"//scala:scala_cross_version.bzl",
"default_scala_major_version",
"default_scala_version",
"scala_mvn_artifact",
)

MAVEN_SERVER_URLS = default_maven_server_urls()

Expand All @@ -64,70 +69,6 @@ load("//test/proto_cross_repo_boundary:repo.bzl", "proto_cross_repo_boundary_rep

proto_cross_repo_boundary_repository()

# test adding a scala jar:
jvm_maven_import_external(
name = "com_twitter__scalding_date",
artifact = scala_mvn_artifact(
"com.twitter:scalding-date:0.17.0",
default_scala_major_version(),
),
artifact_sha256 = "973a7198121cc8dac9eeb3f325c93c497fe3b682f68ba56e34c1b210af7b15b3",
server_urls = MAVEN_SERVER_URLS,
)

# For testing that we don't include sources jars to the classpath
jvm_maven_import_external(
name = "org_typelevel__cats_core",
artifact = scala_mvn_artifact(
"org.typelevel:cats-core:0.9.0",
default_scala_major_version(),
),
artifact_sha256 = "3ca705cba9dc0632e60477d80779006f8c636c0e2e229dda3410a0c314c1ea1d",
server_urls = MAVEN_SERVER_URLS,
)

# test of a plugin
jvm_maven_import_external(
name = "org_psywerx_hairyfotr__linter",
artifact = scala_mvn_artifact(
"org.psywerx.hairyfotr:linter:0.1.17",
default_scala_major_version(),
),
artifact_sha256 = "59becd7883613064842b3a62f84315b02457dc439f42ef62e3c80408393c905b",
server_urls = MAVEN_SERVER_URLS,
)

# test of strict deps (scalac plugin UT + E2E)
jvm_maven_import_external(
name = "com_google_guava_guava_21_0_with_file",
artifact = "com.google.guava:guava:21.0",
artifact_sha256 = "972139718abc8a4893fa78cba8cf7b2c903f35c97aaf44fa3031b0669948b480",
server_urls = MAVEN_SERVER_URLS,
)

# test of import external
# scala maven import external decodes maven artifacts to its parts
# (group id, artifact id, packaging, version and classifier). To make sure
# the decoding and then the download url composition are working the artifact example
# must contain all the different parts and sha256s so the downloaded content will be
# validated against it
scala_maven_import_external(
name = "com_github_jnr_jffi_native",
artifact = "com.github.jnr:jffi:jar:native:1.2.17",
artifact_sha256 = "4eb582bc99d96c8df92fc6f0f608fd123d278223982555ba16219bf8be9f75a9",
fetch_sources = True,
licenses = ["notice"],
server_urls = MAVEN_SERVER_URLS,
srcjar_sha256 = "5e586357a289f5fe896f7b48759e1c16d9fa419333156b496696887e613d7a19",
)

jvm_maven_import_external(
name = "org_apache_commons_commons_lang_3_5",
artifact = "org.apache.commons:commons-lang3:3.5",
artifact_sha256 = "8ac96fc686512d777fca85e144f196cd7cfe0c0aec23127229497d1a38ff651c",
server_urls = MAVEN_SERVER_URLS,
)

new_local_repository(
name = "test_new_local_repo",
build_file_content =
Expand All @@ -154,16 +95,6 @@ register_toolchains("@io_bazel_rules_scala//test/proto:scalapb_toolchain")

load("//scala:scala_maven_import_external.bzl", "java_import_external", "scala_maven_import_external")

scala_maven_import_external(
name = "com_google_guava_guava_21_0",
artifact = "com.google.guava:guava:21.0",
artifact_sha256 = "972139718abc8a4893fa78cba8cf7b2c903f35c97aaf44fa3031b0669948b480",
fetch_sources = True,
licenses = ["notice"], # Apache 2.0
server_urls = MAVEN_SERVER_URLS,
srcjar_sha256 = "b186965c9af0a714632fe49b33378c9670f8f074797ab466f49a67e918e116ea",
)

# bazel's java_import_external has been altered in rules_scala to be a macro based on jvm_import_external
# in order to allow for other jvm-language imports (e.g. scala_import)
# the 3rd-party dependency below is using the java_import_external macro
Expand Down Expand Up @@ -228,36 +159,41 @@ rbe_autoconfig(
name = "buildkite_config",
)

## deps for tests of limited deps support

scala_maven_import_external(
name = "org_springframework_spring_core",
artifact = "org.springframework:spring-core:5.1.5.RELEASE",
artifact_sha256 = "f771b605019eb9d2cf8f60c25c050233e39487ff54d74c93d687ea8de8b7285a",
licenses = ["notice"], # Apache 2.0
server_urls = MAVEN_SERVER_URLS,
)

scala_maven_import_external(
name = "org_springframework_spring_tx",
artifact = "org.springframework:spring-tx:5.1.5.RELEASE",
artifact_sha256 = "666f72b73c7e6b34e5bb92a0d77a14cdeef491c00fcb07a1e89eb62b08500135",
licenses = ["notice"], # Apache 2.0
server_urls = MAVEN_SERVER_URLS,
deps = [
"@org_springframework_spring_core",
],
)
load("//third_party/repositories:repositories.bzl", "repositories")

## deps for tests of compiler plugin
scala_maven_import_external(
name = "org_spire_math_kind_projector",
jvm_maven_import_external(
name = "org_typelevel__cats_core",
artifact = scala_mvn_artifact(
"org.spire-math:kind-projector:0.9.10",
"org.typelevel:cats-core:0.9.0",
default_scala_major_version(),
),
artifact_sha256 = "36aca2493302e2c037328107a121cda1d28bf9119fbc04fb47ea1ff9bce3c03f",
fetch_sources = False,
licenses = ["notice"],
artifact_sha256 = "3ca705cba9dc0632e60477d80779006f8c636c0e2e229dda3410a0c314c1ea1d",
server_urls = MAVEN_SERVER_URLS,
)

repositories(
for_artifact_ids = [
# test adding a scala jar:
"com_twitter__scalding_date",
# For testing that we don't include sources jars to the classpath
# "org_typelevel__cats_core",
# test of a plugin
"org_psywerx_hairyfotr__linter",
# test of strict deps (scalac plugin UT + E2E)
"com_google_guava_guava_21_0_with_file",
"com_github_jnr_jffi_native",
"org_apache_commons_commons_lang_3_5",
"com_google_guava_guava_21_0",
# test of import external
# scala maven import external decodes maven artifacts to its parts
# (group id, artifact id, packaging, version and classifier). To make sure
# the decoding and then the download url composition are working the artifact example
# must contain all the different parts and sha256s so the downloaded content will be
# validated against it
"org_springframework_spring_core",
"org_springframework_spring_tx",
"org_spire_math_kind_projector",
],
maven_servers = MAVEN_SERVER_URLS,
scala_version = default_scala_version(),
)
69 changes: 22 additions & 47 deletions jmh/jmh.bzl
Original file line number Diff line number Diff line change
@@ -1,78 +1,53 @@
load("//scala:scala.bzl", "scala_binary", "scala_library")
load(
"//scala:scala_cross_version.bzl",
_default_maven_server_urls = "default_maven_server_urls",
)
load(
"@io_bazel_rules_scala//scala:scala_maven_import_external.bzl",
_scala_maven_import_external = "scala_maven_import_external",
"default_maven_server_urls",
"default_scala_version",
)
load("//third_party/repositories:repositories.bzl", "repositories")

def jmh_repositories(maven_servers = _default_maven_server_urls()):
_scala_maven_import_external(
name = "io_bazel_rules_scala_org_openjdk_jmh_jmh_core",
artifact = "org.openjdk.jmh:jmh-core:1.20",
artifact_sha256 = "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca",
licenses = ["notice"],
server_urls = maven_servers,
def jmh_repositories(
scala_version = default_scala_version(),
maven_servers = default_maven_server_urls(),
overriden_artifacts = {}):
repositories(
for_artifact_ids = [
"io_bazel_rules_scala_org_openjdk_jmh_jmh_core",
"io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm",
"io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection",
"io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection",
"io_bazel_rules_scala_org_ows2_asm_asm",
"io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple",
"io_bazel_rules_scala_org_apache_commons_commons_math3",
],
fetch_sources = False,
scala_version = scala_version,
maven_servers = maven_servers,
overriden_artifacts = {},
)

native.bind(
name = "io_bazel_rules_scala/dependency/jmh/jmh_core",
actual = "@io_bazel_rules_scala_org_openjdk_jmh_jmh_core//jar",
)
_scala_maven_import_external(
name = "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm",
artifact = "org.openjdk.jmh:jmh-generator-asm:1.20",
artifact_sha256 = "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5",
licenses = ["notice"],
server_urls = maven_servers,
)
native.bind(
name = "io_bazel_rules_scala/dependency/jmh/jmh_generator_asm",
actual = "@io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm//jar",
)
_scala_maven_import_external(
name = "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection",
artifact = "org.openjdk.jmh:jmh-generator-reflection:1.20",
artifact_sha256 = "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e",
licenses = ["notice"],
server_urls = maven_servers,
)
native.bind(
name = "io_bazel_rules_scala/dependency/jmh/jmh_generator_reflection",
actual =
"@io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection//jar",
)
_scala_maven_import_external(
name = "io_bazel_rules_scala_org_ows2_asm_asm",
artifact = "org.ow2.asm:asm:6.1.1",
artifact_sha256 = "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833",
licenses = ["notice"],
server_urls = maven_servers,
)
native.bind(
name = "io_bazel_rules_scala/dependency/jmh/org_ows2_asm_asm",
actual = "@io_bazel_rules_scala_org_ows2_asm_asm//jar",
)
_scala_maven_import_external(
name = "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple",
artifact = "net.sf.jopt-simple:jopt-simple:4.6",
artifact_sha256 = "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda",
licenses = ["notice"],
server_urls = maven_servers,
)
native.bind(
name =
"io_bazel_rules_scala/dependency/jmh/net_sf_jopt_simple_jopt_simple",
actual = "@io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple//jar",
)
_scala_maven_import_external(
name = "io_bazel_rules_scala_org_apache_commons_commons_math3",
artifact = "org.apache.commons:commons-math3:3.6.1",
artifact_sha256 = "1e56d7b058d28b65abd256b8458e3885b674c1d588fa43cd7d1cbb9c7ef2b308",
licenses = ["notice"],
server_urls = maven_servers,
)
native.bind(
name =
"io_bazel_rules_scala/dependency/jmh/org_apache_commons_commons_math3",
Expand Down
31 changes: 12 additions & 19 deletions junit/junit.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,24 @@ load(
"//scala:scala_cross_version.bzl",
_default_maven_server_urls = "default_maven_server_urls",
)
load(
"@io_bazel_rules_scala//scala:scala_maven_import_external.bzl",
_scala_maven_import_external = "scala_maven_import_external",
)
load("//third_party/repositories:repositories.bzl", "repositories")

def junit_repositories(maven_servers = _default_maven_server_urls()):
_scala_maven_import_external(
name = "io_bazel_rules_scala_junit_junit",
artifact = "junit:junit:4.12",
artifact_sha256 = "59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a",
licenses = ["notice"],
server_urls = maven_servers,
def junit_repositories(
maven_servers = _default_maven_server_urls(),
fetch_sources = True):
repositories(
for_artifact_ids = [
"io_bazel_rules_scala_junit_junit",
"io_bazel_rules_scala_org_hamcrest_hamcrest_core",
],
fetch_sources = fetch_sources,
maven_servers = maven_servers,
)

native.bind(
name = "io_bazel_rules_scala/dependency/junit/junit",
actual = "@io_bazel_rules_scala_junit_junit//jar",
)

_scala_maven_import_external(
name = "io_bazel_rules_scala_org_hamcrest_hamcrest_core",
artifact = "org.hamcrest:hamcrest-core:1.3",
artifact_sha256 = "66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9",
licenses = ["notice"],
server_urls = maven_servers,
)
native.bind(
name = "io_bazel_rules_scala/dependency/hamcrest/hamcrest_core",
actual = "@io_bazel_rules_scala_org_hamcrest_hamcrest_core//jar",
Expand Down
Loading

0 comments on commit d8f5bd9

Please sign in to comment.