From cf37615534b85d2a9bd36a8fc7208ee51e4f89f6 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Wed, 20 Sep 2023 13:40:24 +0200 Subject: [PATCH] java_export: Fix Make variable substitution This requires forwarding `toolchains` to all rules as well as evaluating Make variables for dependency coordinates in `pom_file`. --- private/rules/java_export.bzl | 10 +++++++++- private/rules/pom_file.bzl | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/private/rules/java_export.bzl b/private/rules/java_export.bzl index 81138db1f..51618e824 100644 --- a/private/rules/java_export.bzl +++ b/private/rules/java_export.bzl @@ -84,6 +84,7 @@ def java_export( javadocopts = kwargs.pop("javadocopts", []) doc_deps = kwargs.pop("doc_deps", []) doc_url = kwargs.pop("doc_url", "") + toolchains = kwargs.pop("toolchains", []) # Construct the java_library we'll export from here. native.java_library( @@ -108,6 +109,7 @@ def java_export( classifier_artifacts = classifier_artifacts, doc_deps = doc_deps, doc_url = doc_url, + toolchains = toolchains, ) def maven_export( @@ -124,7 +126,8 @@ def maven_export( classifier_artifacts = {}, *, doc_deps = [], - doc_url = ""): + doc_url = "", + toolchains = None): """ All arguments are the same as java_export with the addition of: lib_name: Name of the library that has been built. @@ -210,6 +213,7 @@ def maven_export( visibility = visibility, tags = tags + maven_coordinates_tags, testonly = testonly, + toolchains = toolchains, ) native.filegroup( @@ -251,6 +255,7 @@ def maven_export( visibility = visibility, tags = tags, testonly = testonly, + toolchains = toolchains, ) classifier_artifacts.setdefault("javadoc", docs_jar) @@ -262,6 +267,7 @@ def maven_export( visibility = visibility, tags = tags, testonly = testonly, + toolchains = toolchains, ) maven_publish( @@ -273,6 +279,7 @@ def maven_export( visibility = visibility, tags = tags, testonly = testonly, + toolchains = toolchains, ) # We may want to aggregate several `java_export` targets into a single Maven BOM POM @@ -287,6 +294,7 @@ def maven_export( testonly = testonly, tags = tags, visibility = visibility, + toolchains = toolchains, ) # Finally, alias the primary output diff --git a/private/rules/pom_file.bzl b/private/rules/pom_file.bzl index eba5306e9..2f8b74b0b 100644 --- a/private/rules/pom_file.bzl +++ b/private/rules/pom_file.bzl @@ -15,6 +15,10 @@ def _pom_file_impl(ctx): for dep in additional_deps: for coords in dep[MavenInfo].as_maven_dep.to_list(): all_maven_deps.append(coords) + expanded_maven_deps = [ + ctx.expand_make_variables("additional_deps", coords, ctx.var) + for coords in all_maven_deps + ] # Expand maven coordinates for any variables to be replaced. coordinates = ctx.expand_make_variables("coordinates", info.coordinates, ctx.var) @@ -22,7 +26,7 @@ def _pom_file_impl(ctx): out = generate_pom( ctx, coordinates = coordinates, - versioned_dep_coordinates = sorted(all_maven_deps), + versioned_dep_coordinates = sorted(expanded_maven_deps), pom_template = ctx.file.pom_template, out_name = "%s.xml" % ctx.label.name, )