spring-boot-thin-launcher icon indicating copy to clipboard operation
spring-boot-thin-launcher copied to clipboard

Ability to add additional external classpath directory

Open dantran opened this issue 7 years ago • 15 comments

spring-boot-thin-launch works great for my none spring app as well but I lose the ability the setup external classpath.

Possible to add -Dthin.extraClassPath=xxxx ?

This option allows me to configure my logback.xml location

dantran avatar Nov 23 '18 09:11 dantran

Can you explain a bit more with a sample app and a README? Why would you want to use the classpath to set an XML file location (you could just use a file URL)?

dsyer avatar Nov 23 '18 10:11 dsyer

application with logback automatically searches for logback.xml configuration in its classpath. and I need to use external file. this way I can control the location of the log output

dont think there is a way to configure the location of logback.xml for none-spring boot app

Will update my demo project to show you

dantran avatar Nov 23 '18 11:11 dantran

dont think there is a way to configure the location of logback.xml for none-spring boot app

Link to docs: https://logback.qos.ch/manual/configuration.html#configFileProperty

dsyer avatar Nov 23 '18 17:11 dsyer

-Dlogback.configurationFile works (big thanks, not sure why i missed that :( )

however, i believe there may be other scenarios that I may need this feature. I believe fat spring-boot users also running into this scenario where user have to set layout=ZIP which overrides thin boot layout

dantran avatar Nov 23 '18 21:11 dantran

Maybe. Not sure I understand those scenarios yet. Nothing to do yet, I guess.

dsyer avatar Nov 23 '18 23:11 dsyer

Our use case for this functionality is that our application supports the concept of plugins which are represented by JAR files. The plugins that a particular instance of the application needs to use can't be determined at build time and is only determined at runtime by loading the plugin jars from known locations on the classpath.

jchharris avatar Apr 16 '19 03:04 jchharris

@jcharris that’s a perfect use case for the existing thin.properties features. You just need to make all the “plugin” jars available in a Maven repository (local or remote).

dsyer avatar Apr 16 '19 10:04 dsyer

If I can include just a directory path in thin.properties that would work fine. Having to edit the thin.properties file to include each plugin JAR and plugin JAR dependencies is not an application run time solution. With traditional WARs we have the build time dependencies in the WAR but can add additional functionality via JARs on the external classpath. This doesn't require any knowledge of exactly what is present in that directory until the application starts and looks for stuff that implements its Plugin interfaces..

jchharris avatar Apr 17 '19 03:04 jchharris

Why would the runtime jars need to be in a specific directory though? You can just put them in a Maven repo layout and it will already work just fine.

dsyer avatar Apr 17 '19 09:04 dsyer

Why would the runtime jars need to be in a specific directory though? You can just put them in a Maven repo layout and it will already work just fine.

some local deps are not in maven repo. (eg. build.gradle: implementation files("./lib/arcsoft-sdk-face-2.1.0.0.jar"))

rainmanhhh avatar May 15 '19 00:05 rainmanhhh

Why would the runtime jars need to be in a specific directory though? You can just put them in a Maven repo layout and it will already work just fine.

application was released,but integration jars are unknown before release.,so we want add those jars in a specific directory,and load it at jvm start.

githubyong avatar Nov 01 '19 08:11 githubyong

So can't you put them in ~/.m2/repository? You can use mvn install -D... I think, if you don't want to guess the layout.

dsyer avatar Nov 01 '19 11:11 dsyer

So can't you put them in ~/.m2/repository? You can use mvn install -D... I think, if you don't want to guess the layout.

if thin-launcher support it , we only need to put jars into the directory. but if in your way,we have to : 1.install maven on server. 2.mvn install jars one by one 3.edit thin.properties

this is not convenient, and perhaps application manager doesn't have knowledge of "maven" and "thin-layout".

githubyong avatar Nov 01 '19 13:11 githubyong

this is not convenient

I get that, but if we add an "additional classpath" option it makes the executions non-reproducible - you have to ensure that the classpath is valid before you run, and that means copying files around, which is unreliable and also not convenient. Who is the "application manager" in your scenario? What does he or she have to do to locate the additional libraries?

dsyer avatar Nov 24 '20 16:11 dsyer

We may have an another possible use case. Users may be able to mount jar files in a k8s environment to enable/disable certain features with autoconfiguration.

abelsromero avatar May 07 '21 15:05 abelsromero

Added thin.libs configuration in 168cc036

dsyer avatar Mar 17 '23 13:03 dsyer