This is my run configuration.
task run << {
jvmArgs "-javaagent:/home/audrius/org.springframework.instrument-3.0.5.RELEASE.jar"
jettyRun.execute()
}
but it gives me:
Could not find method jvmArgs()
How do you set javaagent for jettyRun?
Unfortunately, Gradle runs Jetty inside it's own JVM, so you can't set javaagent only for a specific task. It is set for the whole JVM. So, you have two ways to accomplish what you want: either you run Gradle itself with javaagent enabled, or you spawn another JVM process and run Jetty in it.
First solution is pretty easy: provide the option as you normally do. For example, put
org.gradle.jvmargs = "-javaagent:/home/audrius/org.springframework.instrument-3.0.5.RELEASE.jar"
in yourgradle.properties
The second way is pretty hard. You can't just spawn new JVM and say "run this Gradle task" to it. I guess you'll need to use Gradle Tooling API to spawn new process based on your exising build config via GradleConnector:
As you see, second solution is pretty ugly. I'd better choose first approach.