This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 124366
Collapse All | Expand All

(-)a/o.apache.tools.ant.module/apichanges.xml (+17 lines)
Lines 107-112 Link Here
107
107
108
    <changes>
108
    <changes>
109
109
110
        <change id="AntSession.getIO">
111
            <api name="general"/>
112
            <summary>Added <code>AntSession.getIO</code></summary>
113
            <version major="3" minor="35"/>
114
            <date day="16" month="3" year="2009"/>
115
            <author login="jglick"/>
116
            <compatibility addition="yes"/>
117
            <description>
118
                <p>
119
                    Added ability to get the underlying <code>InputOutput</code>
120
                    object for advanced formatting.
121
                </p>
122
            </description>
123
            <class package="org.apache.tools.ant.module.spi" name="AntSession"/>
124
            <issue number="124366"/>
125
        </change>
126
110
        <change id="AntScriptUtils">
127
        <change id="AntScriptUtils">
111
            <api name="general"/>
128
            <api name="general"/>
112
            <summary>Added <code>AntScriptUtils</code></summary>
129
            <summary>Added <code>AntScriptUtils</code></summary>
(-)a/o.apache.tools.ant.module/nbproject/project.properties (-1 / +1 lines)
Lines 39-45 Link Here
39
39
40
javac.compilerargs=-Xlint:unchecked
40
javac.compilerargs=-Xlint:unchecked
41
javac.source=1.5
41
javac.source=1.5
42
spec.version.base=3.34.0
42
spec.version.base=3.35.0
43
compile.ant.jar=${ant.core.lib}
43
compile.ant.jar=${ant.core.lib}
44
src-bridge.cp.extra=build/classes:${compile.ant.jar}
44
src-bridge.cp.extra=build/classes:${compile.ant.jar}
45
extra.module.files=\
45
extra.module.files=\
(-)a/o.apache.tools.ant.module/nbproject/project.xml (-1 / +1 lines)
Lines 162-168 Link Here
162
                    <build-prerequisite/>
162
                    <build-prerequisite/>
163
                    <compile-dependency/>
163
                    <compile-dependency/>
164
                    <run-dependency>
164
                    <run-dependency>
165
                        <specification-version>1.11</specification-version>
165
                        <specification-version>1.16</specification-version>
166
                    </run-dependency>
166
                    </run-dependency>
167
                </dependency>
167
                </dependency>
168
                <dependency>
168
                <dependency>
