简体   繁体   中英

How to run java agent on Corda node by configuring jvm args in gradle build?

I am trying to run a JavaAgent that monitors the code execution on one or multiple Corda nodes so I can track coverage of my functional tests when they are running.

The Corda docs say you can add JVM args by adding this to my node spec:

custom = {
   jvmArgs: [ "-javaAgent:/Path/To/Agent/jacoco-agent.jar=config-file=/Path/To/Agent/jacoco-agent.config",  "-Xmx1G", "-XX:+UseG1GC" ]
}

It seems that I have to add this to each nodes config file but is there a way to add this to all nodes through the build.gradle for example so the agent starts when the node start.

you can edit the node.conf of the generated nodes from the node or nodeDefaults section of the deployNodes task (or any task of type net.corda.plugins.Cordform ) in the build.gradle , so you can simply use

node {
    extraConfig = ['custom.jvmArgs': ["-Xmx1G", "-XX:+UseG1GC"]]
}

note that in Groovy, both lists and dictionaries use square bracket syntax eg

["key" : "value", "key2" : true, "key3" : 42]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM