blob: 898b057e282a71cc48aff480fc89db2b01f61843 [file] [log] [blame]
Sergiusz Bazanski32f8a582020-05-18 00:27:23 +02001load("//bzl:rules.bzl", copy_binary="copy_go_binary")
2
3def _plugin_yml_gen_impl(ctx):
4 ctx.actions.run(
5 mnemonic = "PluginYmlGen",
6 progress_message = "Generating plugin.yml",
7
8 inputs = [ctx.info_file],
9 outputs = [ctx.outputs.out],
10 executable = ctx.executable._genpluginyml,
11 arguments = [
12 "-name", ctx.label.name,
13 "-author", ctx.attr.author,
14 "-main", ctx.attr.main,
15 "-version", ctx.attr.version,
16 "-status_file", ctx.info_file.path,
17 "-out_file", ctx.outputs.out.path,
18 ],
19 )
20
21plugin_yml_gen = rule(
22 implementation = _plugin_yml_gen_impl,
23 attrs = {
24 "main": attr.string(mandatory = True),
25 "version": attr.string(default = ""),
26 "author": attr.string(default = "bazel"),
27 "_genpluginyml": attr.label(
28 default = Label("//personal/q3k/minecraft/plugin:genpluginyml"),
29 cfg = "host",
30 executable = True,
31 allow_files = True,
32 ),
33 },
34 outputs = {
35 "out": "plugin.yml",
36 },
37)
38
39def bukkit_plugin(name, srcs, deps, main, author="", version=""):
40 ymlname = name + "-yml"
41 plugin_yml_gen(
42 name = ymlname,
43 author = author,
44 version = version,
45 main = main,
46 )
47
48 jarname = name + "-jar"
49 native.java_binary(
50 name = jarname,
51 create_executable = False,
52 srcs = srcs,
53 deps = deps,
54 classpath_resources = [":" + ymlname],
55 )
56
57 copy_binary(
58 name = name + ".jar",
59 src = ":" + jarname + "_deploy.jar",
60 )
61 native.alias(
62 name = name,
63 actual = ":" + name + ".jar",
64 )