(-)a/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java (-3 / +4 lines)
Lines 83-88 Link Here
83
import org.openide.util.NbBundle;
83
import org.openide.util.NbBundle;
84
import org.openide.util.NbCollections;
84
import org.openide.util.NbCollections;
85
import org.openide.util.RequestProcessor;
85
import org.openide.util.RequestProcessor;
86
import org.openide.windows.InputOutput;
86
import org.openide.windows.OutputWriter;
87
import org.openide.windows.OutputWriter;
87
88
88
/**
89
/**
Lines 154-161 Link Here
154
        return null;
155
        return null;
155
    }
156
    }
156
    
157
    
157
    public boolean run(File buildFile, List<String> targets, InputStream in, OutputWriter out, OutputWriter err,
158
    public boolean run(File buildFile, List<String> targets, InputStream in, OutputWriter out, OutputWriter err, Map<String,String> properties,
158
                       Map<String,String> properties, int verbosity, String displayName, Runnable interestingOutputCallback, ProgressHandle handle) {
159
            int verbosity, String displayName, Runnable interestingOutputCallback, ProgressHandle handle, InputOutput io) {
159
        if (!classpathInitialized) {
160
        if (!classpathInitialized) {
160
            classpathInitialized = true;
161
            classpathInitialized = true;
161
            // #46171: Ant expects this path to have itself and whatever else you loaded with it,
162
            // #46171: Ant expects this path to have itself and whatever else you loaded with it,
Lines 184-190 Link Here
184
        
185
        
185
        // first use the ProjectHelper to create the project object
186
        // first use the ProjectHelper to create the project object
186
        // from the given build file.
187
        // from the given build file.
187
        final NbBuildLogger logger = new NbBuildLogger(buildFile, out, err, verbosity, displayName, interestingOutputCallback, handle);
188
        final NbBuildLogger logger = new NbBuildLogger(buildFile, out, err, verbosity, displayName, interestingOutputCallback, handle, io);
188
        Vector<String> targs;
189
        Vector<String> targs;
189
        try {
190
        try {
190
            project = new Project();
191
            project = new Project();
(-)a/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/NbBuildLogger.java (-1 / +9 lines)
Lines 84-89 Link Here
84
import org.openide.util.NbCollections;
84
import org.openide.util.NbCollections;
85
import org.openide.util.RequestProcessor;
85
import org.openide.util.RequestProcessor;
86
import org.openide.util.WeakSet;
86
import org.openide.util.WeakSet;
87
import org.openide.windows.InputOutput;
87
import org.openide.windows.OutputListener;
88
import org.openide.windows.OutputListener;
88
import org.openide.windows.OutputWriter;
89
import org.openide.windows.OutputWriter;
89
90
Lines 110-115 Link Here
110
    private String[] targets = null;
111
    private String[] targets = null;
111
    final OutputWriter out;
112
    final OutputWriter out;
112
    final OutputWriter err;
113
    final OutputWriter err;
114
    final InputOutput io;
113
    private final int verbosity;
115
    private final int verbosity;
114
    private final String displayName;
116
    private final String displayName;
115
    private final Runnable interestingOutputCallback;
117
    private final Runnable interestingOutputCallback;
Lines 166-176 Link Here
166
        this.lastTask = lastTask;
168
        this.lastTask = lastTask;
167
    }
169
    }
168
    
170
    
169
    public NbBuildLogger(File origScript, OutputWriter out, OutputWriter err, int verbosity, String displayName, Runnable interestingOutputCallback, ProgressHandle handle) {
171
    public NbBuildLogger(File origScript, OutputWriter out, OutputWriter err, int verbosity, String displayName,
172
            Runnable interestingOutputCallback, ProgressHandle handle, InputOutput io) {
170
        thisSession = LoggerTrampoline.ANT_SESSION_CREATOR.makeAntSession(this);
173
        thisSession = LoggerTrampoline.ANT_SESSION_CREATOR.makeAntSession(this);
171
        this.origScript = origScript;
174
        this.origScript = origScript;
172
        this.out = out;
175
        this.out = out;
173
        this.err = err;
176
        this.err = err;
177
        this.io = io;
174
        this.verbosity = verbosity;
178
        this.verbosity = verbosity;
175
        this.displayName = displayName;
179
        this.displayName = displayName;
176
        this.interestingOutputCallback = interestingOutputCallback;
180
        this.interestingOutputCallback = interestingOutputCallback;
Lines 760-765 Link Here
760
        verifyRunning();
764
        verifyRunning();
761
        return new Hyperlink(file, message, line1, column1, line2, column2);
765
        return new Hyperlink(file, message, line1, column1, line2, column2);
762
    }
766
    }
767
768
    public InputOutput getIO() {
769
        return io;
770
    }
763
    
771
    
764
    // Accessors for stuff which is specific to particular versions of Ant.
772
    // Accessors for stuff which is specific to particular versions of Ant.
765
    private static final Method targetGetLocation; // 1.6.2+
773
    private static final Method targetGetLocation; // 1.6.2+
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/bridge/BridgeInterface.java (-1 / +4 lines)
Lines 46-51 Link Here
46
import java.util.List;
46
import java.util.List;
47
import java.util.Map;
47
import java.util.Map;
48
import org.netbeans.api.progress.ProgressHandle;
48
import org.netbeans.api.progress.ProgressHandle;
49
import org.openide.windows.InputOutput;
49
import org.openide.windows.OutputWriter;
50
import org.openide.windows.OutputWriter;
50
51
51
/**
52
/**
Lines 66-74 Link Here
66
     * @param displayName a user-presentable name for the session
67
     * @param displayName a user-presentable name for the session
67
     * @param interestingOutputCallback will be called if and when some interesting output appears, or input is requested
68
     * @param interestingOutputCallback will be called if and when some interesting output appears, or input is requested
68
     * @param handle a progress handle to update if appropriate (switch to sleeping and back to indeterminate)
69
     * @param handle a progress handle to update if appropriate (switch to sleeping and back to indeterminate)
70
     * @param io raw I/O handle for more advanced output
69
     * @return true if the build succeeded, false if it failed for any reason
71
     * @return true if the build succeeded, false if it failed for any reason
70
     */
