diff --git a/springboot/springboot.bzl b/springboot/springboot.bzl index 5dac2e4..a7b046c 100644 --- a/springboot/springboot.bzl +++ b/springboot/springboot.bzl @@ -385,6 +385,7 @@ def springboot( name, java_library, boot_app_class, + boot_launcher_class = "org.springframework.boot.loader.JarLauncher", deps = None, deps_banned = None, deps_exclude = None, @@ -525,7 +526,7 @@ def springboot( native.genrule( name = genmanifest_rule, srcs = [":" + dep_aggregator_rule], - cmd = "$(location @rules_spring//springboot:write_manifest.sh) " + boot_app_class + " $@ $(JAVABASE) $(SRCS)", + cmd = "$(location @rules_spring//springboot:write_manifest.sh) " + boot_app_class + " " + boot_launcher_class + " $@ $(JAVABASE) $(SRCS)", # message = "SpringBoot rule is writing the MANIFEST.MF...", tools = ["@rules_spring//springboot:write_manifest.sh"], outs = [genmanifest_out], @@ -562,16 +563,17 @@ def springboot( # param0: directory containing the springboot rule # param1: location of the jar utility (singlejar) # param2: boot application main classname (the @SpringBootApplication class) - # param3: jdk path for running java tools e.g. jar; $(JAVABASE) - # param4: compiled application jar name - # param5: use build file deps order [True|False] - # param6: include git.properties file in resulting jar - # param7: executable jar output filename to write to - # param8: compiled application jar - # param9: manifest file - # param10: git.properties file - # param11: classpath_index file - # param12-N: upstream transitive dependency jar(s) + # param3: spring boot launcher class + # param4: jdk path for running java tools e.g. jar; $(JAVABASE) + # param5: compiled application jar name + # param6: use build file deps order [True|False] + # param7: include git.properties file in resulting jar + # param8: executable jar output filename to write to + # param9: compiled application jar + # param10: manifest file + # param11: git.properties file + # param12: classpath_index file + # param13-N: upstream transitive dependency jar(s) native.genrule( name = genjar_rule, srcs = [ @@ -584,7 +586,7 @@ def springboot( ":" + dep_aggregator_rule, ], cmd = "$(location @rules_spring//springboot:springboot_pkg.sh) " + - "$(location @bazel_tools//tools/jdk:singlejar) " + boot_app_class + + "$(location @bazel_tools//tools/jdk:singlejar) " + boot_app_class + " " + boot_launcher_class + " $(JAVABASE) " + name + " " + str(deps_use_starlark_order) + " " + str(include_git_properties_file) + " $@ $(SRCS)", tools = [ "@rules_spring//springboot:springboot_pkg.sh", diff --git a/springboot/springboot_pkg.sh b/springboot/springboot_pkg.sh index c76fcf9..2936902 100755 --- a/springboot/springboot_pkg.sh +++ b/springboot/springboot_pkg.sh @@ -21,16 +21,17 @@ set -e ruledir=$(pwd) singlejar_cmd=$(pwd)/$1 mainclass=$2 -javabase=$3 -appjar_name=$4 -deps_starlark_order=$5 -include_git_properties_file=$6 -outputjar=$7 -appjar=$8 -manifest=$9 -gitpropsfile=${10} -deps_index_file=${11} -first_addin_arg=12 +spring_boot_launcher_class=${3} +javabase=$4 +appjar_name=$5 +deps_starlark_order=$6 +include_git_properties_file=$7 +outputjar=$8 +appjar=$9 +manifest=${10} +gitpropsfile=${11} +deps_index_file=${12} +first_addin_arg=13 # converting starlark booleans to bash booleans if [ $deps_starlark_order = "True" ]; then @@ -87,6 +88,7 @@ echo "SPRING BOOT PACKAGER FOR BAZEL" >> $debugfile echo " ruledir $ruledir (build working directory)" >> $debugfile echo " singlejar $singlejar_cmd (path to the singlejar utility)" >> $debugfile echo " mainclass $mainclass (classname of the @SpringBootApplication class for the manifest.MF file entry)" >> $debugfile +echo " bootloader $spring_boot_launcher_class (classname of the Spring Boot Loader to use)" >> $debugfile echo " outputjar $outputjar (the executable JAR that will be built from this rule)" >> $debugfile echo " javabase $javabase (the path to the JDK2)" >> $debugfile echo " appjar $appjar (contains the .class files for the Spring Boot application)" >> $debugfile @@ -307,7 +309,7 @@ cd $working_dir # so we have to respecify the manifest data # TODO we should rewrite write_manfiest.sh to produce inputs compatible for singlejar (Issue #27) singlejar_options="--normalize --dont_change_compression" # add in --verbose for more details from command -singlejar_mainclass="--main_class org.springframework.boot.loader.JarLauncher" +singlejar_mainclass="--main_class $spring_boot_launcher_class" $singlejar_cmd $singlejar_options $singlejar_mainclass \ --deploy_manifest_lines "Start-Class: $mainclass" \ --sources $raw_output_jar \ diff --git a/springboot/write_manifest.sh b/springboot/write_manifest.sh index 8ce58b5..7586b2a 100755 --- a/springboot/write_manifest.sh +++ b/springboot/write_manifest.sh @@ -9,8 +9,9 @@ set -e mainclass=$1 -manifestfile=$2 -javabase=$3 +springbootlauncherclass=$2 +manifestfile=$3 +javabase=$4 found_spring_jar=0 # Looking for the springboot jar injected by springboot.bzl and extracting the version for var in "$@" @@ -48,7 +49,7 @@ java_version=$(echo "$java_string" | head -n1 | cut -d ' ' -f 3 | rev | cut -c2- echo "Manifest-Version: 1.0" > $manifestfile echo "Created-By: Bazel" >> $manifestfile echo "Built-By: Bazel" >> $manifestfile -echo "Main-Class: org.springframework.boot.loader.JarLauncher" >> $manifestfile +echo "Main-Class: $springbootlauncherclass" >> $manifestfile echo "Spring-Boot-Classes: BOOT-INF/classes/" >> $manifestfile echo "Spring-Boot-Lib: BOOT-INF/lib/" >> $manifestfile echo "Spring-Boot-Version: $spring_version" >> $manifestfile