Skip to content

Commit 4f2a26f

Browse files
authored
Merge pull request #233 from salesforce/plaird/multiple_targets
support multiple springboot targets in a BUILD file
2 parents db35f19 + 7727190 commit 4f2a26f

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

springboot/springboot.bzl

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ else
271271
fi
272272
273273
# the env variables file is found in SCRIPT_DIR
274-
source $SCRIPT_DIR/bazelrun_env.sh
274+
source $SCRIPT_DIR/%name%_bazelrun_env.sh
275275
276276
# the inner bazelrun script is found in the runfiles subdir
277277
# this is either default_bazelrun_script.sh or a custom one provided by the user
@@ -296,7 +296,8 @@ def _springboot_rule_impl(ctx):
296296
# "bazel run" with the springboot target (bazel run //examples/helloworld) and string sub it
297297
# into the _bazelrun_script_template text defined above
298298
outer_bazelrun_script_contents = _bazelrun_script_template \
299-
.replace("%bazelrun_script%", ctx.attr.bazelrun_script.files.to_list()[0].short_path)
299+
.replace("%bazelrun_script%", ctx.attr.bazelrun_script.files.to_list()[0].short_path) \
300+
.replace("%name%", ctx.attr.name)
300301

301302
# the bazelrun_java_toolchain optional, if set, we use it as the jvm for bazel run
302303
if ctx.attr.bazelrun_java_toolchain != None:
@@ -462,16 +463,16 @@ def springboot(
462463
# NOTE: if you add/change any params, be sure to rerun the stardoc generator (see BUILD file)
463464

464465
# Create the subrule names
465-
dep_aggregator_rule = native.package_name() + "_deps"
466-
appjar_locator_rule = native.package_name() + "_appjar_locator"
467-
genmanifest_rule = native.package_name() + "_genmanifest"
468-
genbazelrunenv_rule = native.package_name() + "_genbazelrunenv"
469-
gengitinfo_rule = native.package_name() + "_gengitinfo"
470-
genjar_rule = native.package_name() + "_genjar"
471-
dupecheck_rule = native.package_name() + "_dupecheck"
472-
javaxdetect_rule = native.package_name() + "_javaxdetect"
473-
bannedcheck_rule = native.package_name() + "_bannedcheck"
474-
apprun_rule = native.package_name() + "_apprun"
466+
dep_aggregator_rule = native.package_name() + "_" + name + "_deps"
467+
appjar_locator_rule = native.package_name() + "_" + name + "_appjar_locator"
468+
genmanifest_rule = native.package_name() + "_" + name + "_genmanifest"
469+
genbazelrunenv_rule = native.package_name() + "_" + name + "_genbazelrunenv"
470+
gengitinfo_rule = native.package_name() + "_" + name + "_gengitinfo"
471+
genjar_rule = native.package_name() + "_" + name + "_genjar"
472+
dupecheck_rule = native.package_name() + "_" + name + "_dupecheck"
473+
javaxdetect_rule = native.package_name() + "_" + name + "_javaxdetect"
474+
bannedcheck_rule = native.package_name() + "_" + name + "_bannedcheck"
475+
apprun_rule = native.package_name() + "_" + name + "_apprun"
475476

476477
# Handle deprecated attribute names; if modern name is not set then take
477478
# the legacy attribute value (which may be set to a default, or set by the user)
@@ -511,7 +512,7 @@ def springboot(
511512

512513
# SUBRULE 2: GENERATE THE MANIFEST
513514
# NICER: derive the Build JDK and Boot Version values by scanning transitive deps
514-
genmanifest_out = "MANIFEST.MF"
515+
genmanifest_out = name + "_MANIFEST.MF"
515516
native.genrule(
516517
name = genmanifest_rule,
517518
srcs = [":" + dep_aggregator_rule],
@@ -527,7 +528,7 @@ def springboot(
527528
)
528529

529530
# SUBRULE 2B: GENERATE THE GIT PROPERTIES
530-
gengitinfo_out = "git.properties"
531+
gengitinfo_out = name + "_git.properties"
531532
native.genrule(
532533
name = gengitinfo_rule,
533534
cmd = "$(location @rules_spring//springboot:write_gitinfo_properties.sh) $@",
@@ -597,7 +598,7 @@ def springboot(
597598
)
598599

599600
# SUBRULE 3B: GENERATE THE ENV VARIABLES USED BY THE BAZELRUN LAUNCHER SCRIPT
600-
genbazelrunenv_out = "bazelrun_env.sh"
601+
genbazelrunenv_out = name + "_bazelrun_env.sh"
601602
native.genrule(
602603
name = genbazelrunenv_rule,
603604
cmd = "$(location @rules_spring//springboot:write_bazelrun_env.sh) " + name + " " + _get_springboot_jar_file_name(name)

0 commit comments

Comments
 (0)