daml/bazel_tools/pkg.bzl

76 lines
2.2 KiB
Python
Raw Normal View History

# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2019-04-04 11:33:38 +03:00
# SPDX-License-Identifier: Apache-2.0
load("@bazel_skylib//lib:paths.bzl", "paths")
Upload proto and deploy jars to maven (#3507) * Add helper to produce an empty zip files. This is used to generate empty sources and javadoc jars for deploy jars later on. * Create empty auxilliary jars. da_java_binary: - empty javadoc jar - empty sources jar da_java_proto_library: - empty javadoc jar - the sources jar is automatically generated by java_proto_library as a side effect da_scala_binary: - empty javadoc jar - empty sources jar * Support maven upload for jar-deploy and jar-proto For jar-deploy targets we don't check for internal dependencies, because these should already be contained in the (fat-)jar itself. Additionally, the release program now uploads javadocs and sources for jar-proto and jar-deploy as well to comply with maven central. * Upload ledger-api-test-tool and kvutils + dependencies to maven central. This is the diff running the output of the release without and with these changes. A few artifacts now also get their javadoc and sources uploaded (mostly to bintray, but now they are ready for a maven central upload). ledger-api-test-tool has the scala version removed from the artifact as it is a deploy jar and nobody should care which specific scala version is used. Only in release/com/daml/ledger/participant-state-kvutils-java-proto/100.13.35: participant-state-kvutils-java-proto-100.13.35-javadoc.jar Only in release/com/daml/ledger/participant-state-kvutils-java-proto/100.13.35: participant-state-kvutils-java-proto-100.13.35-sources.jar Only in release/com/daml/ledger/testtool: ledger-api-test-tool Only in release-before/com/daml/ledger/testtool: ledger-api-test-tool_2.12 Only in release/com/digitalasset/daml/lf/engine/trigger/runner_2.12/100.13.35: runner_2.12-100.13.35-javadoc.jar Only in release/com/digitalasset/daml/lf/engine/trigger/runner_2.12/100.13.35: runner_2.12-100.13.35-sources.jar Only in release/com/digitalasset/daml-lf-blindinginfo-java-proto/100.13.35: daml-lf-blindinginfo-java-proto-100.13.35-javadoc.jar Only in release/com/digitalasset/daml-lf-blindinginfo-java-proto/100.13.35: daml-lf-blindinginfo-java-proto-100.13.35-sources.jar Only in release/com/digitalasset/daml-lf-transaction-java-proto/100.13.35: daml-lf-transaction-java-proto-100.13.35-javadoc.jar Only in release/com/digitalasset/daml-lf-transaction-java-proto/100.13.35: daml-lf-transaction-java-proto-100.13.35-sources.jar Only in release/com/digitalasset/daml-lf-value-java-proto/100.13.35: daml-lf-value-java-proto-100.13.35-javadoc.jar Only in release/com/digitalasset/daml-lf-value-java-proto/100.13.35: daml-lf-value-java-proto-100.13.35-sources.jar Only in release/com/digitalasset/damlc/100.13.35: damlc-100.13.35-javadoc.jar Only in release/com/digitalasset/damlc/100.13.35: damlc-100.13.35-sources.jar Only in release/com/digitalasset/extractor/100.13.35: extractor-100.13.35-javadoc.jar Only in release/com/digitalasset/extractor/100.13.35: extractor-100.13.35-sources.jar Only in release/com/digitalasset/ledger-service/http-json-deploy/100.13.35: http-json-deploy-100.13.35-javadoc.jar Only in release/com/digitalasset/ledger-service/http-json-deploy/100.13.35: http-json-deploy-100.13.35-sources.jar Only in release/com/digitalasset/navigator/100.13.35: navigator-100.13.35-javadoc.jar Only in release/com/digitalasset/navigator/100.13.35: navigator-100.13.35-sources.jar
2019-11-18 16:40:15 +03:00
def pkg_empty_zip(name, out):
native.genrule(
name = name,
srcs = [],
outs = [out],
# minimal empty zip file in Base64 encoding
cmd = "echo UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA== | base64 -d > $@",
)
def _unpack_tar_impl(ctx):
outputs = []
for out in ctx.attr.outs:
if out.endswith("/"):
outputs.append(ctx.actions.declare_directory(out[:-1]))
else:
outputs.append(ctx.actions.declare_file(out))
src = ctx.file.src
args = ctx.actions.args()
if src.path.endswith(".tar.gz") or src.path.endswith(".tgz"):
command = "gzip -cd {src} | tar x $@".format(
src = src.path,
)
else:
command = "tar xf {src} $@".format(
src = src.path,
)
if ctx.attr.strip:
args.add_all(["--strip", ctx.attr.strip])
prefix = paths.join(
ctx.bin_dir.path,
ctx.label.workspace_root,
ctx.label.package,
ctx.attr.prefix,
)
args.add_all(["-C", prefix])
ctx.actions.run_shell(
outputs = outputs,
inputs = [ctx.file.src],
command = command,
arguments = [args],
mnemonic = "UnpackTar",
progress_message = "Unpacking {} to {}".format(
ctx.attr.src.label,
prefix,
),
)
return [DefaultInfo(
files = depset(direct = outputs),
)]
unpack_tar = rule(
_unpack_tar_impl,
attrs = dict(
src = attr.label(
doc = "The archive to unpack.",
# Add further extensions on demand.
allow_single_file = [".tar", ".tar.gz", ".tgz"],
mandatory = True,
),
outs = attr.string_list(
doc = "The outputs to capture. Mark directory outputs with a `/` suffix.",
),
strip = attr.int(
doc = "Strip this many leading components from file names on extraction.",
),
prefix = attr.string(
doc = "Add this prefix to the unpacked paths, relative to the current package.",
),
),
)