2929import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_CLASS_NAME ;
3030import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_LISTENER_EXTENSION ;
3131import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_LISTENER_RESULT_FILE ;
32+ import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_LISTENER_USE_FILE ;
3233import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_LISTENER_USE_LEGACY_REPORTING_NAME ;
3334import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_OUTPUT_DIRECTORY ;
3435import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_SEND_SYS_ERR ;
@@ -51,6 +52,7 @@ public class ListenerDefinition {
5152 private String className ;
5253 private String resultFile ;
5354 private String extension = "txt" ;
55+ private boolean useFile = true ;
5456 private boolean sendSysOut ;
5557 private boolean sendSysErr ;
5658 private String outputDir ;
@@ -124,6 +126,19 @@ public String getExtension() {
124126 return extension ;
125127 }
126128
129+ /**
130+ * Sets whether the formatter should log to a file.
131+ * @param useFile if true use a file, if false send to standard out.
132+ * @since Ant 1.10.13
133+ */
134+ public void setUseFile (boolean useFile ) {
135+ this .useFile = useFile ;
136+ }
137+
138+ public boolean shouldUseFile () {
139+ return useFile ;
140+ }
141+
127142 public void setSendSysOut (final boolean sendSysOut ) {
128143 this .sendSysOut = sendSysOut ;
129144 }
@@ -206,6 +221,7 @@ void toForkedRepresentation(final XMLStreamWriter writer) throws XMLStreamExcept
206221 if (this .extension != null ) {
207222 writer .writeAttribute (LD_XML_ATTR_LISTENER_EXTENSION , this .extension );
208223 }
224+ writer .writeAttribute (LD_XML_ATTR_LISTENER_USE_FILE , Boolean .toString (this .useFile ));
209225 writer .writeEndElement ();
210226 }
211227
@@ -234,6 +250,10 @@ public static ListenerDefinition fromForkedRepresentation(final XMLStreamReader
234250 if (extension != null ) {
235251 listenerDef .setExtension (extension );
236252 }
253+ final String useFile = reader .getAttributeValue (null , LD_XML_ATTR_LISTENER_USE_FILE );
254+ if (useFile != null ) {
255+ listenerDef .setUseFile (Boolean .parseBoolean (useFile ));
256+ }
237257 final String useLegacyReportingName = reader .getAttributeValue (null ,
238258 LD_XML_ATTR_LISTENER_USE_LEGACY_REPORTING_NAME );
239259 if (useLegacyReportingName != null ) {
0 commit comments