blob: 792d35a3c7655fc776696314e8042ed1c54e31d3 [file] [log] [blame]
Thomas Vachuskaac9e5242018-07-19 16:15:39 -07001# Copyright 2015 The Bazel Authors. All rights reserved.
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
15load("//tools/build/bazel:generate_workspace.bzl", "maven_coordinates")
16
17def _impl(ctx):
18 arguments = [
19 ctx.outputs.pom.path,
20 maven_coordinates(ctx.attr.artifact)
21 ]
22
23 for dep in ctx.attr.deps:
24 arguments += [ maven_coordinates(dep.label) ]
25
26 ctx.actions.run(
27 inputs = ctx.files.deps,
28 outputs = [ctx.outputs.pom],
29 progress_message = "Generating pom file for %s" % ctx.attr.name,
30 arguments = arguments,
31 executable = ctx.executable._pom_generator,
32 )
33
34pom_file = rule(
35 attrs = {
36 "artifact": attr.string(),
37 "deps": attr.label_list(allow_files = True),
38 "_pom_generator": attr.label(
39 executable = True,
40 cfg = "host",
41 allow_files = True,
42 default = Label("//tools/build/bazel:pom_generator"),
43 )
44 },
45 implementation = _impl,
46 outputs = {"pom" : "%{name}.pom"},
47)
48