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

(-)a/java.project/apichanges.xml (-2 / +18 lines)
Lines 2-8 Link Here
2
<!--
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
4
5
Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
6
6
7
7
8
The contents of this file are subject to the terms of either the GNU
8
The contents of this file are subject to the terms of either the GNU
Lines 26-32 Link Here
26
Contributor(s):
26
Contributor(s):
27
27
28
The Original Software is NetBeans. The Initial Developer of the Original
28
The Original Software is NetBeans. The Initial Developer of the Original
29
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
29
Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
30
Microsystems, Inc. All Rights Reserved.
30
Microsystems, Inc. All Rights Reserved.
31
31
32
If you wish your version of this file to be governed by only the CDDL
32
If you wish your version of this file to be governed by only the CDDL
Lines 106-111 Link Here
106
    <!-- ACTUAL CHANGES BEGIN HERE: -->
106
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
107
108
    <changes>
108
    <changes>
109
        
110
        <change id="ProjectRunner">
111
            <api name="general"/>
112
            <summary>Added ProjectRunner</summary>
113
            <version major="1" minor="19"/>
114
            <date day="7" month="7" year="2008"/>
115
            <author login="jlahoda"/>
116
            <compatibility addition="yes"/>
117
            <description>
118
                <p>
119
                    Class <code>ProjectRunner</code> added.
120
                </p>
121
            </description>
122
            <class package="org.netbeans.spi.java.project.runner" name="ProjectRunner"/>
123
            <issue number="999999"/>
124
        </change>
109
        
125
        
110
        <change id="LookupMerger">
126
        <change id="LookupMerger">
111
            <api name="classpath"/>
127
            <api name="classpath"/>
(-)a/java.project/manifest.mf (-1 / +1 lines)
Lines 3-8 Link Here
3
OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/java/project/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/project/Bundle.properties
5
OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
5
OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker
6
OpenIDE-Module-Specification-Version: 1.18
6
OpenIDE-Module-Specification-Version: 1.19
7
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Show-In-Client: false
8
8
(-)a/java.project/nbproject/project.xml (-9 / +18 lines)
Lines 173-178 Link Here
173
                    </run-dependency>
173
                    </run-dependency>
174
                </dependency>
174
                </dependency>
175
                <dependency>
175
                <dependency>
176
                    <code-name-base>org.openide.execution</code-name-base>
177
                    <build-prerequisite/>
178
                    <compile-dependency/>
179
                    <run-dependency>
180
                        <specification-version>1.12</specification-version>
181
                    </run-dependency>
182
                </dependency>
183
                <dependency>
176
                    <code-name-base>org.openide.filesystems</code-name-base>
184
                    <code-name-base>org.openide.filesystems</code-name-base>
177
                    <build-prerequisite/>
185
                    <build-prerequisite/>
178
                    <compile-dependency/>
186
                    <compile-dependency/>
Lines 310-326 Link Here
310
                <test-type>
318
                <test-type>
311
                    <name>qa-functional</name>
319
                    <name>qa-functional</name>
312
                    <test-dependency>
320
                    <test-dependency>
313
                         <code-name-base>org.netbeans.modules.java.platform</code-name-base>
321
                        <code-name-base>org.netbeans.modules.java.platform</code-name-base>
314
                         <compile-dependency/>
322
                        <compile-dependency/>
315
                    </test-dependency>                    
323
                    </test-dependency>
316
                    <test-dependency>
324
                    <test-dependency>
317
                         <code-name-base>org.netbeans.modules.project.libraries</code-name-base>
325
                        <code-name-base>org.netbeans.modules.project.libraries</code-name-base>
318
                         <compile-dependency/>
326
                        <compile-dependency/>
319
                    </test-dependency>                    
327
                    </test-dependency>
320
                    <test-dependency>
328
                    <test-dependency>
321
                         <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
329
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
322
                         <recursive/>
330
                        <recursive/>
