Inheriting functions in subproject is not working with --no-daemon option?

Hi, environment debian linux 8.2, gradle 2.5

I’m in need of ask a value to the user. The value to read must/may be used more time in different subprojects.
I show the user a drop down to select a value, or, if in console, I ask to type it into the terminal.

This works fine if I run gradle using the daemon, but it crashes if I run in --no-daemon mode. This is a showcase:

  • If I run the build using the daemon, the console is null, so the script show a drop down to the user, and the build works fine, asking the value to the user only for child1 (child2 reuses the previous value).
gradle  upload

Starting a new Gradle Daemon for this build (subsequent builds will be faster).
:child1:upload ...user selects a value (host1, for example) from drop down...
Host1 is host1
Host2 is host1


Total time: 3.609 secs
  • If I run the build using --no-daemon, the console is null, so the script SHOULD asks to the user to type the value but instead it crashes:
gradle --no-daemon upload

:child1:upload FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '/home/larzeni/progetti/tmp/gradletest/child1/build.gradle' line: 4

* What went wrong:
Execution failed for task ':child1:upload'.
> Could not find method readHost() for arguments [] on task ':child1:upload'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


Total time: 2.194 secs

This is the project structure:


And these are the files:

  • gradletest/settings.gradle = "GradleTester"
include "child1", "child2"
  • gradletest/build.gradle
import groovy.swing.SwingBuilder

description = "The function readhost seems to work from task upload ONLY if gradle is run in daemon mode, not if run 
as --no-daemon. Why? And how to solve this?"

project.ext.l_hostname = null; // declare the var, so it will be available in childer without asking it multiple times...
String readHost() {
    if (l_hostname != null) {
        return l_hostname;
    if (System.console() == null) {
        new SwingBuilder().edt {
            dialog(modal: true, title: 'Hostname', alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
                vbox { // Put everything below each other
                    label(text: "Hostname: ")
                    def input1 = comboBox(items:["host1", "host2", "host3"], toolTipText:'Please, choose the hostname into this field')
                    button(defaultButton: true, text: 'OK', actionPerformed: {
                        l_hostname = input1.selectedItem;
    else {
        l_hostname = String.valueOf( System.console().readHost("\nPlease enter hostname: ") )
    return l_hostname
  • gradletest/child1/build.gradle
task upload(description: "Release the file into remote host") {
    doLast {
    String l_host=readHost()
        logger.warn("Host1 is ${l_host}");
  • gradletest/child2/build.gradle
task upload(description: "Release the file into remote host") {
    doLast {
    String l_host=readHost()
        logger.warn("Host1 is ${l_host}");

Can someone help me?