diff --git a/examples/demoapp/BUILD b/examples/demoapp/BUILD
index 0d48a76..b26eab4 100644
--- a/examples/demoapp/BUILD
+++ b/examples/demoapp/BUILD
@@ -85,7 +85,11 @@ springboot(
# if you have conflicting classes in dependency jar files, you can define the order in which the jars are loaded
# https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-executable-jar-format.html#executable-jar-war-index-files-classpath
- deps_index_file = "demoapp_classpath.idx",
+ deps_index_file = ":demoapp_classpath.idx",
+
+ # sometimes packagers want to put certain files into the root of the springboot app jar
+ # these addins will be copied into the root of the generated springboot jar
+ addins = [":info.txt", ":author.txt"],
)
springboottest_deps = [
diff --git a/examples/demoapp/author.txt b/examples/demoapp/author.txt
new file mode 100644
index 0000000..3aff1a1
--- /dev/null
+++ b/examples/demoapp/author.txt
@@ -0,0 +1 @@
+Salesforce
diff --git a/examples/demoapp/info.txt b/examples/demoapp/info.txt
new file mode 100644
index 0000000..8438c28
--- /dev/null
+++ b/examples/demoapp/info.txt
@@ -0,0 +1,3 @@
+This springboot jar was built by Bazel rules_spring.
+
+It is copied into the toplevel directory of the springboot jar as an 'addin'.
diff --git a/springboot/BUILD b/springboot/BUILD
index 7c4172c..46d6643 100644
--- a/springboot/BUILD
+++ b/springboot/BUILD
@@ -20,6 +20,7 @@ exports_files([
"default_bazelrun_script.sh",
"dupe_class_jar_allowlist.txt",
"empty.txt",
+ "addin_end.txt",
])
py_binary(
diff --git a/springboot/addin_end.txt b/springboot/addin_end.txt
new file mode 100644
index 0000000..bf50ff5
--- /dev/null
+++ b/springboot/addin_end.txt
@@ -0,0 +1 @@
+Marker file that indicates the end of the addin list.
diff --git a/springboot/springboot.bzl b/springboot/springboot.bzl
index 80a8ee1..4a5c05f 100644
--- a/springboot/springboot.bzl
+++ b/springboot/springboot.bzl
@@ -253,6 +253,7 @@ def springboot(
bazelrun_jvm_flags = None,
bazelrun_data = None,
bazelrun_background = False,
+ addins = [],
tags = [],
testonly = False,
visibility = None,
@@ -300,6 +301,7 @@ def springboot(
to pass to the JVM at startup. Ex: *-Dcustomprop=gold -DcustomProp2=silver*
bazelrun_data: Uncommon option to add data files to runfiles. Behaves like the *data* attribute defined for *java_binary*.
bazelrun_background: Optional. If True, the *bazel run* launcher will not block. The run command will return and process will remain running.
+ addins: Uncommon option to add additional files to the root of the springboot jar. For example a license file. Pass an array of files from the package.
tags: Optional. Bazel standard attribute.
testonly: Optional. Bazel standard attribute. Defaults to False.
visibility: Optional. Bazel standard attribute.
@@ -417,6 +419,8 @@ def springboot(
":" + genmanifest_rule,
":" + gengitinfo_rule,
deps_index_file,
+ ] + addins + [
+ "@rules_spring//springboot:addin_end.txt",
":" + dep_aggregator_rule,
],
cmd = "$(location @rules_spring//springboot:springboot_pkg.sh) " +
diff --git a/springboot/springboot_doc.md b/springboot/springboot_doc.md
index 2efb86a..97d6e48 100755
--- a/springboot/springboot_doc.md
+++ b/springboot/springboot_doc.md
@@ -36,6 +36,7 @@ Note that the rule README has more detailed usage instructions for each attribut
| bazelrun_jvm_flags | Optional. When launching the application using 'bazel run', an optional set of JVM flags to pass to the JVM at startup. Ex: *-Dcustomprop=gold -DcustomProp2=silver* | None
|
| bazelrun_data | Uncommon option to add data files to runfiles. Behaves like the *data* attribute defined for *java_binary*. | None
|
| bazelrun_background | Optional. If True, the *bazel run* launcher will not block. The run command will return and process will remain running. | False
|
+| addins | Uncommon option to add additional files to the root of the springboot jar. For example a license file. Pass an array of files from the package. | None
|
| tags | Optional. Bazel standard attribute. | []
|
| testonly | Optional. Bazel standard attribute. | False
|
| visibility | Optional. Bazel standard attribute. | None
|
diff --git a/springboot/springboot_pkg.sh b/springboot/springboot_pkg.sh
index 85436cf..606146f 100755
--- a/springboot/springboot_pkg.sh
+++ b/springboot/springboot_pkg.sh
@@ -29,7 +29,7 @@ appjar=$7
manifest=$8
gitpropsfile=$9
deps_index_file=${10}
-first_jar_arg=11
+first_addin_arg=11
if [ $deps_starlark_order = "True" ]; then
deps_starlark_order=true
@@ -86,6 +86,7 @@ echo " appjar_name $appjar_name (unused, is the appjar filename without the
echo " manifest $manifest (the location of the generated manifest.MF file)" >> $debugfile
echo " deps_index_file $deps_index_file (the location of the classpath index file - optional)" >> $debugfile
echo " deplibs (list of upstream transitive dependencies, these will be incorporated into the jar file in BOOT-INF/lib )" >> $debugfile
+echo "*************************************************************************************" >> $debugfile
# compute path to jar utility
pushd . > /dev/null
@@ -95,15 +96,6 @@ popd > /dev/null
echo "Jar command:" >> $debugfile
echo $jar_command >> $debugfile
-# log the list of dep jars we were given
-i=$first_jar_arg
-while [ "$i" -le "$#" ]; do
- eval "lib=\${$i}"
- echo " DEPLIB: $lib" >> $debugfile
- i=$((i + 1))
-done
-echo "" >> $debugfile
-
echo $shasum_install_msg >> $debugfile
echo "Unique identifier for this build: [$packagesha] computed from [$packagesha_raw]" >> $debugfile
@@ -119,6 +111,33 @@ mkdir -p $working_dir/BOOT-INF/classes
TMP_working_dir=$base_working_dir/tmp
mkdir -p $TMP_working_dir
+# Addins is the feature to add files to the root of the springboot jar
+# The addins are listed in order as args, until the addin_end.txt file marks the end
+i=$first_addin_arg
+while [ "$i" -le "$#" ]; do
+ eval "addin=\${$i}"
+ echo " ADDINt: $addin" >> $debugfile
+ if [[ $addin == *addin_end.txt ]]; then
+ i=$((i + 1))
+ echo " ADDIN end found: $addin" >> $debugfile
+ break
+ fi
+ echo " ADDIN: $addin" >> $debugfile
+ cp $addin $working_dir
+ i=$((i + 1))
+done
+first_jar_arg=$i
+echo "" >> $debugfile
+
+# log the list of dep jars we were given
+i=$first_jar_arg
+while [ "$i" -le "$#" ]; do
+ eval "lib=\${$i}"
+ echo " DEPLIB: $lib" >> $debugfile
+ i=$((i + 1))
+done
+echo "" >> $debugfile
+
# Extract the compiled Boot application classes into BOOT-INF/classes
# this must include the application's main class (annotated with @SpringBootApplication)
cd $working_dir/BOOT-INF/classes