323
                         <compile-dependency/>
331
                        <compile-dependency/>
324
                    </test-dependency>
332
                    </test-dependency>
325
                    <test-dependency>
333
                    <test-dependency>
326
                        <code-name-base>org.netbeans.api.progress</code-name-base>
334
                        <code-name-base>org.netbeans.api.progress</code-name-base>
Lines 358-363 Link Here
358
                <package>org.netbeans.api.java.project.classpath</package>
366
                <package>org.netbeans.api.java.project.classpath</package>
359
                <package>org.netbeans.spi.java.project.classpath</package>
367
                <package>org.netbeans.spi.java.project.classpath</package>
360
                <package>org.netbeans.spi.java.project.classpath.support</package>
368
                <package>org.netbeans.spi.java.project.classpath.support</package>
369
                <package>org.netbeans.spi.java.project.runner</package>
361
                <package>org.netbeans.spi.java.project.support</package>
370
                <package>org.netbeans.spi.java.project.support</package>
362
                <package>org.netbeans.spi.java.project.support.ui</package>
371
                <package>org.netbeans.spi.java.project.support.ui</package>
363
                <package>org.netbeans.spi.java.project.support.ui.templates</package>
372
                <package>org.netbeans.spi.java.project.support.ui.templates</package>
(-)a/java.project/src/org/netbeans/spi/java/project/runner/ProjectRunner.java (+321 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.spi.java.project.runner;
41
42
import java.io.File;
43
import java.io.IOException;
44
import java.lang.reflect.InvocationTargetException;
45
import java.lang.reflect.Method;
46
import java.util.Properties;
47
import java.util.logging.Level;
48
import java.util.logging.Logger;
49
import org.apache.tools.ant.module.api.support.ActionUtils;
50
import org.netbeans.api.java.classpath.ClassPath;
51
import org.netbeans.api.java.classpath.ClassPath.Entry;
52
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileUtil;
54
import org.openide.filesystems.Repository;
55
import org.openide.util.Exceptions;
56
import org.openide.util.Lookup;
57
import org.openide.util.Parameters;
58
59
/**
60
 * <p>Class that allows to execute given file(s). API clients can check whether given
61
 * command is support, by calling
62
 * {@link #isSupported(String)} and execute the command by calling
63
 * {@link #execute(String, Properties, List)}. Please consult documentation of particular
64
 * commands for the list of supported properties.</p>
65
 *
66
 * <p>SPI clients (command providers) should write a short ant build script performing
67
 * the given command and register it on the default filesystem as <code>executor-snippets/&lt;command&gt;.xml</code>.
68
 * The project runner will automatically set the following properties:</p>
69
 * <ul>
70
 * <li><strong>classpath</strong> contains executable classpath of the executed file</li>
71
 * <li><strong>classname</strong> contains a classname corresponding to the file that should be executed</li>
72
 * </ul>
73
 *
74
 * <p>If the script defines an attribute <code>checkSupported</code> of a string value, the value is
75
 * interpreted as a name of a static method with one parameter of type {@link FileObject}.
76
 * When the API client invokes the {@link #isSupported(String,FileObject)} method, the
77
 * method specified by the <code>checkSupported</code> is invoked. Its parameter is
78
 * the same as the second parameter of {@link #isSupported(String,FileObject)}.
79
 * {@link #isSupported(String,FileObject)} returns true if and only if script exists for the given
80
 * command and either the <code>checkSupported</code> attribute is not specified or
81
 * the method specified by this attribute exists and returns boolean value <code>true</code>.
82
 *
83
 * @since 1.19
84
 *
85
 * @author Jan Lahoda
86
 */
87
public final class ProjectRunner {
88
89
    /**
90
     * "Test" run the given file. Classfiles produced by the Java infrastructure will be
91
     * executed.
92
     *
93
     * Supported properties:
94
     * <ul>
95
     * <li><strong>run.jvmargs</strong> arguments that will be passed to the Java Virtual Machine</li>
96
     * <li><strong>application.args</strong> arguments that will be passed to the executed files</li>
97
     * </ul>
98
     *
99
     * @since 1.19
100
     */
101
    public static final String QUICK_RUN = "run";
102
103
    /**
104
     * "Test" run the given file in the debugging mode. Classfiles produced by the Java infrastructure will be
105
     * executed.
106
     *
107
     * Supported properties:
108
     * <ul>
109
     * <li><strong>run.jvmargs</strong> arguments that will be passed to the Java Virtual Machine</li>
110
     * <li><strong>application.args</strong> arguments that will be passed to the executed files</li>
111
     * </ul>
112
     *
113
     * @since 1.19
114
     */
115
    public static final String QUICK_DEBUG = "debug";
116
117
    /**
118
     * "Test" run the given test. Classfiles produced by the Java infrastructure will be
119
     * executed.
120
     *
121
     * Supported properties: none.
122
     *
123
     * @since 1.19
124
     */
125
    public static final String QUICK_TEST = "junit";
126
127
    /**
128
     * "Test" run the given test in the debugging mode. Classfiles produced by the Java infrastructure will be
129
     * executed.
130
     *
131
     * Supported properties: none.
132
     *
133
     * @since 1.19
134
     */
135
    public static final String QUICK_TEST_DEBUG = "junit-debug";
136
137
    private static final Logger LOG = Logger.getLogger(ProjectRunner.class.getName());
138
139
    /**
140
     * Check whether the given command is supported.
141
     *
142
     * @param command command name
143
     * @param toRun either the file that would be executed, or the project folder
144
     * @return true if and only if the given command is supported for given file/folder
145
     *
146
     * @since 1.19
147
     */
148
    public static boolean isSupported(String command, FileObject toRun) {
149
        Parameters.notNull("command", command);
150
        Parameters.notNull("toRun", toRun);
151
152
        FileObject script = locateScript(command);
153
154
        if (script == null) {
155
            return false;
156
        }
157
158
        Object attribute = script.getAttribute("checkSupported");
159
160
        if (attribute == null) {
161
            return true;
162
        }
163
164
        if (!(attribute instanceof String)) {
165
            LOG.log(Level.WARNING, "checkSupported attribute of {0} is not a String value (class: {1})", new Object[] {FileUtil.getFileDisplayName(script), attribute.getClass()});
166
            return false;
167
        }
168
169
        try {
170
            String m = (String) attribute;
171
            int lastDot = m.lastIndexOf('.');
172
173
            if (lastDot == (-1)) {
174
                LOG.log(Level.WARNING, "checkSupported attribute of {0} is malformed: {1})", new Object[] {FileUtil.getFileDisplayName(script), m});
175
                return false;
176
            }
177
178
            String clazzName = m.substring(0, lastDot);
179
            String methodName = m.substring(lastDot + 1);
180
181
            ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class);
182
            Class clazz;
183
184
            if (loader != null) {
185
                clazz = Class.forName(clazzName, true, loader);
186
            } else {
187
                clazz = Class.forName(clazzName);
188
            }
189
190
            Method method = clazz.getDeclaredMethod(methodName, FileObject.class);
191
192
            method.setAccessible(true);
193
194
            Object r = method.invoke(null, toRun);
195
196
            return r instanceof Boolean && (Boolean) r;
197
        } catch (IllegalAccessException ex) {
198
            LOG.log(Level.WARNING, "Cannot execute checkSupported method for {0} because of an exception.", new Object[] {FileUtil.getFileDisplayName(script), ex});
199
            return false;
200
        } catch (IllegalArgumentException ex) {
201
            LOG.log(Level.WARNING, "Cannot execute checkSupported method for {0} because of an exception.", new Object[] {FileUtil.getFileDisplayName(script), ex});
202
            return false;
203
        } catch (InvocationTargetException ex) {
204
            LOG.log(Level.WARNING, "Cannot execute checkSupported method for {0} because of an exception.", new Object[] {FileUtil.getFileDisplayName(script), ex});
205
            return false;
206
        } catch (NoSuchMethodException ex) {
207
            LOG.log(Level.WARNING, "Cannot execute checkSupported method for {0} because of an exception.", new Object[] {FileUtil.getFileDisplayName(script), ex});
208
            return false;
209
        } catch (SecurityException ex) {
210
            LOG.log(Level.WARNING, "Cannot execute checkSupported method for {0} because of an exception.", new Object[] {FileUtil.getFileDisplayName(script), ex});
211
            return false;
212
        } catch (ClassNotFoundException ex) {
213
            LOG.log(Level.WARNING, "Cannot execute checkSupported method for {0} because of an exception.", new Object[] {FileUtil.getFileDisplayName(script), ex});
214
            return false;
215
        }
216
    }
217
218
    /**
219
     * Execute the given command with given parameters. Please refer to the documentation
220
     * of the given command for supported properties.
221
     *
222
     * @param command command to execute
223
     * @param props properties
224
     * @param toRun file to run
225
     * @throws java.io.IOException if execution fails
226
     *
227
     * @since 1.19
228
     */
229
    public static void execute(String command, Properties props, FileObject toRun) throws IOException {
230
        ClassPath exec = ClassPath.getClassPath(toRun, ClassPath.EXECUTE);
231
        ClassPath source = ClassPath.getClassPath(toRun, ClassPath.SOURCE);
232
233
        LOG.log(Level.FINE, "execute classpath={0}", exec);
234
235
        String cp = toString(exec);
236
237
        Properties antProps = (Properties) props.clone();
238
239
        antProps.setProperty("classpath", cp);
240
        antProps.setProperty("classname", source.getResourceName(toRun, '.', false));
241
242
        ActionUtils.runTarget(buildScript(command), new String[] {"execute"}, antProps);
243
    }
244
245
    private static String toString(ClassPath exec) {
246
        StringBuilder cp = new StringBuilder();
247
        boolean first = true;
248
249
        for (Entry e : exec.entries()) {
250
            if (!first) {
251
                cp.append(File.pathSeparatorChar);
252
            }
253
254
            File f = FileUtil.archiveOrDirForURL(e.getURL());
255
256
            if (f != null) {
257
                cp.append(f.getAbsolutePath());
258
                first = false;
259
            }
260
        }
261
262
        return cp.toString();
263
    }
264
265
    private static FileObject locateScript(String actionName) {
266
        return Repository.getDefault().getDefaultFileSystem().findResource("executor-snippets/" + actionName + ".xml");
267
    }
268
269
    private static FileObject buildScript(String actionName) {
270
        FileObject script = locateScript(actionName);
271
272
        if (script == null) {
273
            return null;
274
        }
275
276
        File scriptFile = new File(getCacheFolder(), actionName + ".xml");
277
278
        if (!scriptFile.canRead() || script.lastModified().getTime() > scriptFile.lastModified()) {
279
            try {
280
                scriptFile.delete();
281
282
                FileObject parent = FileUtil.createFolder(scriptFile.getParentFile());
283
284
                return FileUtil.copyFile(script, parent, actionName);
285
            } catch (IOException ex) {
286
                Exceptions.printStackTrace(ex);
287
                return null;
288
            }
289
        }
290
291
        return FileUtil.toFileObject(scriptFile);
292
    }
293
294
    private static final String NB_USER_DIR = "netbeans.user";   //NOI18N
295
    private static final String SNIPPETS_CACHE_DIR = "var"+File.separatorChar+"cache"+File.separatorChar+"executor-snippets";    //NOI18N
296
297
298
    private static String getNbUserDir () {
299
        final String nbUserProp = System.getProperty(NB_USER_DIR);
300
        return nbUserProp;
301
    }
302
303
    private static File cacheFolder;
304
305
    private static synchronized File getCacheFolder () {
306
        if (cacheFolder == null) {
307
            final String nbUserDirProp = getNbUserDir();
308
            assert nbUserDirProp != null;
309
            final File nbUserDir = new File (nbUserDirProp);
310
            cacheFolder = FileUtil.normalizeFile(new File (nbUserDir, SNIPPETS_CACHE_DIR));
311
            if (!cacheFolder.exists()) {
312
                boolean created = cacheFolder.mkdirs();
313
                assert created : "Cannot create cache folder";  //NOI18N
314
            }
315
            else {
316
                assert cacheFolder.isDirectory() && cacheFolder.canRead() && cacheFolder.canWrite();
317
            }
318
        }
319
        return cacheFolder;
320
    }
321
}
(-)a/java.source/nbproject/project.properties (-3 / +4 lines)
Lines 1-6 Link Here
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
#
2
#
3
# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
3
# Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
4
#
4
#
5
# The contents of this file are subject to the terms of either the GNU
5
# The contents of this file are subject to the terms of either the GNU
6
# General Public License Version 2 only ("GPL") or the Common
6
# General Public License Version 2 only ("GPL") or the Common
Lines 23-29 Link Here
23
# Contributor(s):
23
# Contributor(s):
24
#
24
#
25
# The Original Software is NetBeans. The Initial Developer of the Original
25
# The Original Software is NetBeans. The Initial Developer of the Original
26
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
26
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
27
# Microsystems, Inc. All Rights Reserved.
27
# Microsystems, Inc. All Rights Reserved.
28
#
28
#
29
# If you wish your version of this file to be governed by only the CDDL
29
# If you wish your version of this file to be governed by only the CDDL
Lines 38-49 Link Here
38
# made subject to such option by the copyright holder.
38
# made subject to such option by the copyright holder.
39
#javac.compilerargs=-Xlint:unchecked
39
#javac.compilerargs=-Xlint:unchecked
40
nbroot=../..
40
nbroot=../..
41
ant.jar=${ant.core.lib}
41
javac.source=1.5
42
javac.source=1.5
42
javadoc.name=Java Source
43
javadoc.name=Java Source
43
javadoc.title=Java Source
44
javadoc.title=Java Source
44
javadoc.arch=${basedir}/arch.xml
45
javadoc.arch=${basedir}/arch.xml
45
javadoc.apichanges=${basedir}/apichanges.xml
46
javadoc.apichanges=${basedir}/apichanges.xml
46
spec.version.base=0.36.0
47
spec.version.base=0.37.0
47
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
48
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
48
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
49
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
49
    ${o.n.core.dir}/lib/boot.jar:\
