blob: 36e3084e78f79e4c73fbdc96b759ba0dc3358dfc [file] [log] [blame]
David Ostrovskyb81b4f72016-05-21 19:55:01 +02001# Copyright (C) 2016 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Merge maven files
16
David Ostrovsky20c2fd42019-08-30 10:19:56 +020017load("@rules_java//java:defs.bzl", "java_import")
18
David Ostrovskyb81b4f72016-05-21 19:55:01 +020019def cmd(jars):
Han-Wen Nienhuysb6a40482018-07-10 11:51:36 +020020 return ("$(location //tools:merge_jars) $@ " +
21 " ".join(["$(location %s)" % j for j in jars]))
David Ostrovskyb81b4f72016-05-21 19:55:01 +020022
Yuxuan 'fishy' Wang75b98f72016-09-24 06:31:27 +080023def merge_maven_jars(name, srcs, **kwargs):
Han-Wen Nienhuysb6a40482018-07-10 11:51:36 +020024 native.genrule(
25 name = "%s__merged_bin" % name,
26 cmd = cmd(srcs),
27 tools = srcs + ["//tools:merge_jars"],
28 outs = ["%s__merged.jar" % name],
29 )
David Ostrovsky20c2fd42019-08-30 10:19:56 +020030 java_import(
Han-Wen Nienhuysb6a40482018-07-10 11:51:36 +020031 name = name,
32 jars = [":%s__merged_bin" % name],
33 **kwargs
34 )