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 206161
Collapse All | Expand All

(-)a/o.apache.tools.ant.module/apichanges.xml (+16 lines)
Lines 110-115 Link Here
110
110
111
    <changes>
111
    <changes>
112
112
113
        <change id="AntSession.getProperties">
114
            <api name="general"/>
115
            <summary>Added <code>AntSession.getPropertes</code></summary>
116
            <version major="3" minor="52"/>
117
            <date year="2011" month="12" day="15"/>
118
            <author login="jglick"/>
119
            <compatibility addition="yes"/>
120
            <description>
121
                <p>
122
                    Added ability to get user properties defined for a build.
123
                </p>
124
            </description>
125
            <class package="org.apache.tools.ant.module.spi" name="AntSession"/>
126
            <issue number="206161"/>
127
        </change>
128
113
        <change id="AntSession.getIO">
129
        <change id="AntSession.getIO">
114
            <api name="general"/>
130
            <api name="general"/>
115
            <summary>Added <code>AntSession.getIO</code></summary>
131
            <summary>Added <code>AntSession.getIO</code></summary>
(-)a/o.apache.tools.ant.module/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=3.51.0
45
spec.version.base=3.52.0
46
compile.ant.jar=${ant.core.lib}
46
compile.ant.jar=${ant.core.lib}
47
src-bridge.cp.extra=build/classes:${compile.ant.jar}
47
src-bridge.cp.extra=build/classes:${compile.ant.jar}
48
extra.module.files=\
48
extra.module.files=\
(-)a/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java (-1 / +1 lines)
Lines 189-195 Link Here
189
        
189
        
190
        // first use the ProjectHelper to create the project object
190
        // first use the ProjectHelper to create the project object
191
        // from the given build file.
191
        // from the given build file.
192
        final NbBuildLogger logger = new NbBuildLogger(buildFile, out, err, verbosity, displayName, interestingOutputCallback, handle, io);
192
        final NbBuildLogger logger = new NbBuildLogger(buildFile, out, err, verbosity, displayName, properties, interestingOutputCallback, handle, io);
193
        Vector<String> targs;
193
        Vector<String> targs;
194
        try {
194
        try {
195
            project = new Project();
195
            project = new Project();
(-)a/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/NbBuildLogger.java (-1 / +7 lines)
Lines 114-119 Link Here
114
    final OutputWriter err;
114
    final OutputWriter err;
115
    final InputOutput io;
115
    final InputOutput io;
116
    private final int verbosity;
116
    private final int verbosity;
117
    private final Map<String,String> properties;
117
    private final String displayName;
118
    private final String displayName;
118
    private final Runnable interestingOutputCallback;
119
    private final Runnable interestingOutputCallback;
119
    private final ProgressHandle handle;
120
    private final ProgressHandle handle;
Lines 175-181 Link Here
175
    }
176
    }
176
    
177
    
177
    @SuppressWarnings("LeakingThisInConstructor")
178
    @SuppressWarnings("LeakingThisInConstructor")
178
    public NbBuildLogger(File origScript, OutputWriter out, OutputWriter err, int verbosity, String displayName,
179
    NbBuildLogger(File origScript, OutputWriter out, OutputWriter err, int verbosity, String displayName, Map<String,String> properties,
179
            Runnable interestingOutputCallback, ProgressHandle handle, InputOutput io) {
180
            Runnable interestingOutputCallback, ProgressHandle handle, InputOutput io) {
180
        thisSession = LoggerTrampoline.ANT_SESSION_CREATOR.makeAntSession(this);
181
        thisSession = LoggerTrampoline.ANT_SESSION_CREATOR.makeAntSession(this);
181
        this.origScript = origScript;
182
        this.origScript = origScript;
Lines 183-188 Link Here
183
        this.err = err;
184
        this.err = err;
184
        this.io = io;
185
        this.io = io;
185
        this.verbosity = verbosity;
186
        this.verbosity = verbosity;
187
        this.properties = properties;
186
        this.displayName = displayName;
188
        this.displayName = displayName;
187
        this.interestingOutputCallback = interestingOutputCallback;
189
        this.interestingOutputCallback = interestingOutputCallback;
188
        this.handle = handle;
190
        this.handle = handle;
Lines 719-724 Link Here
719
        verifyRunning();
721
        verifyRunning();
720
        return verbosity;
722
        return verbosity;
721
    }
723
    }