50
    ${o.n.core.dir}/lib/boot.jar:\
(-)a/java.source/nbproject/project.xml (+49 lines)
Lines 46-51 Link Here
46
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
46
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
47
            <code-name-base>org.netbeans.modules.java.source</code-name-base>
47
            <code-name-base>org.netbeans.modules.java.source</code-name-base>
48
            <module-dependencies>
48
            <module-dependencies>
49
                <dependency>
50
                    <code-name-base>org.apache.tools.ant.module</code-name-base>
51
                    <build-prerequisite/>
52
                    <compile-dependency/>
53
                    <run-dependency>
54
                        <release-version>3</release-version>
55
                        <specification-version>3.30</specification-version>
56
                    </run-dependency>
57
                </dependency>
49
                <dependency>
58
                <dependency>
50
                    <code-name-base>org.jdesktop.layout</code-name-base>
59
                    <code-name-base>org.jdesktop.layout</code-name-base>
51
                    <build-prerequisite/>
60
                    <build-prerequisite/>
Lines 203-208 Link Here
203
                    </run-dependency>
212
                    </run-dependency>
204
                </dependency>
213
                </dependency>
205
                <dependency>
214
                <dependency>
215
                    <code-name-base>org.netbeans.modules.java.project</code-name-base>
216
                    <build-prerequisite/>
