I’m using the application plugin to generate a zip archive with a convenient launcher script so the user does not have to do much other than extract the zip and run the tool.
I would like to make it even easier by including a ready to go properties file in the generated Zip distribution and also have it added to the classpath in the launcher script. That way the user can just run the app with minimal command line args.
How can I go about :
Getting the properties file added to the resultant Zip/Tar package
Have that properties file added to the classpath used by the wrapper script
You’ll need to 1) configure the ‘main’ distribution to include the properties file and 2) configure the ‘startScripts’ task to add the file to the classpath.
And then in the code use new File(args[0]) or similar to read it.
Attention: Do not just omit the startScripts configuration and use new File("config/foo.properties") as that will be relative to the current working directory of the user starting the application and will thus be very fragile.
Following on another thread we were discussing @Vampire, how would one also ensure that the src/dist is added to the classpath so that when code is executed from grade (build/test/etc) that it can find the files?