724
725
    @Override public Map<String, String> getProperties() {
726
        return Collections.unmodifiableMap(properties);
727
    }
722
    
728
    
723
    String getDisplayNameNoLock() {
729
    String getDisplayNameNoLock() {
724
        return displayName;
730
        return displayName;
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/LoggerTrampoline.java (+2 lines)
Lines 46-51 Link Here
46
46
47
import java.io.File;
47
import java.io.File;
48
import java.net.URL;
48
import java.net.URL;
49
import java.util.Map;
49
import java.util.Set;
50
import java.util.Set;
50
import org.apache.tools.ant.module.spi.AntEvent;
51
import org.apache.tools.ant.module.spi.AntEvent;
51
import org.apache.tools.ant.module.spi.AntLogger;
52
import org.apache.tools.ant.module.spi.AntLogger;
Lines 99-104 Link Here
99
        String getDisplayName();
100
        String getDisplayName();
100
        OutputListener createStandardHyperlink(URL file, String message, int line1, int column1, int line2, int column2);
101
        OutputListener createStandardHyperlink(URL file, String message, int line1, int column1, int line2, int column2);
101
        InputOutput getIO();
102
        InputOutput getIO();
103
        Map<String,String> getProperties();
102
    }
104
    }
103
    
105
    
104
    public interface AntEventImpl {
106
    public interface AntEventImpl {
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/StandardLogger.java (-3 / +44 lines)
Lines 52-57 Link Here
52
import java.net.MalformedURLException;
52
import java.net.MalformedURLException;
53
import java.net.URI;
53
import java.net.URI;
54
import java.net.URISyntaxException;
54
import java.net.URISyntaxException;
55
import java.util.ArrayList;
56
import java.util.List;
57
import java.util.Map;
55
import java.util.Stack;
58
import java.util.Stack;
56
import java.util.StringTokenizer;
59
import java.util.StringTokenizer;
57
import java.util.logging.Level;
60
import java.util.logging.Level;
Lines 64-69 Link Here
64
import org.openide.awt.StatusDisplayer;
67
import org.openide.awt.StatusDisplayer;
65
import org.openide.filesystems.FileUtil;
68
import org.openide.filesystems.FileUtil;
66
import org.openide.util.NbBundle;
69
import org.openide.util.NbBundle;
70
import org.openide.util.Utilities;
67
import org.openide.util.lookup.ServiceProvider;
71
import org.openide.util.lookup.ServiceProvider;
68
import org.openide.windows.IOColorLines;
72
import org.openide.windows.IOColorLines;
69
import org.openide.windows.IOColorPrint;
73
import org.openide.windows.IOColorPrint;
Lines 212-220 Link Here
212
        if (event.isConsumed()) {
216
        if (event.isConsumed()) {
213
            return;
217
            return;
214
        }
218
        }
215
        getSessionData(event.getSession()).startTime = System.currentTimeMillis();
219
        AntSession session = event.getSession();
216
        StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(StandardLogger.class, "FMT_running_ant", event.getSession().getDisplayName()));
220
        getSessionData(session).startTime = System.currentTimeMillis();
217
        // no messages printed for now
221
        StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(StandardLogger.class, "FMT_running_ant", session.getDisplayName()));
222
        if (!session.getOriginatingScript().getParentFile().getName().equals("executor-snippets")) { // internal detail of JavaRunner
223
            List<String> cmd = new ArrayList<String>();
224
            cmd.add("ant");
225
            switch (session.getVerbosity()) {
226
            case AntEvent.LOG_DEBUG:
227
                cmd.add("-d");
228
                break;
229
            case AntEvent.LOG_VERBOSE:
230
                cmd.add("-v");
231
                break;
232
            case AntEvent.LOG_WARN:
233
                cmd.add("-q");
234
                break;
235
            }
236
            cmd.add("-f");
237
            cmd.add(session.getOriginatingScript().getAbsolutePath());
238
            for (Map.Entry<String,String> prop : session.getProperties().entrySet()) {
239
                if (prop.getKey().equals("build.compiler.emacs")) {
240
                    continue; // uninteresting
241
                }
242
                cmd.add("-D" + prop);
243
            }
244
            for (String target : session.getOriginatingTargets()) {
245
                cmd.add(target);
246
            }
247
            String msg = Utilities.escapeParameters(cmd.toArray(new String[cmd.size()]));
248
            InputOutput io = session.getIO();
249
            if (IOColorLines.isSupported(io)) {
250
                try {
251
                    IOColorLines.println(io, msg, Color.GRAY);
252
                } catch (IOException x) {
253
                    ERR.log(Level.INFO, null, x);
254
                }
255
            } else {
256
                session.println(msg.toString(), false, null);
257
            }
258
        }
218
        event.consume();
259
        event.consume();
219
    }
260
    }
220
    
261
    
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/spi/AntSession.java (+11 lines)
Lines 46-51 Link Here
46
46
47
import java.io.File;
47
import java.io.File;
48
import java.net.URL;
48
import java.net.URL;
49
import java.util.Map;
49
import org.apache.tools.ant.module.run.LoggerTrampoline;
50
import org.apache.tools.ant.module.run.LoggerTrampoline;
50
import org.openide.windows.IOColors;
51
import org.openide.windows.IOColors;
51
import org.openide.windows.InputOutput;
52
import org.openide.windows.InputOutput;
Lines 198-203 Link Here
198
    public int getVerbosity() {
199
    public int getVerbosity() {
199
        return impl.getVerbosity();
200
        return impl.getVerbosity();
200
    }
201
    }
202
203
    /**
204
     * Gets a set of user properties defined for this session.
205
     * These might be a mixture of global default definitions and per-session properties.
206
     * @return an immutable property map
207
     * @since 3.52
208
     */
209
    public Map<String,String> getProperties() {
210
        return impl.getProperties();
211
    }
201
    
212
    
