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

(-)a/o.apache.tools.ant.module/apichanges.xml (+29 lines)
Lines 106-111 is the proper place. Link Here
106
<!-- ACTUAL CHANGES BEGIN HERE: -->
106
<!-- ACTUAL CHANGES BEGIN HERE: -->
107
107
108
    <changes>
108
    <changes>
109
110
        <change id="AntEvent-references">
111
            <api name="general"/>
112
            <summary>Ant loggers can now inspect Ant reference objects</summary>
113
            <version major="3" minor="29"/>
114
            <date day="6" month="3" year="2008"/>
115
            <author login="jglick"/>
116
            <compatibility modification="yes" semantic="compatible">
117
                <p>
118
                    Properties of the same name take precedence over references,
119
                    so only code which relied on a property name <em>not</em>
120
                    being set would see different behavior.
121
                </p>
122
            </compatibility>
123
            <description>
124
                <p>
125
                    The <code>AntEvent</code> methods <code>getProperty</code> and
126
                    <code>getPropertyNames</code> can now work with Ant references
127
                    as well as plain properties. This is critical for loggers which
128
                    wish to inspect e.g. the runtime value of a classpath given as:
129
                </p>
130
                <pre>&lt;classpath refid="my.cp"/&gt;</pre>
131
                <p>
132
                    which otherwise would be inaccessible.
133
                </p>
134
            </description>
135
            <class package="org.apache.tools.ant.module.spi" name="AntEvent"/>
136
            <issue number="128778"/>
137
        </change>
109
138
110
        <change id="IntrospectedInfo.serializable">
139
        <change id="IntrospectedInfo.serializable">
111
            <api name="general"/>
140
            <api name="general"/>
(-)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.28.0
42
spec.version.base=3.29.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/src-bridge/org/apache/tools/ant/module/bridge/impl/NbBuildLogger.java (-2 / +11 lines)
Lines 52-57 import java.util.Comparator; Link Here
52
import java.util.Comparator;
52
import java.util.Comparator;
53
import java.util.Enumeration;
53
import java.util.Enumeration;
54
import java.util.HashMap;
54
import java.util.HashMap;
55
import java.util.HashSet;
55
import java.util.LinkedHashSet;
56
import java.util.LinkedHashSet;
56
import java.util.LinkedList;
57
import java.util.LinkedList;
57
import java.util.List;
58
import java.util.List;
Lines 1163-1169 final class NbBuildLogger implements Bui Link Here
1163
                if (o instanceof String) {
1164
                if (o instanceof String) {
1164
                    return (String) o;
1165
                    return (String) o;
1165
                } else {
1166
                } else {
1166
                    return null;
1167
                    o = project.getReference(name);
1168
                    if (o != null) {
1169
                        return o.toString();
1170
                    } else {
1171
                        return null;
1172
                    }
1167
                }
1173
                }
