Skip to content

Commit 55bdaae

Browse files
authored
Merge pull request #191 from Aditya-2001/aditya/add-exports+opens
Add support for add-opens and add-exports
2 parents 758565c + 8b04107 commit 55bdaae

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

springboot/default_bazelrun_script.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ echo ""
5555
echo "Using JAVA_OPTS from the environment: ${JAVA_OPTS}"
5656
echo "Using bazelrun_jvm_flags from the BUILD file: ${JVM_FLAGS}"
5757

58+
if [ -f "${ADD_EXPORTS}" ]; then
59+
echo "Using ADD_EXPORTS from the environment: ${ADD_EXPORTS}"
60+
fi
61+
62+
if [ -f "${ADD_OPENS}" ]; then
63+
echo "Using ADD_OPENS from the environment: ${ADD_OPENS}"
64+
fi
65+
5866
# main args
5967
main_args="$@"
6068

@@ -64,7 +72,7 @@ jar=${SPRINGBOOTJAR_FILENAME}
6472

6573
# assemble the command
6674
# use exec so that we can pass signals to the underlying process (https://github.com/salesforce/rules_spring/issues/91)
67-
cmd="exec ${java_cmd} ${JVM_FLAGS} ${JAVA_OPTS} -jar ${path}${jar} ${main_args}"
75+
cmd="exec ${java_cmd} ${JVM_FLAGS} ${JAVA_OPTS} ${ADD_EXPORTS} ${ADD_OPENS} -jar ${path}${jar} ${main_args}"
6876

6977
echo "Running ${cmd}"
7078
echo "In directory $(pwd)"

springboot/springboot.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ def springboot(
386386
tags = [],
387387
testonly = False,
388388
visibility = None,
389+
bazelrun_addopens = [],
390+
bazelrun_addexports = [],
389391
exclude = [], # deprecated
390392
classpath_index = "@rules_spring//springboot:empty.txt", # deprecated
391393
use_build_dependency_order = True, # deprecated
@@ -585,6 +587,8 @@ def springboot(
585587
name = genbazelrunenv_rule,
586588
cmd = "$(location @rules_spring//springboot:write_bazelrun_env.sh) " + name + " " + _get_springboot_jar_file_name(name)
587589
+ " " + _get_relative_package_path() + " $@ " + _convert_starlarkbool_to_bashbool(bazelrun_background)
590+
+ " " + " ".join(["--add-exports=" + element for element in bazelrun_addexports])
591+
+ " " + " ".join(["--add-opens=" + element for element in bazelrun_addopens])
588592
+ " " + bazelrun_jvm_flags,
589593
# message = "SpringBoot rule is writing the bazel run launcher env...",
590594
tools = ["@rules_spring//springboot:write_bazelrun_env.sh"],

springboot/write_bazelrun_env.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ SPRINGBOOTJAR_FILENAME=${2}
1717
LABEL_PATH=${3}
1818
OUTPUTFILE_PATH=${4}
1919
DO_BACKGROUND=${5}
20-
FIRST_JVMFLAG_ARG=6
20+
ADD_EXPORTS=${6}
21+
ADD_OPENS=${7}
22+
FIRST_JVMFLAG_ARG=8
2123

2224
if [ "$LABEL_PATH" == "root" ]; then
2325
# token that indicates that the target is in the root path, which for the
@@ -43,4 +45,6 @@ echo "export RULE_NAME=$RULE_NAME" > $OUTPUTFILE_PATH
4345
echo "export LABEL_PATH=$LABEL_PATH" >> $OUTPUTFILE_PATH
4446
echo "export SPRINGBOOTJAR_FILENAME=$SPRINGBOOTJAR_FILENAME" >> $OUTPUTFILE_PATH
4547
echo "export DO_BACKGROUND=$DO_BACKGROUND" >> $OUTPUTFILE_PATH
48+
echo "export ADD_EXPORTS=$ADD_EXPORTS" >> $OUTPUTFILE_PATH
49+
echo "export ADD_OPENS=$ADD_OPENS" >> $OUTPUTFILE_PATH
4650
echo "export JVM_FLAGS=\"$JVM_FLAGS\"" >> $OUTPUTFILE_PATH

0 commit comments

Comments
 (0)