29
29
import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_CLASS_NAME ;
30
30
import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_LISTENER_EXTENSION ;
31
31
import 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 ;
32
33
import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_LISTENER_USE_LEGACY_REPORTING_NAME ;
33
34
import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_OUTPUT_DIRECTORY ;
34
35
import static org .apache .tools .ant .taskdefs .optional .junitlauncher .confined .Constants .LD_XML_ATTR_SEND_SYS_ERR ;
@@ -51,6 +52,7 @@ public class ListenerDefinition {
51
52
private String className ;
52
53
private String resultFile ;
53
54
private String extension = "txt" ;
55
+ private boolean useFile = true ;
54
56
private boolean sendSysOut ;
55
57
private boolean sendSysErr ;
56
58
private String outputDir ;
@@ -124,6 +126,19 @@ public String getExtension() {
124
126
return extension ;
125
127
}
126
128
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
+
127
142
public void setSendSysOut (final boolean sendSysOut ) {
128
143
this .sendSysOut = sendSysOut ;
129
144
}
@@ -206,6 +221,7 @@ void toForkedRepresentation(final XMLStreamWriter writer) throws XMLStreamExcept
206
221
if (this .extension != null ) {
207
222
writer .writeAttribute (LD_XML_ATTR_LISTENER_EXTENSION , this .extension );
208
223
}
224
+ writer .writeAttribute (LD_XML_ATTR_LISTENER_USE_FILE , Boolean .toString (this .useFile ));
209
225
writer .writeEndElement ();
210
226
}
211
227
@@ -234,6 +250,10 @@ public static ListenerDefinition fromForkedRepresentation(final XMLStreamReader
234
250
if (extension != null ) {
235
251
listenerDef .setExtension (extension );
236
252
}
253
+ final String useFile = reader .getAttributeValue (null , LD_XML_ATTR_LISTENER_USE_FILE );
254
+ if (useFile != null ) {
255
+ listenerDef .setUseFile (Boolean .parseBoolean (useFile ));
256
+ }
237
257
final String useLegacyReportingName = reader .getAttributeValue (null ,
238
258
LD_XML_ATTR_LISTENER_USE_LEGACY_REPORTING_NAME );
239
259
if (useLegacyReportingName != null ) {
0 commit comments