Dear Matthias,

Most of the properties you are seeing in the Project Properties on a Gradle project are read-only. At the moment we are not trying to edit the build files. That has to be done manually, we just read them through Gradle.

Please check the following:

https://docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

The 'run' task in Gradle is a JavaExec so you can configure the jvm args with:

run.jvmArgs '-javaagent....'

in your build file.

runSingle is a NetBeans injected task, you can define it in your project if you wish as of:

tasks.create('runSingle', JavaExec) {

            main = project.getProperty('runClassName')
            classpath = project.sourceSets.main.runtimeClasspath
            standardInput = System.in

            jvmArgs '-javaagent...'


            if (project.hasProperty('runArgs')) {
                args = project.getProperty('runArgs').tokenize(' ')
            }

}

On 11/27/19 6:24 AM, Dr. Matthias Laux wrote:
Hello,

I'm starting to lose hope in this ... I got my class library using OpenJPA to work nicely in Netbeans using Ant support and storing stuff in the backend Derby database. Then I decided to move to the much newer Gradle and - after a bit of a learning curve - all builds work find. The one thing that doesn't work is the weaving of OpenJPA which requires -javaagent:<openJPA>/openjpa-3.1.0.jar on the command line. I am not able to figure out how to get this into the execution path of Gradle within Netbeans. It always fails with not getting the -javaagent argument passed to the JVM from within NB. I can try the Run button in the menu bar or right-click "run <main class>", same problem. OpenJPA doesn't work because the weaving is not possible ... the Java Agent is missing.

I have tried the build config in Netbeans under Project - Properties - Build - BuildActions with run and run.single, no luck - I can not find the right syntax for JVM arguments.
Either they're ignored or I get an error message.

I have tried modifying the local gradlew script by injecting the argument in the command string, but when I run it from the command line, it finds the Java Agent (Open JPA weaver) but still fails because the classpath is not set correctly, all dependent libs are missing. When I run it from within NB, it ignores any changes to my local gradlew (which is confusing in itself).

This is honestly driving me nuts ... I got it to run nicely in IntelliJ with their concept of "Run configurations" which allows for direct specification of JVM parameters. NB doesn't
seem to have such a concept.

How can I pass a -javaagent argument to a gradle task (run, runSingle) started within NB?

Any help greatly appreciated ... before I go back to Ant and stop wasting more time :-(

Thx Matthias

Reply via email to