217
                    <compile-dependency/>
218
                    <run-dependency>
219
                        <release-version>1</release-version>
220
                        <specification-version>1.16</specification-version>
221
                    </run-dependency>
222
                </dependency>
223
                <dependency>
206
                    <code-name-base>org.netbeans.modules.lexer</code-name-base>
224
                    <code-name-base>org.netbeans.modules.lexer</code-name-base>
207
                    <build-prerequisite/>
225
                    <build-prerequisite/>
208
                    <compile-dependency/>
226
                    <compile-dependency/>
Lines 227-232 Link Here
227
                    <run-dependency>
245
                    <run-dependency>
228
                        <release-version>1</release-version>
246
                        <release-version>1</release-version>
229
                        <specification-version>1.5</specification-version>
247
                        <specification-version>1.5</specification-version>
248
                    </run-dependency>
249
                </dependency>
250
                <dependency>
251
                    <code-name-base>org.netbeans.modules.project.ant</code-name-base>
252
                    <build-prerequisite/>
253
                    <compile-dependency/>
254
                    <run-dependency>
255
                        <release-version>1</release-version>
256
                        <specification-version>1.20</specification-version>
230
                    </run-dependency>
257
                    </run-dependency>
231
                </dependency>
258
                </dependency>
232
                <dependency>