72
     */
71
    boolean run(File buildFile, List<String> targets, InputStream in, OutputWriter out, OutputWriter err, Map<String,String> properties, int verbosity, String displayName, Runnable interestingOutputCallback, ProgressHandle handle);
73
    boolean run(File buildFile, List<String> targets, InputStream in, OutputWriter out, OutputWriter err, Map<String,String> properties,
74
            int verbosity, String displayName, Runnable interestingOutputCallback, ProgressHandle handle, InputOutput io);
72
    
75
    
73
    /**
76
    /**
74
     * Try to stop a running build.
77
     * Try to stop a running build.
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/bridge/DummyBridgeImpl.java (-1 / +3 lines)
Lines 51-56 Link Here
51
import org.openide.ErrorManager;
51
import org.openide.ErrorManager;
52
import org.openide.util.NbBundle;
52
import org.openide.util.NbBundle;
53
import org.openide.util.Enumerations;
53
import org.openide.util.Enumerations;
54
import org.openide.windows.InputOutput;
54
import org.openide.windows.OutputWriter;
55
import org.openide.windows.OutputWriter;
55
56
56
/**
57
/**
Lines 106-112 Link Here
106
        return null;
107
        return null;
107
    }
108
    }
108
    
109
    
109
    public boolean run(File buildFile, List<String> targets, InputStream in, OutputWriter out, OutputWriter err, Map<String,String> properties, int verbosity, String displayName, Runnable interestingOutputCallback, ProgressHandle handle) {
110
    public boolean run(File buildFile, List<String> targets, InputStream in, OutputWriter out, OutputWriter err, Map<String,String> properties,
111
            int verbosity, String displayName, Runnable interestingOutputCallback, ProgressHandle handle, InputOutput io) {
110
        err.println(NbBundle.getMessage(DummyBridgeImpl.class, "ERR_cannot_run_target"));
112
        err.println(NbBundle.getMessage(DummyBridgeImpl.class, "ERR_cannot_run_target"));
111
        problem.printStackTrace(err);
113
        problem.printStackTrace(err);
112
        return false;
114
        return false;
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/LoggerTrampoline.java (+2 lines)
Lines 48-53 Link Here
48
import org.apache.tools.ant.module.spi.AntLogger;
48
import org.apache.tools.ant.module.spi.AntLogger;
49
import org.apache.tools.ant.module.spi.AntSession;
49
import org.apache.tools.ant.module.spi.AntSession;
50
import org.apache.tools.ant.module.spi.TaskStructure;
50
import org.apache.tools.ant.module.spi.TaskStructure;
51
import org.openide.windows.InputOutput;
51
import org.openide.windows.OutputListener;
52
import org.openide.windows.OutputListener;
52
53
53
/**
54
/**
Lines 94-99 Link Here
94
        int getVerbosity();
95
        int getVerbosity();
95
        String getDisplayName();
96
        String getDisplayName();
96
        OutputListener createStandardHyperlink(URL file, String message, int line1, int column1, int line2, int column2);
97
        OutputListener createStandardHyperlink(URL file, String message, int line1, int column1, int line2, int column2);
98
        InputOutput getIO();
97
    }
99
    }
98
    
100
    
99
    public interface AntEventImpl {
101
    public interface AntEventImpl {
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/StandardLogger.java (-5 / +19 lines)
Lines 41-47 Link Here
41
41
42
package org.apache.tools.ant.module.run;
42
package org.apache.tools.ant.module.run;
43
43
44
import java.awt.Color;
44
import java.io.File;
45
import java.io.File;
46
import java.io.IOException;
45
import java.io.PrintWriter;
47
import java.io.PrintWriter;
46
import java.io.StringWriter;
48
import java.io.StringWriter;
47
import java.net.MalformedURLException;
49
import java.net.MalformedURLException;
Lines 61-66 Link Here
61
import org.openide.filesystems.FileUtil;
63
import org.openide.filesystems.FileUtil;
62
import org.openide.util.NbBundle;
64
import org.openide.util.NbBundle;
63
import org.openide.util.lookup.ServiceProvider;
65
import org.openide.util.lookup.ServiceProvider;
66
import org.openide.windows.IOColorLines;
67
import org.openide.windows.InputOutput;
64
import org.openide.windows.OutputListener;
68
import org.openide.windows.OutputListener;
65
69
66
/**
70
/**
Lines 233-239 Link Here
233
            time = mockTotalTime;
237
            time = mockTotalTime;
234
        }
238
        }
235
        if (t == null) {
239
        if (t == null) {
236
            session.println(formatMessageWithTime("FMT_finished_target_printed", time), false, null);
240
            formatColoredMessageWithTime(session, "FMT_finished_target_printed", false, time);
237
            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(StandardLogger.class, "FMT_finished_target_status", session.getDisplayName()));
241
            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(StandardLogger.class, "FMT_finished_target_status", session.getDisplayName()));
238
        } else {
242
        } else {
239
            if (isStopException(t.getCause())) {
243
            if (isStopException(t.getCause())) {
Lines 263-272 Link Here
263
                }
267
                }
264
            }
268
            }
265
            if (isStopException(t)) {
269
            if (isStopException(t)) {
266
                event.getSession().println(formatMessageWithTime("FMT_target_stopped_printed", time), true, null);
270
                formatColoredMessageWithTime(session, "FMT_target_stopped_printed", true, time);
267
                StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(StandardLogger.class, "FMT_target_stopped_status", event.getSession().getDisplayName()));
271
                StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(StandardLogger.class, "FMT_target_stopped_status", event.getSession().getDisplayName()));
268
            } else {
272
            } else {
269
                event.getSession().println(formatMessageWithTime("FMT_target_failed_printed", time), true, null); // #10305
273
                formatColoredMessageWithTime(session, "FMT_target_failed_printed", true, time);
270
                StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(StandardLogger.class, "FMT_target_failed_status", event.getSession().getDisplayName()));
274
                StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(StandardLogger.class, "FMT_target_failed_status", event.getSession().getDisplayName()));
271
            }
275
            }
272
        }
276
        }
Lines 290-300 Link Here
290
     * Total time: {0} minutes
294
     * Total time: {0} minutes
291
     *             {1} seconds
295
     *             {1} seconds
292
     */
