How to configure JVM arguments for distribution, not development

Okay, so feel free to chime in if I’m doing anything wrong or if there are better ways to do things. I am essentially new to Java, and Java build tools. I am just getting my bearings for Tasks, Groovy, etc… I have a project that I am creating a JAR of by using the application plugin and calling the task installDist.

Short Version: How do I optionally include JVM arguments depending on whether I am running a Distribution task, or a Run task? Or, how am I intended to manipulate the batch file that’s included with the distribution process (e.g. /build/install/MyAppName/bin/MyAppName.bat).

Long Version: I am using Apache Camel Main which automatically picks up an file in the /resources/ folder when running my project within the IDE (via gradle run). In order to override this property file after distributing my project into a JAR, I need to supply JVM arguments ( If I specify the arguments with the applicationDefaultJvmArgs option it will work for my distributed JAR but won’t work for my locally run IDE version (due to it trying to find a file that doesn’t exist). I know I can comment/uncomment out code for running but that seems like a poor workaround. I want to be able to include the JVM args only in the distribution.

application { applicationDefaultJvmArgs = ... } is for ones that should always be valid and thus are used for run task and also the start scripts.
If you instead configure the defaultJvmOpts on the startScripts task (which defaults to the value of the application extension above) it is only valid for the start scripts, but not for the run task.

Perfect, this is precisely what I was looking for. Thank you for the quick reply and added explaination to differentiate the two.