This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 37431 - NB Ant execution does not support console input
Summary: NB Ant execution does not support console input
Status: VERIFIED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 3.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks: 41535
  Show dependency tree
 
Reported: 2003-11-22 15:44 UTC by Jesse Glick
Modified: 2005-07-14 16:18 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Attempted patch which did not seem to do anything - TBD why (8.28 KB, patch)
2003-11-22 15:46 UTC, Jesse Glick
Details | Diff
Updated patch (untested) (8.57 KB, patch)
2004-05-09 22:17 UTC, Jesse Glick
Details | Diff
Patch in progress (9.47 KB, patch)
2004-05-23 23:17 UTC, Jesse Glick
Details | Diff
More useful test project - helps look at multiple input and output redirections at once (just run it several times) (6.94 KB, application/octet-stream)
2004-05-23 23:19 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2003-11-22 15:44:51 UTC
I.e. even when Ant as run from the command line
would permit console input to be passed through to
a task, Ant run from NB using the Output Window
never passes any input. You can type stuff in the
Output Window but it is apparently not sent to Ant.

Only really relevant for Ant 1.6 which improves
console input handling. See also:

http://issues.apache.org/bugzilla/show_bug.cgi?id=2738
http://issues.apache.org/bugzilla/show_bug.cgi?id=3452
http://issues.apache.org/bugzilla/show_bug.cgi?id=24592
Comment 1 Jesse Glick 2003-11-22 15:46:28 UTC
Created attachment 12267 [details]
Attempted patch which did not seem to do anything - TBD why
Comment 2 Jesse Glick 2003-11-22 16:07:48 UTC
I also filed:

http://issues.apache.org/bugzilla/show_bug.cgi?id=24918

which I was testing this patch with.
Comment 3 Jesse Glick 2004-05-09 22:12:20 UTC
May be a priority esp. for programming students who tend to use stdin
a lot.
Comment 4 Jesse Glick 2004-05-09 22:17:58 UTC
Created attachment 14771 [details]
Updated patch (untested)
Comment 5 Jesse Glick 2004-05-10 00:33:30 UTC
Besides patching the Ant module, I am patching core/output (which
seems to forget to flush its PipedWriter - may or may not matter, I'm
not sure) and o.o.util.io.ReaderInputStream, which did not correctly
implement 3-arg read(...).

Now works with this main app (JDK 1.5):

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = Scanner.create(System.in);
        while (true) {
            int i = sc.nextInt();
            if (i == 0) {
                break;
            }
            System.out.println("Square of " + i + " is " + (i * i));
        }
    }
}

But you need to run w/ internal exec for now, due to Ant #24918, which
I hope to get fixed for Ant 1.6.2. To test w/ internal exec, add to
build.xml:

    <target name="init-macrodef-java">
        <macrodef name="java"
uri="http://www.netbeans.org/ns/j2se-project/1">
            <attribute name="classname" default="${main.class}"/>
            <element name="customize" optional="true"/>
            <sequential>
                <java classname="@{classname}" fork="false">
                    <classpath>
                        <path path="${run.classpath}"/>
                    </classpath>
                    <customize/>
                </java>
            </sequential>
        </macrodef>
    </target>
Comment 6 Jesse Glick 2004-05-10 01:55:22 UTC
committed     Up-To-Date  1.8        
openide/src/org/openide/util/io/ReaderInputStream.java
committed     Up-To-Date  1.28       
core/output/src/org/netbeans/core/output/OutputTabInner.java
committed   * Up-To-Date  1.13       
ant/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java
committed   * Up-To-Date  1.13       
ant/src/org/apache/tools/ant/module/bridge/AntBridge.java
committed   * Up-To-Date  1.4        
ant/src/org/apache/tools/ant/module/bridge/BridgeInterface.java
committed   * Up-To-Date  1.4        
ant/src/org/apache/tools/ant/module/bridge/DummyBridgeImpl.java
committed   * Up-To-Date  1.39       
ant/src/org/apache/tools/ant/module/run/TargetExecutor.java
Comment 7 Jesse Glick 2004-05-23 23:16:00 UTC
Still some problems w.r.t. handling input from >1 process at a time,
etc. Have an apparently working fix in progress.
Comment 8 Jesse Glick 2004-05-23 23:17:30 UTC
Created attachment 15076 [details]
Patch in progress
Comment 9 Jesse Glick 2004-05-23 23:19:34 UTC
Created attachment 15077 [details]
More useful test project - helps look at multiple input and output redirections at once (just run it several times)
Comment 10 Jesse Glick 2004-05-26 14:11:02 UTC
Fixing multiple process problem:

committed     Up-To-Date  1.15       
ant/src/org/apache/tools/ant/module/bridge/AntBridge.java
Comment 11 Jaromir Uhrik 2005-07-14 16:18:52 UTC
Verified.