259
                <dependency>
Lines 290-300 Link Here
290
                    </run-dependency>
317
                    </run-dependency>
291
                </dependency>
318
                </dependency>
292
                <dependency>
319
                <dependency>
320
                    <code-name-base>org.openide.execution</code-name-base>
321
                    <build-prerequisite/>
322
                    <compile-dependency/>
323
                    <run-dependency>
324
                        <specification-version>1.12</specification-version>
325
                    </run-dependency>
326
                </dependency>
327
                <dependency>
293
                    <code-name-base>org.openide.filesystems</code-name-base>
328
                    <code-name-base>org.openide.filesystems</code-name-base>
294
                    <build-prerequisite/>
329
                    <build-prerequisite/>
295
                    <compile-dependency/>
330
                    <compile-dependency/>
296
                    <run-dependency>
331
                    <run-dependency>
297
                        <specification-version>7.7</specification-version>
332
                        <specification-version>7.7</specification-version>
333
                    </run-dependency>
334
                </dependency>
335
                <dependency>
336
                    <code-name-base>org.openide.io</code-name-base>
337
                    <build-prerequisite/>
338
                    <compile-dependency/>
339
                    <run-dependency>
340
                        <specification-version>1.12</specification-version>
298
                    </run-dependency>
341
                    </run-dependency>
