I want to make it so Gradle will cause a Java Agent to be attached to my process when it is launched. I want the solution to work with
To attach a Java Agent you have to launch java with the
-javaagent:path/to/agent.jar to the java command. Normally to add an option to the java command line I would add it via
applicationDefaultJvmArgs = [ '-javaagent:path/to/agent.jar']. However, this results in needing to know the absolute path of the agent JAR at build time, or know the location of the agent.jar relative to the working directory at runtime.
Looking at the scripts generated by
installDist, I can see that an
$APP_HOME variable is set but it is set after the java options are processed, so I don’t believe I can use that as part of my agent path. Is there some other way to get access to $APP_HOME from a command line option?