Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/demoapp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ springboot(
bazelrun_script = "custom_bazelrun_script.sh",
boot_app_class = "com.sample.SampleMain",
boot_launcher_class = "org.springframework.boot.loader.launch.JarLauncher",
# Verify that dupe class checking works in this second springboot rule too
dupeclassescheck_enable = True,
dupeclassescheck_ignorelist = "demoapp_dupeclass_allowlist.txt",
java_library = ":demoapp_lib",
deps = [":rootclassloader_lib"],
)
Expand Down
29 changes: 15 additions & 14 deletions springboot/springboot.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ _appjar_locator_rule = rule(

def _dupeclasses_rule_impl(ctx):
# setup the output file (contains SUCCESS, NOT_RUN, or the list of errors)
output = ctx.actions.declare_file(ctx.attr.out)
output = ctx.actions.declare_file(ctx.attr.name + "_results.txt")
outputs = [output]

if not ctx.attr.dupeclassescheck_enable:
Expand Down Expand Up @@ -138,7 +138,6 @@ _dupeclasses_rule = rule(
"springbootjar": attr.label(),
"dupeclassescheck_ignorelist": attr.label(allow_files = True),
"dupeclassescheck_enable": attr.bool(),
"out": attr.string(),
},
)

Expand All @@ -147,7 +146,7 @@ _dupeclasses_rule = rule(

def _javaxdetect_rule_impl(ctx):
# setup the output file (contains SUCCESS, NOT_RUN, or the list of errors)
output = ctx.actions.declare_file(ctx.attr.out)
output = ctx.actions.declare_file(ctx.attr.name + "_results.txt")
outputs = [output]

if not ctx.attr.javaxdetect_enable:
Expand Down Expand Up @@ -192,15 +191,14 @@ _javaxdetect_rule = rule(
"springbootjar": attr.label(),
"javaxdetect_ignorelist": attr.label(allow_files = True),
"javaxdetect_enable": attr.bool(),
"out": attr.string(),
},
)

# ***************************************************************
# BANNED DEPS RULE

def _banneddeps_rule_impl(ctx):
output = ctx.actions.declare_file(ctx.attr.out)
output = ctx.actions.declare_file(ctx.attr.name + "_results.txt")
outputs = [output]

if ctx.attr.deps_banned == None:
Expand Down Expand Up @@ -236,7 +234,6 @@ _banneddeps_rule = rule(
"springboot_rule_name": attr.string(),
"deps_banned": attr.string_list(),
"deps": attr.label_list(),
"out": attr.string(),
},
)

Expand Down Expand Up @@ -325,11 +322,18 @@ def _springboot_rule_impl(ctx):
for data_target in data_target.files.to_list():
runfiles_list.append(data_target)

return [DefaultInfo(
files = outs,
executable = outer_bazelrun_script_file,
runfiles = ctx.runfiles(files = runfiles_list),
)]
validations = ctx.files.dupecheck_rule + ctx.files.javaxdetect_rule + ctx.files.banneddeps_rule

return [
DefaultInfo(
files = outs,
executable = outer_bazelrun_script_file,
runfiles = ctx.runfiles(files = runfiles_list),
),
# Special output group for validation results that ensures they are put into the critical
# path of the build. https://bazel.build/versions/8.4.0/extending/rules#validation_actions
OutputGroupInfo(_validation = validations),
]

_springboot_rule = rule(
implementation = _springboot_rule_impl,
Expand Down Expand Up @@ -644,7 +648,6 @@ def springboot(
springbootjar = genjar_rule,
dupeclassescheck_enable = dupeclassescheck_enable,
dupeclassescheck_ignorelist = dupeclassescheck_ignorelist,
out = "dupecheck_results.txt",
tags = tags,
testonly = testonly,
restricted_to = restricted_to,
Expand All @@ -664,7 +667,6 @@ def springboot(
springbootjar = genjar_rule,
javaxdetect_enable = javaxdetect_enable,
javaxdetect_ignorelist = javaxdetect_ignorelist,
out = "javaxdetect_results.txt",
tags = tags,
testonly = testonly,
restricted_to = restricted_to,
Expand All @@ -683,7 +685,6 @@ def springboot(
name = bannedcheck_rule,
deps = [":" + dep_aggregator_rule],
deps_banned = deps_banned,
out = "bannedcheck_results.txt",
tags = tags,
testonly = testonly,
restricted_to = restricted_to,
Expand Down