1168
            } else {
1174
            } else {
1169
                return null;
1175
                return null;
Lines 1174-1180 final class NbBuildLogger implements Bui Link Here
1174
            verifyRunning();
1180
            verifyRunning();
1175
            Project project = getProjectIfPropertiesDefined();
1181
            Project project = getProjectIfPropertiesDefined();
1176
            if (project != null) {
1182
            if (project != null) {
1177
                return NbCollections.checkedSetByFilter(project.getProperties().keySet(), String.class, true);
1183
                Set<String> s = new HashSet<String>();
1184
                s.addAll(NbCollections.checkedSetByFilter(project.getProperties().keySet(), String.class, true));
1185
                s.addAll(NbCollections.checkedSetByFilter(project.getReferences().keySet(), String.class, true));
1186
                return s;
1178
            } else {
1187
            } else {
1179
                return Collections.emptySet();
1188
                return Collections.emptySet();
1180
            }
1189
            }
(-)a/o.apache.tools.ant.module/src/org/apache/tools/ant/module/spi/AntEvent.java (+2 lines)
Lines 206-211 public final class AntEvent { Link Here
206
    
206
    
207
    /**
207
    /**
208
     * Get a property set on the current Ant project.
208
     * Get a property set on the current Ant project.
209
     * Also can retrieve references using their string values since org.apache.tools.ant.module/3 3.29.
209
     * @param name the property name
210
     * @param name the property name
210
     * @return its value, or null
211
     * @return its value, or null
211
     */
212
     */
Lines 215-220 public final class AntEvent { Link Here
215
    
216
    
216
    /**
217
    /**
217
     * Get a set of property names defined on the current Ant project.
218
     * Get a set of property names defined on the current Ant project.
219
     * Also includes reference names since org.apache.tools.ant.module/3 3.29.
218
     * @return a set of property names; may be empty but not null
220
     * @return a set of property names; may be empty but not null
219
     */
221
     */
220
    public Set<String> getPropertyNames() {
222
    public Set<String> getPropertyNames() {
(-)a/o.apache.tools.ant.module/test/unit/data/antlogger/reference.xml (+6 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project name="reference" default="run" basedir=".">
3
    <target name="run">
4
        <path id="p" path="reference.xml"/>
5
    </target>
6
</project>
(-)a/o.apache.tools.ant.module/test/unit/src/org/apache/tools/ant/module/spi/AntLoggerTest.java (-1 / +17 lines)
Lines 192-197 public class AntLoggerTest extends NbTes Link Here
192
        run(testdirFO.getFileObject("trivial.xml"), null, AntEvent.LOG_VERBOSE);
192
        run(testdirFO.getFileObject("trivial.xml"), null, AntEvent.LOG_VERBOSE);
193
        // see TestLogger.taskStarted for details
193
        // see TestLogger.taskStarted for details
194
    }
194
    }
195
196
    public void testReferences() throws Exception {
197
        LOGGER.interestedInSessionFlag = true;
198
        LOGGER.interestedInAllScriptsFlag = true;
199
        LOGGER.interestingTargets = AntLogger.ALL_TARGETS;
200
        FileObject rxml = testdirFO.getFileObject("reference.xml");
201
        run(rxml);
202
        assertEquals(FileUtil.toFile(rxml).getAbsolutePath(), LOGGER.referenceValue);
203
    }
195
    
204
    
196
    /**
205
    /**
197
     * Sample logger which collects results.
206
     * Sample logger which collects results.
Lines 211-216 public class AntLoggerTest extends NbTes Link Here
211
        /** Format of each: "taskname:level:message" */
220
        /** Format of each: "taskname:level:message" */
212
        private List<String> messages;
221
        private List<String> messages;
213
        private boolean antEventDetailsOK;
222
        private boolean antEventDetailsOK;
223
        private String referenceValue;
214
        
224
        
215
        public TestLogger() {}
225
        public TestLogger() {}
216
        
226
        
Lines 226-231 public class AntLoggerTest extends NbTes Link Here
226
            targetsStarted = new ArrayList<String>();
236
            targetsStarted = new ArrayList<String>();
227
            messages = new ArrayList<String>();
237
            messages = new ArrayList<String>();
228
            antEventDetailsOK = false;
238
            antEventDetailsOK = false;
239
            referenceValue = null;
229
            halt = false;
240
            halt = false;
230
        }
241
        }
231
        
242
        
Lines 276-281 public class AntLoggerTest extends NbTes Link Here
276
        }
287
        }
277
        
288
        
278
        @Override
289
        @Override
290
        public void targetFinished(AntEvent event) {
291
            referenceValue = event.getProperty("p");
292
        }
293
294
        @Override
279
        public synchronized void messageLogged(AntEvent event) {
295
        public synchronized void messageLogged(AntEvent event) {
280
            String toadd = "" + event.getLogLevel() + ":" + event.getMessage();
296
            String toadd = "" + event.getLogLevel() + ":" + event.getMessage();
281
            String taskname = event.getTaskName();
297
            String taskname = event.getTaskName();
Lines 304-310 public class AntLoggerTest extends NbTes Link Here
304
            if (halt && event.getTaskName().equals("touch")) {
320
            if (halt && event.getTaskName().equals("touch")) {
305
                try {
321
                try {
306
                    Thread t = new Thread() {
322
                    Thread t = new Thread() {
307
                        public void run() {
323
                        public @Override void run() {
308
                            synchronized (TestLogger.this) {
324
                            synchronized (TestLogger.this) {
309
                                assertEquals("${foobie}", event.evaluate("${foobie}"));
325
                                assertEquals("${foobie}", event.evaluate("${foobie}"));
310
                                TestLogger.this.notify();
326
                                TestLogger.this.notify();

Return to bug 128778