I work on a large set of services that run SpringBoot in containers. We build a "Spring Boot Jar" and execute it with "java -jar ..." as the start script in the container.
I've been asked to to implement something that seems conceptually simple, but I'm finding it could potentially be quite gnarly.
What needs to happen is that the script needs to check for a particular jar file in a mapped volume, and if it is present, run the spring boot service with an augmented classpath, including the additional jar.
I've realized this is quite messy because when you execute a Spring Boot jar with "java -jar", you can't just "augment the classpath". If "-jar" is on the command line, it will ignore all "-cp" options.
That simple fact requires examining the possibility of quite possibly heavy introspection into the original jar, getting the entire list of BOOT-INF/lib jars at a minimum, and constructing a new classpath string including all of those jars along with the additional jar, not to mention BOOT-INF/classes. A relatively complete solution requires extracting the META-INF/MANIFEST.MF file to get the Start-Class property. This is all pretty messy to implement for real. I certainly hope I don't find any services I need to do this to that use the Spring Boot "idx" thing, to specify the classpath order for jars. I don't think we have any, but I'm really not certain.
I suppose a cleaner solution might be to have the script use zip utilities to "edit" the jar, adding another BOOT-INF-lib jar entry for the additional jar. Unfortunately, these containers run in read-only filesystems, so there's no place I could write the jar to.
I'd appreciate any reasonable strategies for this that people could suggest.