202
    /**
213
    /**
203
     * Get a display name used for the session as a whole.
214
     * Get a display name used for the session as a whole.
(-)a/o.apache.tools.ant.module/test/unit/src/org/apache/tools/ant/module/run/StandardLoggerTest.java (-2 / +12 lines)
Lines 97-102 Link Here
97
        session.sendTargetFinished(makeAntEvent(realSession, null, -1, null, "some-target", null));
97
        session.sendTargetFinished(makeAntEvent(realSession, null, -1, null, "some-target", null));
98
        session.sendBuildFinished(makeAntEvent(realSession, null, -1, null, null, null));
98
        session.sendBuildFinished(makeAntEvent(realSession, null, -1, null, null, null));
99
        List<Message> expectedMessages = Arrays.asList(new Message[] {
99
        List<Message> expectedMessages = Arrays.asList(new Message[] {
100
            new Message("ant -f " + MockAntSession.MOCK_SCRIPT + " " + MockAntSession.MOCK_TARGET, false, null),
100
            new Message(NbBundle.getMessage(StandardLogger.class, "MSG_target_started_printed", "some-target"), false, null),
101
            new Message(NbBundle.getMessage(StandardLogger.class, "MSG_target_started_printed", "some-target"), false, null),
101
            new Message("some message", true, null),
102
            new Message("some message", true, null),
102
            new Message(NbBundle.getMessage(StandardLogger.class, "FMT_finished_target_printed", new Integer(0), new Integer(15)), false, null),
103
            new Message(NbBundle.getMessage(StandardLogger.class, "FMT_finished_target_printed", new Integer(0), new Integer(15)), false, null),
Lines 121-126 Link Here
121
            AntEvent.LOG_WARN, null, null, null));
122
            AntEvent.LOG_WARN, null, null, null));
122
        session.sendBuildFinished(makeAntEvent(realSession, null, -1, null, null, null));
123
        session.sendBuildFinished(makeAntEvent(realSession, null, -1, null, null, null));
123
        List<Message> expectedMessages = Arrays.asList(
124
        List<Message> expectedMessages = Arrays.asList(
125
            new Message("ant -f " + MockAntSession.MOCK_SCRIPT + " " + MockAntSession.MOCK_TARGET, false, null),
124
            new Message("Stack trace in separate lines:", false, null),
126
            new Message("Stack trace in separate lines:", false, null),
125
            new Message("\tat Foo.java:3", false, new MockHyperlink("file:/src/Foo.java", "stack trace", 3, -1, -1, -1)),
127
            new Message("\tat Foo.java:3", false, new MockHyperlink("file:/src/Foo.java", "stack trace", 3, -1, -1, -1)),
126
            new Message("\tat Bar.java:5", false, new MockHyperlink("file:/src/Bar.java", "stack trace", 5, -1, -1, -1)),
128
            new Message("\tat Bar.java:5", false, new MockHyperlink("file:/src/Bar.java", "stack trace", 5, -1, -1, -1)),
Lines 165-170 Link Here
165
        session.sendTargetFinished(makeAntEvent(realSession, null, -1, null, "some-target", null));
167
        session.sendTargetFinished(makeAntEvent(realSession, null, -1, null, "some-target", null));
166
        session.sendBuildFinished(makeAntEvent(realSession, null, -1, null, null, null));
168
        session.sendBuildFinished(makeAntEvent(realSession, null, -1, null, null, null));
167
        List<Message> expectedMessages = Arrays.asList(
169
        List<Message> expectedMessages = Arrays.asList(
170
            new Message("ant -f " + MockAntSession.MOCK_SCRIPT + " " + MockAntSession.MOCK_TARGET, false, null),
168
            new Message(NbBundle.getMessage(StandardLogger.class, "MSG_target_started_printed", "some-target"), false, null),
171
            new Message(NbBundle.getMessage(StandardLogger.class, "MSG_target_started_printed", "some-target"), false, null),
169
            /*
172
            /*
170
            new Message("c:\\temp\\foo: malformed", true, new MockHyperlink("c:\\temp\\foo", "malformed", -1, -1, -1, -1)),
173
            new Message("c:\\temp\\foo: malformed", true, new MockHyperlink("c:\\temp\\foo", "malformed", -1, -1, -1, -1)),
Lines 206-211 Link Here
206
     * Display name always "Mock Session"; orig target is "mock-target"; orig script is "/tmp/mock-script".
209
     * Display name always "Mock Session"; orig target is "mock-target"; orig script is "/tmp/mock-script".
207
     */
210
     */
208
    private static final class MockAntSession implements LoggerTrampoline.AntSessionImpl {
211
    private static final class MockAntSession implements LoggerTrampoline.AntSessionImpl {
212
213
        static final File MOCK_SCRIPT = new File("/tmp/mock-script");
214
        static final String MOCK_TARGET = "mock-target";
209
        
215
        
210
        private final AntLogger[] loggers;
216
        private final AntLogger[] loggers;
211
        private final int verbosity;
217
        private final int verbosity;
Lines 318-333 Link Here
318
        }
324
        }
319
325
320
        public String[] getOriginatingTargets() {
326
        public String[] getOriginatingTargets() {
321
            return new String[] {"mock-target"};
327
            return new String[] {MOCK_TARGET};
322
        }
328
        }
323
329
324
        public File getOriginatingScript() {
330
        public File getOriginatingScript() {
325
            return new File(System.getProperty("java.io.tmpdir"), "mock-script");
331
            return MOCK_SCRIPT;
326
        }
332
        }
327
333
328
        public String getDisplayName() {
334
        public String getDisplayName() {
329
            return "Mock Session";
335
            return "Mock Session";
330
        }
336
        }
337
338
        @Override public Map<String, String> getProperties() {
339
            return Collections.emptyMap();
340
        }
331
        
341
        
332
    }
342
    }
333
343

Return to bug 206161