Relatively new Gradle user here and first post. Be gentle.
I am using the “Application” plugin to assemble my app, which I run on a remote Linux server. I need to remotely debug my app (via IntelliJ), which requires me to add additional flags to the JVM when I run my app.
What I’d like to do is define an optional runtime switch be added to my app’s scripts ("-remotedebug", for example) that would add on the required JVM command line arguments. So I’d like to do this:
bin/myapp -remotedebug
which would, in turn, add additional args to the JVM command line.
I found an alternative approach to what I’m trying to accomplish that suits my needs just fine. I’m including my solution here for others’ benefit:
Thanks to this very helpful Mkyong article, I have chosen to instruct Gradle’s Application plugin to generate a second startup script that passes the additional JVM arguments that I need. Here’s the magic:
This will result in the creation of a second set of startup scripts in my package’s ‘bin’ directory called “customStartupScript” (Linux) and “customStartupScript.bat” that do exactly what I need.
Hope others find this useful. Does anyone have another approach?