299
                </dependency>
342
                </dependency>
300
                <dependency>
343
                <dependency>
Lines 517-522 Link Here
517
                <package>org.netbeans.api.java.source.support</package>
560
                <package>org.netbeans.api.java.source.support</package>
518
                <package>org.netbeans.spi.java.loaders</package>
561
                <package>org.netbeans.spi.java.loaders</package>
519
            </public-packages>
562
            </public-packages>
563
            <extra-compilation-unit>
564
                <package-root>antsrc</package-root>
565
                <classpath>${module.classpath}:${ant.jar}:${tools.jar}:${cluster}/modules/${code.name.base.dashes}.jar</classpath>
566
                <built-to>build/antclasses</built-to>
567
                <built-to>${cluster}/ant/nblib/${code.name.base.dashes}.jar</built-to>
568
            </extra-compilation-unit>
520
        </data>
569
        </data>
521
    </configuration>
570
    </configuration>
522
</project>
571
</project>
(-)a/java.source/src/org/netbeans/api/java/source/BuildArtifactMapper.java (+94 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 * 
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 * 
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 * 
35
 * Contributor(s):
36
 * 
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.api.java.source;
41
42
import java.io.File;
43
import java.net.URL;
44
import org.netbeans.api.java.queries.BinaryForSourceQuery;
45
import org.netbeans.modules.java.source.usages.BuildArtifactMapperImpl;
46
47
/**
48
 * @since 0.37
49
 * 
50
 * @author Jan Lahoda
51
 */
52
public class BuildArtifactMapper {
53
54
    /**
55
     * Add an {@link ArtifactsUpdated} listener. The method {@link ArtifactsUpdated#artifactsUpdated(java.lang.Iterable)}
56
     * will be called each time the files inside the output folder are updated.
57
     * The output folder computed for the source root using the {@link BinaryForSourceQuery}.
58
     * The files in the output folder are updated only if file <code>.netbeans_automatic_build</code>
59
     * exists inside the output folder.
60
     * 
61
     * @param sourceRoot the listener will be assigned to this source root
62
     * @param listener listener to add
63
     * @since 0.37
64
     */
65
    public static void addArtifactsUpdatedListener(URL sourceRoot, ArtifactsUpdated listener) {
66
        BuildArtifactMapperImpl.addArtifactsUpdatedListener(sourceRoot, listener);
67
    }
68
    
69
    /**
70
     * Remove an {@link ArtifactsUpdated} listener.
71
     *
72
     * @param sourceRoot the listener will be assigned to this source root
73
     * @param listener listener to add
74
     * @since 0.37
75
     */
76
    public static void removeArtifactsUpdatedListener(URL sourceRoot, ArtifactsUpdated listener) {
77
        BuildArtifactMapperImpl.removeArtifactsUpdatedListener(sourceRoot, listener);
78
    }
79
80
    /**
81
     * Notify that the files in the output directory has been updated.
82
     * @since 0.37
83
     */
84
    public static interface ArtifactsUpdated {
85
        /**
86
         * Notify that the files in the output directory has been updated.
87
         *
88
         * @param artifacts the updated files
89
         * @since 0.37
90
         */
91
        public void artifactsUpdated(Iterable<File> artifacts);
92
    }
93
    
94
}
(-)a/java.source/arch.xml (+5 lines)
Lines 72-77 Link Here
72
 <answer id="arch-overall">
72
 <answer id="arch-overall">
73
  <p>
73
  <p>
74
   Provides Java Model API access.
74
   Provides Java Model API access.
75
   <api type="export" category="devel" group="property" name="ensure.built.source.roots">
76
       When the <code>ensure.built.source.roots</code> property is set during ant script execution,
77
       the <code>javac</code> task will not actually build the classfiles from scratch, but rather copy classfiles
78
       produced by the Java infrastructure into the output folder.
79
   </api>
75
  </p>
80
  </p>
76
 </answer>
81
 </answer>
77
82
(-)a/java.source/apichanges.xml (+12 lines)
Lines 105-110 Link Here
105
    <!-- ACTUAL CHANGES BEGIN HERE: -->
105
    <!-- ACTUAL CHANGES BEGIN HERE: -->
106
106
107
    <changes>
107
    <changes>
108
        <change id="BuildArtifactMapper">
109
             <api name="general"/>
110
             <summary>Added BuildArtifactMapper</summary>
111
             <version major="0" minor="37"/>
112
             <date day="7" month="7" year="2008"/>
113
             <author login="jlahoda"/>
114
             <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
115
             <description>
116
                 Added BuildArtifactMapper.
117
             </description>
118
             <class package="org.netbeans.api.java.source" name="BuildArtifactMapper" />
119
        </change>
108
        <change id="TypeUtilities.substitute">
120
        <change id="TypeUtilities.substitute">
109
             <api name="general"/>
121
             <api name="general"/>
110
             <summary>Added TypeUtilities.substitute</summary>
122
             <summary>Added TypeUtilities.substitute</summary>

Return to bug 138504