How to read multiline value using Ant input task?

Does anyone know how I can enter a multi-line value in an Ant script? I invite the user to comment on a Subversion comment using an input task and I would like to be able to support multiple lines of text.

I am running a standalone version of Ant at a Windows command prompt.

I thought I could do a search and replace for \ n, but I see no easy way to replace the property value with the property value in Ant. It seems like I would have to write the file, replace it in the file , and then load the file into another property. I do not want this bad.

+3
source share
1 answer

100% , Ant, readLine():

/org/apache/tools/ant/input/DefaultInputHandler.java:

/**
 * Prompts and requests input.  May loop until a valid input has
 * been entered.
 * @param request the request to handle
 * @throws BuildException if not possible to read from console
 */
public void handleInput(InputRequest request) throws BuildException {
    String prompt = getPrompt(request);
    BufferedReader r = null;
    try {
        r = new BufferedReader(new InputStreamReader(getInputStream()));
        do {
            System.err.println(prompt);
            System.err.flush();
            try {
                String input = r.readLine();
                request.setInput(input);
            } catch (IOException e) {
                throw new BuildException("Failed to read input from"
                                         + " Console.", e);
            }
        } while (!request.isInputValid());
    } finally {
        if (r != null) {
            try {
                r.close();
            } catch (IOException e) {
                throw new BuildException("Failed to close input.", e);
            }
        }
    }
}

, :

  • Ant 1.7, InputHandler, . Apache .
  • Ant 1,6 , MultiLineInput. .

, " ". - .

!

P.S. Google "ant ", :-). , .

+5

Source: https://habr.com/ru/post/1706197/


All Articles