@@ -222,9 +222,9 @@ def _banneddeps_rule_impl(ctx):
222
222
223
223
if found_banned :
224
224
ctx .actions .write (output , "FAIL" , is_executable = False )
225
- fail ("Found banned jars in the springboot rule [" + ctx .label .name
226
- + "] dependency list. Filenames:\n " + banned_filenames
227
- + "\n You can ignore these by setting deps_banned = [] on the springboot() rule.\n " )
225
+ fail ("Found banned jars in the springboot rule [" + ctx .label .name +
226
+ "] dependency list. Filenames:\n " + banned_filenames +
227
+ "\n You can ignore these by setting deps_banned = [] on the springboot() rule.\n " )
228
228
else :
229
229
ctx .actions .write (output , "SUCCESS" , is_executable = False )
230
230
return [DefaultInfo (files = depset (outputs ))]
@@ -237,11 +237,9 @@ _banneddeps_rule = rule(
237
237
"deps_banned" : attr .string_list (),
238
238
"deps" : attr .label_list (),
239
239
"out" : attr .string (),
240
- }
240
+ },
241
241
)
242
242
243
-
244
-
245
243
# ***************************************************************
246
244
# Outer launcher script for "bazel run"
247
245
@@ -297,21 +295,21 @@ def _springboot_rule_impl(ctx):
297
295
# into the _bazelrun_script_template text defined above
298
296
outer_bazelrun_script_contents = _bazelrun_script_template \
299
297
.replace ("%bazelrun_script%" , ctx .attr .bazelrun_script .files .to_list ()[0 ].short_path ) \
300
- .replace ("%name%" , ctx .attr .name )
298
+ .replace ("%name%" , ctx .attr .name )
301
299
302
300
# the bazelrun_java_toolchain optional, if set, we use it as the jvm for bazel run
303
301
if ctx .attr .bazelrun_java_toolchain != None :
304
- # lookup the path to selected java toolchain, and string sub it into the bazel run script
305
- # text _bazelrun_script_template defined above
306
- java_runtime = ctx .attr .bazelrun_java_toolchain [java_common .JavaToolchainInfo ].java_runtime
307
- java_bin = [f for f in java_runtime .files .to_list () if f .path .endswith ("bin/java" ) or f .path .endswith ("bin/java.exe" )][0 ]
308
- outer_bazelrun_script_contents = outer_bazelrun_script_contents \
309
- .replace ("%java_toolchain_attr%" , java_bin .path )
310
- outer_bazelrun_script_contents = outer_bazelrun_script_contents \
311
- .replace ("%java_toolchain_name_attr%" , ctx .attr .bazelrun_java_toolchain .label .name )
302
+ # lookup the path to selected java toolchain, and string sub it into the bazel run script
303
+ # text _bazelrun_script_template defined above
304
+ java_runtime = ctx .attr .bazelrun_java_toolchain [java_common .JavaToolchainInfo ].java_runtime
305
+ java_bin = [f for f in java_runtime .files .to_list () if f .path .endswith ("bin/java" ) or f .path .endswith ("bin/java.exe" )][0 ]
306
+ outer_bazelrun_script_contents = outer_bazelrun_script_contents \
307
+ .replace ("%java_toolchain_attr%" , java_bin .path )
308
+ outer_bazelrun_script_contents = outer_bazelrun_script_contents \
309
+ .replace ("%java_toolchain_name_attr%" , ctx .attr .bazelrun_java_toolchain .label .name )
312
310
else :
313
- outer_bazelrun_script_contents = outer_bazelrun_script_contents \
314
- .replace ("%java_toolchain_attr%" , "" )
311
+ outer_bazelrun_script_contents = outer_bazelrun_script_contents \
312
+ .replace ("%java_toolchain_attr%" , "" )
315
313
316
314
outer_bazelrun_script_file = ctx .actions .declare_file ("%s" % ctx .label .name )
317
315
ctx .actions .write (outer_bazelrun_script_file , outer_bazelrun_script_contents , is_executable = True )
@@ -323,9 +321,9 @@ def _springboot_rule_impl(ctx):
323
321
324
322
# and add any data files to runfiles
325
323
if ctx .attr .bazelrun_data != None :
326
- for data_target in ctx .attr .bazelrun_data :
327
- for data_target in data_target .files .to_list ():
328
- runfiles_list .append (data_target )
324
+ for data_target in ctx .attr .bazelrun_data :
325
+ for data_target in data_target .files .to_list ():
326
+ runfiles_list .append (data_target )
329
327
330
328
return [DefaultInfo (
331
329
files = outs ,
@@ -347,10 +345,8 @@ _springboot_rule = rule(
347
345
"javaxdetect_rule" : attr .label (),
348
346
"banneddeps_rule" : attr .label (),
349
347
"apprun_rule" : attr .label (),
350
-
351
- "bazelrun_script" : attr .label (allow_files = True ),
352
- "bazelrun_data" : attr .label_list (allow_files = True ),
353
-
348
+ "bazelrun_script" : attr .label (allow_files = True ),
349
+ "bazelrun_data" : attr .label_list (allow_files = True ),
354
350
"bazelrun_java_toolchain" : attr .label (
355
351
mandatory = False ,
356
352
default = "@bazel_tools//tools/jdk:current_java_toolchain" ,
@@ -368,7 +364,7 @@ def springboot(
368
364
boot_app_class ,
369
365
boot_launcher_class = "org.springframework.boot.loader.JarLauncher" ,
370
366
deps = None ,
371
- deps_banned = [ "junit" , "mockito" , ], # detects common mistake of test dep pollution
367
+ deps_banned = ["junit" , "mockito" ], # detects common mistake of test dep pollution
372
368
deps_exclude = None ,
373
369
deps_exclude_paths = None ,
374
370
deps_index_file = None ,
@@ -377,7 +373,7 @@ def springboot(
377
373
dupeclassescheck_ignorelist = None ,
378
374
javaxdetect_enable = None ,
379
375
javaxdetect_ignorelist = None ,
380
- include_git_properties_file = True ,
376
+ include_git_properties_file = True ,
381
377
bazelrun_java_toolchain = None ,
382
378
bazelrun_script = None ,
383
379
bazelrun_jvm_flags = None ,
@@ -391,17 +387,16 @@ def springboot(
391
387
visibility = None ,
392
388
bazelrun_addopens = [],
393
389
bazelrun_addexports = [],
394
- jartools_toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime" ], # Issue 250
395
- exclude = [], # deprecated
396
- classpath_index = "@rules_spring//springboot:empty.txt" , # deprecated
397
- use_build_dependency_order = True , # deprecated
398
- fail_on_duplicate_classes = False , # deprecated
399
- duplicate_class_allowlist = None , # deprecated
400
- jvm_flags = "" , # deprecated
401
- data = [], # deprecated
390
+ jartools_toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime" ], # Issue 250
391
+ exclude = [], # deprecated
392
+ classpath_index = "@rules_spring//springboot:empty.txt" , # deprecated
393
+ use_build_dependency_order = True , # deprecated
394
+ fail_on_duplicate_classes = False , # deprecated
395
+ duplicate_class_allowlist = None , # deprecated
396
+ jvm_flags = "" , # deprecated
397
+ data = [], # deprecated
402
398
restricted_to = None ,
403
- target_compatible_with = [],
404
- ):
399
+ target_compatible_with = []):
405
400
"""Bazel rule for packaging an executable Spring Boot application.
406
401
407
402
Note that the rule README has more detailed usage instructions for each attribute.
@@ -610,22 +605,20 @@ def springboot(
610
605
visibility = visibility ,
611
606
)
612
607
613
-
614
-
615
608
# SUBRULE 3B: GENERATE THE ENV VARIABLES USED BY THE BAZELRUN LAUNCHER SCRIPT
616
609
genbazelrunenv_out = name + "_bazelrun_env.sh"
617
610
native .genrule (
618
611
name = genbazelrunenv_rule ,
619
612
srcs = bazelrun_data ,
620
- cmd = "$(location @rules_spring//springboot:write_bazelrun_env.sh) " + name + " " + _get_springboot_jar_file_name (name )
621
- + " " + _get_relative_package_path () + " $@ " + _convert_starlarkbool_to_bashbool (bazelrun_background )
622
- + " $(SRCS)"
623
- + " start_flags"
624
- + " " + " " .join (["--add-exports=" + element for element in bazelrun_addexports ])
625
- + " " + " " .join (["--add-opens=" + element for element in bazelrun_addopens ])
626
- + " " + bazelrun_jvm_flags
627
- + " start_envs"
628
- + " " + bazelrun_env_flags ,
613
+ cmd = "$(location @rules_spring//springboot:write_bazelrun_env.sh) " + name + " " + _get_springboot_jar_file_name (name ) +
614
+ " " + _get_relative_package_path () + " $@ " + _convert_starlarkbool_to_bashbool (bazelrun_background ) +
615
+ " $(SRCS)" +
616
+ " start_flags" +
617
+ " " + " " .join (["--add-exports=" + element for element in bazelrun_addexports ]) +
618
+ " " + " " .join (["--add-opens=" + element for element in bazelrun_addopens ]) +
619
+ " " + bazelrun_jvm_flags +
620
+ " start_envs" +
621
+ " " + bazelrun_env_flags ,
629
622
# message = "SpringBoot rule is writing the bazel run launcher env...",
630
623
tools = ["@rules_spring//springboot:write_bazelrun_env.sh" ],
631
624
outs = [genbazelrunenv_out ],
@@ -727,10 +720,8 @@ def springboot(
727
720
dupecheck_rule = dupecheck_rule_label ,
728
721
javaxdetect_rule = javaxdetect_rule_label ,
729
722
apprun_rule = ":" + apprun_rule ,
730
-
731
723
bazelrun_script = bazelrun_script ,
732
724
bazelrun_data = bazelrun_data ,
733
-
734
725
tags = tags ,
735
726
testonly = testonly ,
736
727
restricted_to = restricted_to ,
@@ -747,7 +738,7 @@ def _get_springboot_jar_file_name(name):
747
738
748
739
def _convert_starlarkbool_to_bashbool (starlarkbool ):
749
740
if starlarkbool :
750
- return "true"
741
+ return "true"
751
742
return "false"
752
743
753
744
def _get_relative_package_path ():
0 commit comments