296
     */
293
    private static String formatMessageWithTime(String key, long millis) {
297
    private static void formatColoredMessageWithTime(AntSession session, String key, boolean error, long millis) {
294
        int secs = (int) (millis / 1000);
298
        int secs = (int) (millis / 1000);
295
        int minutes = secs / 60;
299
        int minutes = secs / 60;
296
        int seconds = secs % 60;
300
        int seconds = secs % 60;
297
        return NbBundle.getMessage(StandardLogger.class, key, minutes, seconds);
301
        String msg = NbBundle.getMessage(StandardLogger.class, key, minutes, seconds);
302
        InputOutput io = session.getIO();
303
        if (IOColorLines.isSupported(io)) {
304
            try {
305
                IOColorLines.println(io, msg, error ? Color.RED : Color.GREEN);
306
                return;
307
            } catch (IOException x) {
308
                ERR.log(Level.INFO, null, x);
309
            }
310
        }
311
        session.println(msg, error, null);
298
    }
312
    }
299
    
313
    
300
    @Override
314
    @Override
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/TargetExecutor.java (-1 / +1 lines)
Lines 495-501 Link Here
495
        handle.start();
495
        handle.start();
496
        setEnabledEQ(sa, true);
496
        setEnabledEQ(sa, true);
497
        setEnabledEQ(ra, false);
