Run 'buildifer -r .' to format all Bazel files (#804)
diff --git a/WORKSPACE.bzl b/WORKSPACE.bzl index c7bbb23..ffd939c 100644 --- a/WORKSPACE.bzl +++ b/WORKSPACE.bzl
@@ -1 +1 @@ -workspace(name = "rules_jvm_external") \ No newline at end of file +workspace(name = "rules_jvm_external")
diff --git a/coursier.bzl b/coursier.bzl index 4919a24..c0ed639 100644 --- a/coursier.bzl +++ b/coursier.bzl
@@ -191,18 +191,19 @@ if len(absolute_path_parts) != 2: fail("Error while trying to parse the path of file in the coursier cache: " + absolute_path) else: - relative_path = absolute_path_parts[1] - # Coursier prefixes private repositories with the username, which obfuscates - # changes to the pinned json so we remove it from the relative path. - credential_marker = relative_path.find("%40") - if credential_marker > -1: - user_prefix = relative_path[:credential_marker+3].split("/")[-1] - relative_path = relative_path.replace(user_prefix, "") + relative_path = absolute_path_parts[1] - # Make a symlink from the absolute path of the artifact to the relative - # path within the output_base/external. - artifact_relative_path = "v1" + relative_path - repository_ctx.symlink(absolute_path, repository_ctx.path(artifact_relative_path)) + # Coursier prefixes private repositories with the username, which obfuscates + # changes to the pinned json so we remove it from the relative path. + credential_marker = relative_path.find("%40") + if credential_marker > -1: + user_prefix = relative_path[:credential_marker + 3].split("/")[-1] + relative_path = relative_path.replace(user_prefix, "") + + # Make a symlink from the absolute path of the artifact to the relative + # path within the output_base/external. + artifact_relative_path = "v1" + relative_path + repository_ctx.symlink(absolute_path, repository_ctx.path(artifact_relative_path)) return artifact_relative_path # Relativize an absolute path to an artifact in maven local. @@ -1049,15 +1050,14 @@ # https://repo1.maven.org/maven2/org/threeten/threetenbp/1.3.3/threetenbp-1.3.3.jar primary_url = "".join(primary_url_parts).replace("%3A", ":").replace("%40", "@") - # Coursier prepends the username from the provided credentials if needed to authenticate # with the repository. We remove it from the url and file attributes if only the username is present # and no password, as it has noe function and obfuscates changes to the pinned json credential_marker = primary_url.find("@") if credential_marker > -1: - potential_credentials = remove_prefix(primary_url[:credential_marker+1], protocol + "://") - if len(potential_credentials.split(':')) == 1: - primary_url = primary_url.replace(potential_credentials, "") + potential_credentials = remove_prefix(primary_url[:credential_marker + 1], protocol + "://") + if len(potential_credentials.split(":")) == 1: + primary_url = primary_url.replace(potential_credentials, "") artifact.update({"url": primary_url})
diff --git a/examples/android_instrumentation_test/WORKSPACE b/examples/android_instrumentation_test/WORKSPACE index 4226429..345c2a8 100644 --- a/examples/android_instrumentation_test/WORKSPACE +++ b/examples/android_instrumentation_test/WORKSPACE
@@ -82,4 +82,4 @@ rbe_preconfig( name = "rbe_default", toolchain = "ubuntu1804-bazel-java11", -) \ No newline at end of file +)
diff --git a/examples/android_kotlin_app/WORKSPACE b/examples/android_kotlin_app/WORKSPACE index 8ac8c85..84e19e2 100644 --- a/examples/android_kotlin_app/WORKSPACE +++ b/examples/android_kotlin_app/WORKSPACE
@@ -8,15 +8,17 @@ # BEGIN io_bazel_rules_kotlin http_archive( name = "io_bazel_rules_kotlin", - urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v1.7.0-RC-2/rules_kotlin_release.tgz"], sha256 = "946747acdbeae799b085d12b240ec346f775ac65236dfcf18aa0cd7300f6de78", + urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v1.7.0-RC-2/rules_kotlin_release.tgz"], ) load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories") -kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below + +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() # to use the default toolchain, otherwise see toolchains below + +kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below # END io_bazel_rules_kotlin local_repository(
diff --git a/examples/bzlmod/WORKSPACE b/examples/bzlmod/WORKSPACE index ee6017c..d565013 100644 --- a/examples/bzlmod/WORKSPACE +++ b/examples/bzlmod/WORKSPACE
@@ -25,4 +25,4 @@ load("@maven//:defs.bzl", "pinned_maven_install") -pinned_maven_install() \ No newline at end of file +pinned_maven_install()
diff --git a/examples/java-export/BUILD b/examples/java-export/BUILD index 954a482..74810c9 100644 --- a/examples/java-export/BUILD +++ b/examples/java-export/BUILD
@@ -17,10 +17,10 @@ maven_bom( name = "bom", + dependencies_maven_coordinates = "com.example:bazel-example-dependencies:0.0.1", java_exports = [ ":example-export", "//src/main/java/com/github/bazelbuild/rulesjvmexternal/example/io", ], maven_coordinates = "com.example:bazel-example-bom:0.0.1", - dependencies_maven_coordinates = "com.example:bazel-example-dependencies:0.0.1", )
diff --git a/examples/kt_android_local_test/WORKSPACE b/examples/kt_android_local_test/WORKSPACE index d008dc0..2cdedfb 100644 --- a/examples/kt_android_local_test/WORKSPACE +++ b/examples/kt_android_local_test/WORKSPACE
@@ -21,15 +21,17 @@ # BEGIN io_bazel_rules_kotlin http_archive( name = "io_bazel_rules_kotlin", - urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v1.7.0-RC-2/rules_kotlin_release.tgz"], sha256 = "946747acdbeae799b085d12b240ec346f775ac65236dfcf18aa0cd7300f6de78", + urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v1.7.0-RC-2/rules_kotlin_release.tgz"], ) load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories") -kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below + +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() # to use the default toolchain, otherwise see toolchains below + +kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below # END io_bazel_rules_kotlin local_repository(
diff --git a/examples/kt_jvm_export/BUILD b/examples/kt_jvm_export/BUILD index a9cda06..024316a 100644 --- a/examples/kt_jvm_export/BUILD +++ b/examples/kt_jvm_export/BUILD
@@ -9,11 +9,11 @@ kt_jvm_export( name = "example-export", + deploy_env = [ + "@com_github_jetbrains_kotlin//:kotlin-stdlib", + ], maven_coordinates = "com.example:bazel-example:0.0.1", runtime_deps = [ "//examples/kt_jvm_export/src/main/kotlin/com/github/bazelbuild/rulesjvmexternal/example/export", ], - deploy_env = [ - "@com_github_jetbrains_kotlin//:kotlin-stdlib", - ], )
diff --git a/examples/spring_boot/WORKSPACE b/examples/spring_boot/WORKSPACE index 8908c82..d2e3bc4 100644 --- a/examples/spring_boot/WORKSPACE +++ b/examples/spring_boot/WORKSPACE
@@ -2,6 +2,7 @@ name = "rules_jvm_external", path = "../../", ) + load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") rules_jvm_external_deps()
diff --git a/private/coursier_utilities.bzl b/private/coursier_utilities.bzl index 1953c70..0a3ac18 100644 --- a/private/coursier_utilities.bzl +++ b/private/coursier_utilities.bzl
@@ -15,7 +15,7 @@ # For example, some jars have the type "eclipse-plugin", and Coursier would not # download them if it's not asked to to resolve "eclipse-plugin". -load ("//:specs.bzl", "parse") +load("//:specs.bzl", "parse") SUPPORTED_PACKAGING_TYPES = [ "jar", @@ -38,7 +38,7 @@ "linux-x86_64", "osx-aarch_64", "osx-x86_64", - "windows-x86_64" + "windows-x86_64", ] def strip_packaging_and_classifier(coord): @@ -80,7 +80,6 @@ # Get classifier from the following maven coordinate return parse.parse_maven_coordinate(coord).get("classifier", None) - def escape(string): for char in [".", "-", ":", "/", "+"]: string = string.replace(char, "_") @@ -88,4 +87,4 @@ def is_maven_local_path(absolute_path): # Return whether or not the provided absolute path corresponds to maven local - return absolute_path and len(absolute_path.split(".m2/repository")) == 2 + return absolute_path and len(absolute_path.split(".m2/repository")) == 2
diff --git a/private/dependency_tree_parser.bzl b/private/dependency_tree_parser.bzl index 3b1b4b1..8515bf5 100644 --- a/private/dependency_tree_parser.bzl +++ b/private/dependency_tree_parser.bzl
@@ -19,14 +19,14 @@ load( "//private:coursier_utilities.bzl", + "PLATFORM_CLASSIFIER", "escape", "get_classifier", "get_packaging", + "is_maven_local_path", "match_group_and_artifact", "strip_packaging_and_classifier", "strip_packaging_and_classifier_and_version", - "PLATFORM_CLASSIFIER", - "is_maven_local_path" ) JETIFY_INCLUDE_LIST_JETIFY_ALL = ["*"] @@ -89,9 +89,10 @@ for artifact in dep_tree["dependencies"]: if get_classifier(artifact["coord"]) == "sources": artifact_path = artifact["file"] + # Skip the maven local dependencies if requested if skip_maven_local_dependencies and is_maven_local_path(artifact_path): - continue + continue if artifact_path != None and artifact_path not in seen_imports: seen_imports[artifact_path] = True target_label = escape(strip_packaging_and_classifier_and_version(artifact["coord"])) @@ -219,8 +220,8 @@ # If we have matching artifacts with platform classifiers, skip adding this dependency. # See https://github.com/bazelbuild/rules_jvm_external/issues/686 if match_group_and_artifact(artifact["coord"], dep) and \ - get_classifier(artifact["coord"]) in PLATFORM_CLASSIFIER and \ - get_classifier(dep) in PLATFORM_CLASSIFIER: + get_classifier(artifact["coord"]) in PLATFORM_CLASSIFIER and \ + get_classifier(dep) in PLATFORM_CLASSIFIER: continue # Coursier returns cyclic dependencies sometimes. Handle it here.
diff --git a/private/rules/kt_jvm_export.bzl b/private/rules/kt_jvm_export.bzl index 05b5089..b030fe3 100644 --- a/private/rules/kt_jvm_export.bzl +++ b/private/rules/kt_jvm_export.bzl
@@ -84,5 +84,5 @@ tags, testonly, lib_name, - javadocopts + javadocopts, )
diff --git a/tests/integration/kt_jvm_export/BUILD b/tests/integration/kt_jvm_export/BUILD index afb7ddc..6fa02f5 100644 --- a/tests/integration/kt_jvm_export/BUILD +++ b/tests/integration/kt_jvm_export/BUILD
@@ -3,8 +3,8 @@ kt_jvm_export( name = "test", srcs = [ - "Main.kt", "Dependency.kt", + "Main.kt", ], maven_coordinates = "com.example:kt:1.0.0", )