I am creating a tomcat/jsp based WAR spring boot 2.0.4 executable which works pretty well when just using bootWar gradle target. But now I want to load local external JARs and WarLauncher doesnt support this (is there a reason for that?). So I switched to PropertiesLauncher via:
bootWar {
enabled = true
manifest {
attributes 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher'
}
}
Now looking inside the generated war file, everything looks ok in the MANIFEST like:
Start-Class: com.mypackage.Application
Main-Class: org.springframework.boot.loader.PropertiesLauncher
Now I tried to figure out the right command line args to start this thing which was a bit of trial and error but that got me nearly to the finish line:
java -Dloader.path=WEB-INF/lib-provided,WEB-INF/lib,WEB-INF/classes -jar myapplication-4.0.0.war
So I basically looked at WarLauncher and tried to recreate the classpath via loader.path values without adding 3rd party jars because first I just want to start my application.
The loading of my application looks ok.
Now I want to add a "local" path where my 3rd party jars reside. I thought I can just do:
java -Dloader.path=WEB-INF/lib-provided,WEB-INF/lib,WEB-INF/classes,jar:file:lib -jar myapplication-4.0.0.war
so adding a jar:file:lib which should mean the "lib" folder next to my runnable WAR. But this doesnt work. Also just adding ",lib" to the loader.path doesnt work.
The only thing that works is adding the full path like "jar:file:/foo/bar/lib" but i really would like to have it relative to current runnable WAR folder.
Can someone tell me how to define the relative local folder where to scan for Jars?
I hope i will help others struggling with PropertiesLauncher in combination with runnable WAR files because its not really straighforward and there is not much documentation apart from https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html