497
        setEnabledEQ(ra, false);
498
        ok = AntBridge.getInterface().run(buildFile, targetNames, in, out, err, properties, verbosity, displayName, interestingOutputCallback, handle);
498
        ok = AntBridge.getInterface().run(buildFile, targetNames, in, out, err, properties, verbosity, displayName, interestingOutputCallback, handle, io);
499
        
499
        
500
        } finally {
500
        } finally {
501
            if (io != null) {
501
            if (io != null) {
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/spi/AntSession.java (+11 lines)
Lines 44-49 Link Here
44
import java.io.File;
44
import java.io.File;
45
import java.net.URL;
45
import java.net.URL;
46
import org.apache.tools.ant.module.run.LoggerTrampoline;
46
import org.apache.tools.ant.module.run.LoggerTrampoline;
47
import org.openide.windows.IOColors;
48
import org.openide.windows.InputOutput;
47
import org.openide.windows.OutputListener;
49
import org.openide.windows.OutputListener;
48
50
49
/**
51
/**
Lines 222-227 Link Here
222
    public OutputListener createStandardHyperlink(URL file, String message, int line1, int column1, int line2, int column2) {
224
    public OutputListener createStandardHyperlink(URL file, String message, int line1, int column1, int line2, int column2) {
223
        return impl.createStandardHyperlink(file, message, line1, column1, line2, column2);
225
        return impl.createStandardHyperlink(file, message, line1, column1, line2, column2);
224
    }
226
    }
227
228
    /**
229
     * Obtains the I/O handle for advanced operations such as {@link IOColors}.
230
     * @return an I/O handle
231
     * @since org.apache.tools.ant.module/3 3.35
232
     */
233
    public InputOutput getIO() {
234
        return impl.getIO();
235
    }
225
    
236
    
226
    @Override
237
    @Override
227
    public String toString() {
238
    public String toString() {
(-)a/o.apache.tools.ant.module/test/unit/src/org/apache/tools/ant/module/run/StandardLoggerTest.java (+6 lines)
Lines 63-68 Link Here
63
import org.openide.util.NbBundle;
63
import org.openide.util.NbBundle;
64
import org.openide.util.Utilities;
64
import org.openide.util.Utilities;
65
import org.openide.util.WeakSet;
65
import org.openide.util.WeakSet;
66
import org.openide.windows.IOProvider;
67
import org.openide.windows.InputOutput;
66
import org.openide.windows.OutputEvent;
68
import org.openide.windows.OutputEvent;
67
import org.openide.windows.OutputListener;
69
import org.openide.windows.OutputListener;
68
70
Lines 273-278 Link Here
273
            return new MockHyperlink(file.toExternalForm(), message, line1, column1, line2, column2);
275
            return new MockHyperlink(file.toExternalForm(), message, line1, column1, line2, column2);
274
        }
276
        }
275
277
278
        public InputOutput getIO() {
279
            return IOProvider.getDefault().getIO("", true);
280
        }
281
276
        public void println(String message, boolean err, OutputListener listener) {
282
        public void println(String message, boolean err, OutputListener listener) {
277
            messages.add(new Message(message, err, listener));
283
            messages.add(new Message(message, err, listener));
278
        }
284
        }

Return to bug 124366