-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make gradle plugin respect Netbeans Configurations #313
Comments
Can you describe what exactly you are doing (what you write into where) and your expectation (where do you expect to see what precisely)? Because I'm unaware any bug where configurations of other profiles are not honored. Anyway, if you set a JVM argument, that is a JVM argument for the build script. That won't be passed to tasks which happen to spawn another Java process (like test). Also, I would recommend you to use project properties instead of using JVM arguments for performace reason. |
What I'm doing exactly is:
My expectation is that when I select "headless" in the dropbox menu in the Netbeans toolbar and run the tests, I should not receive the RuntimeException. |
This won't work for two reasons:
|
Thanks for getting back to me. I made the mistake when I wrote this issue to forget the "-D" before the property (which is what I did use in my test). |
If you are using if (project.hasProperty('headless') {
test.systemProperty 'headless', project.headless
} |
Thanks for the answer. I don't know what I am doing wrong, but your suggestion does not work for me. |
This is the way this has to be done in all Gradle projects whether in
NetBeans or not vim with Gradle. See:
https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html
You have to configure the system properties for the test jvm which is not
the one your Gradle build script is running in. A simple syntax I use in a
lot of cases is:
systemProperties = System.properties
Others can be found here:
http://stackoverflow.com/questions/21406265/how-to-give-system-property-to-my-test-via-gradle-and-d
Hope it helps,
Wade
On Jan 23, 2017 7:12 PM, "MarceloRuiz" <[email protected]> wrote:
Thanks for the answer. I don't know what I am doing wrong, but your
suggestion does not work for me.
I added a println to confirm the project has the headless property, but
*Boolean.getBoolean("headless")* in my code always returns false.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#313 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAvjuhfVgzunaJjRZp3gEI48h4YAMbI8ks5rVUH6gaJpZM4LrPKG>
.
|
@wadechandler |
Ah, so, you would need to use -Pheadless=true versus -Dheadless, and then
be sure and set systemProperty "headless" project.getProperty ("headless")
to specifically pull the value from the project, and put it into the system
property, and an if statement to make sure the value is set before doing it
would make sure you don't set the property unless it is actually set. So,
not sure why it wasn't working for you exactly, but probably a missing -P
or something. Sorry I missed your system property was working.
Wade
…On Jan 23, 2017 8:28 PM, "MarceloRuiz" ***@***.***> wrote:
@wadechandler <https://github.com/wadechandler>
Thanks for your answer. That is exactly what I was doing and it was
working. I was just trying to follow kelemen's suggestion to translate the
project property (which is set correctly) to the system property just for
the test. Do you happen to know why the other approach was not working?
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#313 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAvjuoE7Vhw0lh7HHzVH6lR-F2pgxOuPks5rVVPEgaJpZM4LrPKG>
.
|
@MarceloRuiz Can you create a sample project and share it on Github (commit NB generated files as well except files within .nb-gradle/private/)? That way I can be sure what you are doing. |
Hi Attila, |
You have set "-Pheadless=true" for the default profile (I assume this was not the case in your real project). Anyway, you only set "-Pheadless" for the "Build" action. You have to add this for every test related built-in task (test, test single, debug test single method, ...). Sadly, there is no way at the moment to define arguments passed for all built-in tasks (or possibly even custom tasks). Though, it wouldn't be too hard to add. |
Thanks for getting back to me. In my real project I had a new profile for headless operation with the property set to each of those tasks you mentioned. Maybe I was too tried when I created the sample project. What I ended up doing is tweaking the gradle build file for test tasks and setting the system properties needed to run headless tests there. |
The project you have linked works for me as expected and if I configure "-Pheadless=true" for the test command, it will print "It is headless!". By the way, you are writting this: tasks.withType(Test) {
testLogging {
showStandardStreams = true
}
if (project.hasProperty('headless')) {
test.systemProperty 'headless', project.headless
}
} If you are doing it this way, you should remove the |
Thanks Attila! |
It seems the Gradle plugin ignores different Netbeans Configuration. Usually Netbeans runs the Default Profile, but one can create a new configuration (for example, "Headless" to run tests in headless mode) and set a system property in that configuration (like headless=true).
Even though the output shows the JVM is started with that property correctly set, it seems the plugin is not configured to pass that configuration to gradle, nor the application arguments for that matter.
The current workaround is setting that in the build file :
It is my expectation that the plugin will honor the Netbeans Configuration settings out of the box when running the project (same behavior that Netbeans has with running maven or ant projects).
Thanks!
The text was updated successfully, but these errors were encountered: