blob: e3c5689b62a536b879b0bd9a1edaa05e717d525c [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):
Ray Milkey5063f5b2018-08-15 16:22:30 -070018 arguments = [
19 ctx.outputs.pom.path,
20 maven_coordinates(ctx.attr.artifact),
21 ]
Thomas Vachuskaac9e5242018-07-19 16:15:39 -070022
Ray Milkey5063f5b2018-08-15 16:22:30 -070023 for dep in ctx.attr.deps:
24 arguments += [maven_coordinates(dep.label)]
Thomas Vachuskaac9e5242018-07-19 16:15:39 -070025
Ray Milkey5063f5b2018-08-15 16:22:30 -070026 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 )
Thomas Vachuskaac9e5242018-07-19 16:15:39 -070033
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"),
Ray Milkey5063f5b2018-08-15 16:22:30 -070043 ),
Thomas Vachuskaac9e5242018-07-19 16:15:39 -070044 },
45 implementation = _impl,
Ray Milkey5063f5b2018-08-15 16:22:30 -070046 outputs = {"pom": "%{name}.pom"},
Thomas Vachuskaac9e5242018-07-19 16:15:39 -070047)