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

java_export: Fix Make variable substitution #960

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion private/rules/java_export.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -108,6 +109,7 @@ def java_export(
classifier_artifacts = classifier_artifacts,
doc_deps = doc_deps,
doc_url = doc_url,
toolchains = toolchains,
)

def maven_export(
Expand All @@ -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.
Expand Down Expand Up @@ -210,6 +213,7 @@ def maven_export(
visibility = visibility,
tags = tags + maven_coordinates_tags,
testonly = testonly,
toolchains = toolchains,
)

native.filegroup(
Expand Down Expand Up @@ -251,6 +255,7 @@ def maven_export(
visibility = visibility,
tags = tags,
testonly = testonly,
toolchains = toolchains,
)
classifier_artifacts.setdefault("javadoc", docs_jar)

Expand All @@ -262,6 +267,7 @@ def maven_export(
visibility = visibility,
tags = tags,
testonly = testonly,
toolchains = toolchains,
)

maven_publish(
Expand All @@ -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
Expand All @@ -287,6 +294,7 @@ def maven_export(
testonly = testonly,
tags = tags,
visibility = visibility,
toolchains = toolchains,
)

# Finally, alias the primary output
Expand Down
6 changes: 5 additions & 1 deletion private/rules/pom_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ 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)

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,
)
Expand Down