Question

I want to add some configs to the classpath (generated by maven-jar-plugin), but I don't want them inside a jar, but in an external folder. That way I'll be able to edit configs without repackaging. I found one solution How to add a classpath entry when executing the app with exec plugin but is there a less complicated solution?

Or maybe I'm wrong and it's a bad pattern - storing configs in the classpath but outside a Jar? Maybe it's better to store app configs in the user's home directory and add them to the app at runtime?

For example I want to allow the end user to edit log4j.properties and translations.

Regards,

Was it helpful?

Solution

I'd suggest having a default location that it looks for the app configs (e.g. user home directory, as you suggested), but allow the user to provide an agrument/System property to override this location. Assuming to look on the classpath is not, in my opinion, the best solution, since the concept of a classpath is a fairly alien thing to most users, and can even be hard to determine for some programmers.

OTHER TIPS

I think that Melv are right - better to store configs in Home directory and provide ability to change it, but if someone need add something to classpath - you just can add following code into <configuration><archive>.

<manifestEntries>
    <Class-Path>config/</Class-Path>
    <mode>development</mode>
    <url>${pom.url}</url>
</manifestEntries>

If you declare <addClasspath>true</addClasspath>, then dependency classpaths also will be added.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top