Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3530

Can't read from console when running a <groovy in Ant in Eclipse

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5.6
    • 1.6.7, 1.7.0
    • Ant integration
    • None
    • Windows XP, Eclipse 3.4.2 , Ant 1.6.5

    Description

      I have a groovy program that I am running from Ant in Eclipse
      using <groovy src="thepgm.groovy" />

      I can write to the console using println

      But I can't read from the console.
      When I try to, the program waits at the right place
      and I can type in the console window
      but I can't terminate the input and return to the program.
      I have tried ctrl+c, ctrl+z, and esc
      (When I ran a groovy program directly in Eclipse, I had to terminate with ctrl+z)
      I have to cancel the program.

      I would like a way that work in environment, and also if I run it from an Ant job in the command window

      I have tried the following, with and w/o the import statements.

      	<target name="groovy.test.console.in"
      		description="">
      	<!-- ***** Not working ***** -->
      		<groovy>
      			//import console.*
      			//import java.io.*
      
      			println "Hello World"
      			
      			//Process1 ()
      			//Process2 ()
      			//Process3 ()
      			Process4 ()
      			return
      			
      			def Process1 () {
      				ans = System.in.readLines()
      				//ans = System.in.readLine()
      				println "ans = " + ans
      			}
      
      			def Process2 () {
      			def stdin = new BufferedReader(new InputStreamReader(System.in))
      			print "Enter info: " 
      			String info = stdin.readLine()
      			print "You entered:  " + info
      			}
      
      			def Process3 () {
      				println "Starting Process3"
      				ant.echo("Ant says Hello World")
      				ant.input(message:"Enter a name",addproperty:"a.name")
      			}
      
      			def Process4 () {
      				println "Starting Process4"
      				System.in.readLines().each {
      					println it
      				}
      			}
      		</groovy>
      	</target>
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            patriciashannon Patricia Shannon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: