kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
172 stars 57 forks source link

Netbeans gradle debug system properties #385

Open stanforums opened 6 years ago

stanforums commented 6 years ago

my gradle file contains: run { args += '/home/stan/datafiles/cms/SystemConfig.txt' systemProperty "log4j.configuration", "log4j.xml" standardInput = System.in }

when i run the following lines from netbeans run or the command line System.out.format("%-30s = %s\n", "log4j.configuration", system.getProperty("log4j.configuration")); System.out.format("%-30s = %s\n", "System config file" , configFile);

i get -

log4j.configuration = log4j.xml System config file = /home/stan/datafiles/cms/SystemConfig.txt

however when i run from the netbeans debugger i get -

log4j.configuration = null System config file =

How do i get the debugger to cooperate? Thanks

kelemen commented 6 years ago

The simplest solution (assuming you didn't cusomtize the debug task) is to set the debug mode to "Debugger listens for connections" in the "Debugging - Java" category (either in the global settings or in the project settings). What you see happens because in the other mode - by default - the "debug" task is called instead of the "run" (if there is none, NB will pass an init script which will create one). Though it would be better to have the "Debugger listens for connections" set by default, I have never changed it to prevent backward compatibility problems (i.e., break the settings for people relying on it).

stanforums commented 6 years ago

That worked perfect, Thanks

As a side issue, i tried to create a debug task, but the run task ran anyway - strange.

kelemen commented 6 years ago

In the "debugger attaches to debugee" mode, the default is to run the "debug" task, unless you configured otherwise in the "Built-in task" category. You can check what was configured there (note that if you change the debug mode, it won't take effect before you click ok, and the built-in task willl show tasks based on the currently active settings).