forked from hswaw/hscloud
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
load("//bzl:rules.bzl", copy_binary="copy_go_binary")
|
|
|
|
def _plugin_yml_gen_impl(ctx):
|
|
ctx.actions.run(
|
|
mnemonic = "PluginYmlGen",
|
|
progress_message = "Generating plugin.yml",
|
|
|
|
inputs = [ctx.info_file],
|
|
outputs = [ctx.outputs.out],
|
|
executable = ctx.executable._genpluginyml,
|
|
arguments = [
|
|
"-name", ctx.label.name,
|
|
"-author", ctx.attr.author,
|
|
"-main", ctx.attr.main,
|
|
"-version", ctx.attr.version,
|
|
"-status_file", ctx.info_file.path,
|
|
"-out_file", ctx.outputs.out.path,
|
|
],
|
|
)
|
|
|
|
plugin_yml_gen = rule(
|
|
implementation = _plugin_yml_gen_impl,
|
|
attrs = {
|
|
"main": attr.string(mandatory = True),
|
|
"version": attr.string(default = ""),
|
|
"author": attr.string(default = "bazel"),
|
|
"_genpluginyml": attr.label(
|
|
default = Label("//personal/q3k/minecraft/plugin:genpluginyml"),
|
|
cfg = "host",
|
|
executable = True,
|
|
allow_files = True,
|
|
),
|
|
},
|
|
outputs = {
|
|
"out": "plugin.yml",
|
|
},
|
|
)
|
|
|
|
def bukkit_plugin(name, srcs, deps, main, author="", version=""):
|
|
ymlname = name + "-yml"
|
|
plugin_yml_gen(
|
|
name = ymlname,
|
|
author = author,
|
|
version = version,
|
|
main = main,
|
|
)
|
|
|
|
jarname = name + "-jar"
|
|
native.java_binary(
|
|
name = jarname,
|
|
create_executable = False,
|
|
srcs = srcs,
|
|
deps = deps,
|
|
classpath_resources = [":" + ymlname],
|
|
)
|
|
|
|
copy_binary(
|
|
name = name + ".jar",
|
|
src = ":" + jarname + "_deploy.jar",
|
|
)
|
|
native.alias(
|
|
name = name,
|
|
actual = ":" + name + ".jar",
|
|
)
|