Skip to content
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

System.out/err and jfxRun #29

Closed
embee1981 opened this issue Aug 19, 2016 · 14 comments
Closed

System.out/err and jfxRun #29

embee1981 opened this issue Aug 19, 2016 · 14 comments

Comments

@embee1981
Copy link

Daft question but how do you get jfxRun to show output from System.out/err?

On running via this task, my app had an expected fatal crash and I get shown

Running JavaFX Application
:jfxRun FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jfxRun'.
> There was an exception while executing JavaFX Application. Please check build-log.

I can't find build-log to see the stack trace from the exit and was wondering how I can get it to show all std out/err stuff to the gradle console?

@FibreFoX
Copy link
Owner

Hi @embee1981 , first of all: thanks for using my gradle-plugin.

The jfxRun-task uses the inheritIO-call of the ProcessBuilder, so you should see any output, which is done.

To make sure you really are having "no output", please call java -jar your-app-name.jar inside the build/jfx/app/-folder ... maybe your application just can't start correctly or even does no output?!

@embee1981
Copy link
Author

Hiya, yeah I'm getting output when running via java -jar :-(

Java version is 1.8.0_92 and Gradle is 3.0 (forgot to give some version info in first post)

@FibreFoX
Copy link
Owner

Hm .... that sounds strange ... but maybe because of gradle 3.0 ...
Do you have the time/chance to create some minimal reproducable project to share with me? With that I can debug that.

@embee1981
Copy link
Author

Sure
JavaFxPluginDemo.zip

Simple IDE agnostic project attached :-)
The App class attempts a sys out, sys err and throws a runtime exception to exit.

I'm on Windows 10, 64 bit version as well in case that's a factor.

@FibreFoX
Copy link
Owner

Thanks, will check it out now 👍

@FibreFoX
Copy link
Owner

As gradle 3 now uses its daemons by default, this is the change that makes the output not being sent. I've added org.gradle.daemon=false to my local gradle.properties-file (like described in the docs) and it dropped me the error you got.

As this (again) is some problem with that daemon, I will have to take some time, finding a way to provide you with your information.

Bug confirmed.

@FibreFoX
Copy link
Owner

Hi @embee1981, thanks for reporting this, it is a problem with the daemon-handling. I have found a way for telling gradle to print stdout and stderr to the normal output, the output recieved by the gradle-daemon is covered/mangled and it needs special adjustment for getting all that to the user.

With gradle 3 the daemon is "used per-default", switching the personal setting (like mentioned in my answer before), does work, but disables the use of the daemon. I personally don't like that daemon, because it introduces another location for mistakes (especially when having buggy software which does not close threads or filehandles like in #12).

A fix will be provided soon.

@FibreFoX FibreFoX self-assigned this Aug 20, 2016
@FibreFoX
Copy link
Owner

Good news:
I have uploaded a possibly fixed version, could you check with 8.5.3-SNAPSHOT-version?

buildscript {
    dependencies {
        classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.5.3-SNAPSHOT'
    }
    repositories {
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    }
}

@FibreFoX
Copy link
Owner

Best fitting bug found on the gradle-project:
https://issues.gradle.org/browse/GRADLE-2310

@embee1981
Copy link
Author

Heya, still no joy with the new snapshot. I can use the disable daemon workaround in the meantime though :-)

@FibreFoX
Copy link
Owner

@embee1981 what do you mean with "joy"?

The project you provided now does print the stdout and strerr when calling gradlew jfxRun.

package com.test;

import javafx.application.Application;
import javafx.stage.Stage;

public class App extends Application{

    @Override
    public void start(Stage primaryStage) throws Exception {
        System.out.println("Printing to sys out");
        System.err.println("Printing to sys err");
        // throw new RuntimeException("Throwing a runtime exception, should see stack trace");
        System.exit(0);
    }

    public static void main(String... args) {
        launch(args);
    }
}

Running gradle now does this output for me:

C:\develop\tmp\JavaFxPluginDemo>gradlew jfxRun
Download https://oss.sonatype.org/content/repositories/snapshots/de/dynamicfiles/projects/gradle/plugins/javafx-gradle-plugin/8.5.3-SNAPSHOT/javafx-gradle-plugin-8.5.3-20160820.114916-1.pom
Download https://oss.sonatype.org/content/repositories/snapshots/de/dynamicfiles/projects/gradle/plugins/javafx-gradle-plugin/8.5.3-SNAPSHOT/javafx-gradle-plugin-8.5.3-20160820.114916-1.jar
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:jfxJar
:jfxRun
Running JavaFX Application

BUILD SUCCESSFUL

Total time: 11.568 secs
C:\develop\tmp\JavaFxPluginDemo>

What problems do you still have now, maybe I can help further to locate this bug?

@FibreFoX
Copy link
Owner

FibreFoX commented Aug 20, 2016

I'm starting to realize, that there is no output .... hm ... only when having a problem?! Very strange ... will work on it...

EDIT: hmpf ..... reminder to myself: when using gradle, make REALLY sure the daemon is running :(

@FibreFoX
Copy link
Owner

@embee1981 can you recheck? I have uploaded a new SNAPSHOT-version :)

@embee1981
Copy link
Author

Awesome :-) Its printing now to the console with daemon running, good job!

@FibreFoX FibreFoX removed the question label Aug 20, 2016
FibreFoX added a commit that referenced this issue Aug 28, 2016
- fixes issue #30
- my first assumption, that it was a duplicate for #29, was wrong, because fix was only working on windows, seems that daemon or java ProcessBuilder works different when calling `inheritIO()`

thanks to @toolforger for finding and reporting this ;) and to work with me together on it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants