Skip to content

Commit

Permalink
Propagate bazel tags= in java_export sub-targets (bazel-contrib#647)
Browse files Browse the repository at this point in the history
One use-case is using tags=["manual"] to exclude building of these targets by default.
  • Loading branch information
dmivankov authored Jan 17, 2022
1 parent d00c1ae commit 77225e0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions private/rules/java_export.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ def java_export(
and so may contain any valid parameter for that rule.
"""

tags = tags + ["maven_coordinates=%s" % maven_coordinates]
maven_coordinates_tags = ["maven_coordinates=%s" % maven_coordinates]
lib_name = "%s-lib" % name

javadocopts = kwargs.pop("javadocopts", [])

# Construct the java_library we'll export from here.
native.java_library(
name = lib_name,
tags = tags,
tags = tags + maven_coordinates_tags,
**kwargs
)

Expand All @@ -78,7 +78,7 @@ def java_export(
name = "%s-project" % name,
target = ":%s" % lib_name,
deploy_env = deploy_env,
tags = tags,
tags = tags + maven_coordinates_tags,
)

native.filegroup(
Expand All @@ -87,6 +87,7 @@ def java_export(
":%s-project" % name,
],
output_group = "maven_artifact",
tags = tags,
)

native.filegroup(
Expand All @@ -95,6 +96,7 @@ def java_export(
":%s-project" % name,
],
output_group = "maven_source",
tags = tags,
)

docs_jar = None
Expand All @@ -105,13 +107,15 @@ def java_export(
deps = [
":%s-project" % name,
],
javadocopts = javadocopts
javadocopts = javadocopts,
tags = tags,
)

pom_file(
name = "%s-pom" % name,
target = ":%s" % lib_name,
pom_template = pom_template,
tags = tags,
)

maven_publish(
Expand All @@ -122,11 +126,13 @@ def java_export(
artifact_jar = ":%s-maven-artifact" % name,
source_jar = ":%s-maven-source" % name,
visibility = visibility,
tags = tags,
)

# Finally, alias the primary output
native.alias(
name = name,
actual = ":%s-project" % name,
visibility = visibility,
tags = tags,
)

0 comments on commit 77225e0

Please sign in to comment.