Skip to content

ant: console output (BUILD SUCCESSFUL, [echo], [javac], program stdout) is lost over the serial console #597

Description

@LSantha

Summary

When ant (Apache Ant 1.7.1 wrapper, org.jnode.command.dev.ant.AntCommand) runs over the serial agent console, almost all of its console output is lost. Only Buildfile: build.xml appears; BUILD SUCCESSFUL, Total time, [echo], [javac], and the target program's System.out never reach the console — even though the build actually succeeds and side-effects happen (files the target creates appear on disk).

This is the root cause of the common "ant does nothing" impression over serial.

Repro (JNode all-plugins boot /full.jgz, serial agent console)

Dir: /devices/hdb1/devtest/ant1 (JFAT).

WH3.java:

public class WH3 { public static void main(String[] a) throws Exception {
  java.io.PrintWriter w = new java.io.PrintWriter(new java.io.FileOutputStream("/devices/hdb1/devtest/ant1/wh3.txt"));
  w.println("WH3 RAN"); w.close(); System.out.println("WH3_SYS_OUT");
} }

build.xml:

<project name="t" default="job">
  <target name="job">
    <javac srcdir="." destdir="."/>
    <java classname="WH3" fork="false" failonerror="true">
      <classpath location="."/>
    </java>
  </target>
</project>

Run ant from that dir over the serial agent.

Observed serial output:

Buildfile: build.xml

Expected: [javac], [java], WH3_SYS_OUT, BUILD SUCCESSFUL, Total time.

None appear — but wh3.txt is created (8 bytes WH3 RAN), and the exit state is success. So only the first Buildfile: line is flushed through; the ant build logger output is buffered and lost. Streaming is also racy: on one run the full output (help:, [echo] echo task is working, BUILD SUCCESSFUL) DID come through, so the logger flush is timing-dependent.

Analysis

AntCommand.main just calls org.apache.tools.ant.Main.main(args). The ant logger writes to System.out; on JNode the buffered non-flushing output stream is likely not flushed to the serial console before the agent considers the command complete. BUILD FAILED error lines, by contrast, DO stream (observed with Content is not allowed in prolog), so it is the success-path logger output that is lost.

Suggested fix

Make the ant wrapper flush the Project logger / build log after execution (e.g. AntCommand should pump ant's BuildLogger through a shell stream that is flushed, or ant output should go to the command's report stream which the shell flushes like it does for other commands). After the fix, [echo], [javac], program stdout, and BUILD SUCCESSFUL should reach the serial console.

Workaround (for serial users)

Do not rely on ant console output over serial; verify execution by side effects (a file the code creates, ls -l), and use the shell's javac + java commands directly when you need stdout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/doneThe agent finished successfully; PR opened or comment posted.area/corecore/ — VM, kernel, scheduler, classmgr, drivers.kind/bugConfirmed bug report with a repro or stack trace.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions