It's a Maven-based project, so the keystore is in /src/main/resources. I build a jar and move the file to /resources in the jar. I'd like the .config file to say something like "resources/keystore.jks".
Why do you do that? You shouldn't have to move it. Just put that keystore in resources/resources/keystore.jks
if you want it to be available in /resources
on the classpath.
How do I parse the .config file so it:
- Uses /src/main/resources/keystore.jks for
application code in development.
- Uses /src/test/resources/keystore.jks for
test code.
- Uses /resources in the jar.
If you follow my previous advice, then you don't have anything particular to do.
- Resources in
src/main/resources
are available in the normal classpath
- Resources in
src/test/resources
are available in the test classpath (which has precedence on the normal classpath when runnign mvn test
)
src/main/resources
is the root of the resource path. If you want something to be available under /my/package/my.properties
, then put in src/main/resources/my/package/my.properties
.
If really this doesn't cover your needs, then have a look at resources filtering. Filtering can be combined with profiles for more complicated things. Or you could also use several filters and pick up the right one by passing a property. But, as I said, I'm not sure you need this.