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

(-)a/apisupport.harness/nbproject/project.properties (+1 lines)
Lines 84-89 Link Here
84
    org/netbeans/nbbuild/ModuleSelector*.class,\
84
    org/netbeans/nbbuild/ModuleSelector*.class,\
85
    org/netbeans/nbbuild/ModuleTracking*.class,\
85
    org/netbeans/nbbuild/ModuleTracking*.class,\
86
    org/netbeans/nbbuild/ParseProjectXml*.class,\
86
    org/netbeans/nbbuild/ParseProjectXml*.class,\
87
    org/netbeans/nbbuild/PathFileSet*.class,\
87
    org/netbeans/nbbuild/ShorterPaths*.class,\
88
    org/netbeans/nbbuild/ShorterPaths*.class,\
88
    org/netbeans/nbbuild/SortSuiteModules*.class,\
89
    org/netbeans/nbbuild/SortSuiteModules*.class,\
89
    org/netbeans/nbbuild/UpdateTracking*.class,\
90
    org/netbeans/nbbuild/UpdateTracking*.class,\
(-)a/apisupport.harness/release/run.xml (-14 / +36 lines)
Lines 48-54 Link Here
48
            <isset property="suite.dir"/>
48
            <isset property="suite.dir"/>
49
        </condition>
49
        </condition>
50
        <property name="test.user.dir" location="build/testuserdir"/>
50
        <property name="test.user.dir" location="build/testuserdir"/>
51
        <property name="install" location="${netbeans.dest.dir}"/>
51
        <pathconvert property="install">
52
            <path path="${cluster.path}"/>
53
            <regexpmapper from="(.*)platform[0-9]*$$" to="\1"/>
54
        </pathconvert>
52
        <property name="run.args.common" value='--userdir "${test.user.dir}" -J-Dnetbeans.logger.console=true -J-ea'/>
55
        <property name="run.args.common" value='--userdir "${test.user.dir}" -J-Dnetbeans.logger.console=true -J-ea'/>
53
        <!-- In case run from a suite module, to get app.name and/or branding.token: -->
56
        <!-- In case run from a suite module, to get app.name and/or branding.token: -->
54
        <property file="${suite.dir}/nbproject/private/private.properties"/>
57
        <property file="${suite.dir}/nbproject/private/private.properties"/>
Lines 93-99 Link Here
93
96
94
    <target name="-prepare-as-platform" depends="-init" if="app.name">
97
    <target name="-prepare-as-platform" depends="-init" if="app.name">
95
        <property name="disabled.modules" value=""/>
98
        <property name="disabled.modules" value=""/>
96
        <property name="enabled.clusters" value=""/>
99
        <!-- XXX property name="enabled.clusters" value=""/>
97
        <property name="disabled.clusters" value=""/>
100
        <property name="disabled.clusters" value=""/>
98
        <pathconvert property="run.platform.update.tracking">
101
        <pathconvert property="run.platform.update.tracking">
99
            <path>
102
            <path>
Lines 115-132 Link Here
115
                    </selector>
118
                    </selector>
116
                </fileset>
119
                </fileset>
117
            </path>
120
            </path>
118
            <mapper type="regexp" from="[/\\]([^/\\]+)[/\\](config[/\\]Modules|update_tracking)[/\\]" to="\1"/> <!-- #71849, #73494 -->
121
            <mapper type="regexp" from="[/\\]([^/\\]+)[/\\](config[/\\]Modules|update_tracking)[/\\]" to="\1"/ --> <!-- #71849, #73494 -->
119
        </pathconvert>
122
        <!-- /pathconvert -->
120
        <fail message="Must have at least one cluster from the platform">
123
121
            <!-- Otherwise ${run.platform.clusters} gets filled with nonsense. -->
124
        <fail message="Platform cluster is not present in cluster.path: '${cluster.path}'">
122
            <condition>
125
            <condition>
123
                <equals arg1="${run.platform.clusters.duplicates}" arg2=""/>
126
                <not>
127
                    <matches string="${cluster.path}" pattern="[\\/]platform[0-9]*([;:]|$)"/>
128
                </not>
124
            </condition>
129
            </condition>
125
        </fail>
130
        </fail>
131
        <!-- XXX pathfileset property="run.platform.update.tracking" include="**/update_tracking/*.xml">
132
            <path path="${cluster.path}"/>
133
        </pathfileset>
134
        <pathfileset property="run.platform.clusters.filtered" pathsep=",">
135
            <path path="${cluster.path}"/>
136
            <selector>
137
                <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
138
                    <param name="excludeModules" value="${disabled.modules}"/>
139
                    <param name="includeClusters" value="${enabled.clusters}"/>
140
                    <param name="excludeClusters" value="${disabled.clusters}"/>
141
                    <param name="updateTrackingFiles" value="${run.platform.update.tracking}"/>
142
                </custom>
143
            </selector>
144
        </pathfileset -->
126
        <pathconvert property="run.platform.clusters">
145
        <pathconvert property="run.platform.clusters">
127
            <path>
146
            <path>
128
                <pathelement location="${cluster}"/>
147
                <pathelement location="${cluster}"/>
129
                <dirset dir="${netbeans.dest.dir}" includes="${run.platform.clusters.duplicates}" excludes="platform*"/>
148
                <!-- Does not exclude clusters in which all modules are excluded, shouldn't be a problem -->
149
                <pathelement path="${cluster.path}"/>
130
            </path>
150
            </path>
131
        </pathconvert>
151
        </pathconvert>
132
        <pathconvert property="run.exe">
152
        <pathconvert property="run.exe">
Lines 181-191 Link Here
181
201
182
    <target name="debug">
202
    <target name="debug">
183
        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
203
        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
204
        <pathfileset property="cluster.path.jars" include="**/*.jar">
205
            <path path="${cluster.path}"/>
206
        </pathfileset>
184
        <nbjpdastart name="NetBeans" addressproperty="debug.port" transport="dt_socket">
207
        <nbjpdastart name="NetBeans" addressproperty="debug.port" transport="dt_socket">
185
            <classpath>
208
            <classpath>
186
                <fileset dir="${netbeans.dest.dir}">
209
                <path path="${cluster.path.jars}"/>
187
                    <include name="**/*.jar"/>
188
                </fileset>
189
                <fileset dir="${cluster}">
210
                <fileset dir="${cluster}">
190
                    <include name="**/*.jar"/>
211
                    <include name="**/*.jar"/>
191
                </fileset>
212
                </fileset>
Lines 200-214 Link Here
200
    
221
    
201
    <target name="profile" description="Profile a project in the IDE.">
222
    <target name="profile" description="Profile a project in the IDE.">
202
        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
223
        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
224
        <pathfileset property="cluster.path.jars" include="**/*.jar">
225
            <path path="${cluster.path}"/>
226
        </pathfileset>
203
        <nbprofiledirect 
227
        <nbprofiledirect 
204
            jvmargsprefix="-J" 
228
            jvmargsprefix="-J" 
205
            jvmargsproperty="profiler.jvmargs" 
229
            jvmargsproperty="profiler.jvmargs" 
206
            mainclass="org.netbeans.Main"
230
            mainclass="org.netbeans.Main"
207
        >
231
        >
208
            <classpath>
232
            <classpath>
209
                <fileset dir="${netbeans.dest.dir}">
233
                <path path="${cluster.path.jars}"/>
210
                    <include name="**/*.jar"/>
211
                </fileset>
212
                <fileset dir="${cluster}">
234
                <fileset dir="${cluster}">
213
                    <include name="**/*.jar"/>
235
                    <include name="**/*.jar"/>
214
                </fileset>
236
                </fileset>
(-)a/apisupport.harness/release/suite.xml (-8 / +8 lines)
Lines 105-118 Link Here
105
    <target name="build" depends="-init,branding,release" description="Build all modules in the suite.">
105
    <target name="build" depends="-init,branding,release" description="Build all modules in the suite.">
106
        <subant target="netbeans" buildpath="${modules.sorted}" inheritrefs="false" inheritall="false"/>
106
        <subant target="netbeans" buildpath="${modules.sorted}" inheritrefs="false" inheritall="false"/>
107
        <mkdir dir="${cluster}/config/Modules"/>
107
        <mkdir dir="${cluster}/config/Modules"/>
108
        <createmodulexml xmldir="${cluster}/config/Modules">
108
        <pathfileset pathsep="," property="disabled.modules.paths.list">
109
            <hidden dir="${netbeans.dest.dir}">
109
            <path path="${cluster.path}"/>
110
                <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
110
            <custom classpath="${harness.dir}/tasks.jar" classname="org.netbeans.nbbuild.ModuleSelector">
111
                    <param name="excludeModules" value="${disabled.modules}"/>
111
                <param name="excludeModules" value="${disabled.modules}"/>
112
                    <param name="excluded" value="true"/>
112
                <param name="excluded" value="true"/>
113
                </custom>
113
            </custom>
114
            </hidden>
114
        </pathfileset>
115
        </createmodulexml>
115
        <createmodulexml xmldir="${cluster}/config/Modules" hidden="${disabled.modules.paths.list}"/>
116
    </target>
116
    </target>
117
117
118
    <target name="nbms" depends="build" description="Build NBMs and an Auto Update site descriptor for all modules in the suite.">
118
    <target name="nbms" depends="build" description="Build NBMs and an Auto Update site descriptor for all modules in the suite.">
(-)a/apisupport.harness/taskdefs.properties (+1 lines)
Lines 54-56 Link Here
54
fixtestdeps=org.netbeans.nbbuild.FixTestDependencies
54
fixtestdeps=org.netbeans.nbbuild.FixTestDependencies
55
shorterpaths=org.netbeans.nbbuild.ShorterPaths
55
shorterpaths=org.netbeans.nbbuild.ShorterPaths
56
custom-javac=org.netbeans.nbbuild.CustomJavac
56
custom-javac=org.netbeans.nbbuild.CustomJavac
57
pathfileset=org.netbeans.nbbuild.PathFileSet
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/CreateModuleXML.java (-107 / +140 lines)
Lines 104-116 Link Here
104
    private List<String> autoloadNames = new ArrayList<String>(10);
104
    private List<String> autoloadNames = new ArrayList<String>(10);
105
    private List<String> eagerNames = new ArrayList<String>(10);
105
    private List<String> eagerNames = new ArrayList<String>(10);
106
    private List<String> hiddenNames = new ArrayList<String>(10);
106
    private List<String> hiddenNames = new ArrayList<String>(10);
107
    
107
    private String hiddenList;
108
109
    /**
110
     * In addition to &gt;hidden&lt; nested fileset, list of hidden modules can
111
     * be specified as comma-separated list in attribute 'hidden'.
112
     * @param hiddenList
113
     */
114
    public void setHidden(String hiddenList) {
115
        // Only hidden parameters can be specified as list of absolute file paths,
116
        // enabled, eager and autoload modules need relative path to create proper module xml
117
        this.hiddenList = hiddenList;
118
    }
119
108
    public void execute() throws BuildException {
120
    public void execute() throws BuildException {
109
        if (xmldir == null) throw new BuildException("Must set xmldir attribute", getLocation());
121
        if (xmldir == null) throw new BuildException("Must set xmldir attribute", getLocation());
110
        if (!xmldir.exists ()) {
122
        if (!xmldir.exists ()) {
111
            if (!xmldir.mkdirs()) throw new BuildException("Cannot create directory " + xmldir, getLocation());
123
            if (!xmldir.mkdirs()) throw new BuildException("Cannot create directory " + xmldir, getLocation());
112
        }
124
        }
113
        if (enabled.isEmpty() && disabled.isEmpty() && autoload.isEmpty() && eager.isEmpty() && hidden.isEmpty()) {
125
        if (enabled.isEmpty() && disabled.isEmpty() && autoload.isEmpty() && eager.isEmpty() && hidden.isEmpty()
126
                && hiddenList == null) {
114
            log("Warning: <createmodulexml> with no modules listed", Project.MSG_WARN);
127
            log("Warning: <createmodulexml> with no modules listed", Project.MSG_WARN);
115
        }
128
        }
116
        for (FileSet fs : enabled) {
129
        for (FileSet fs : enabled) {
Lines 128-133 Link Here
128
        for (FileSet fs : hidden) {
141
        for (FileSet fs : hidden) {
129
            scanModules(fs, false, false, false, true, hiddenNames);
142
            scanModules(fs, false, false, false, true, hiddenNames);
130
        }
143
        }
144
        if (hiddenList != null && hiddenList.length() > 0)
145
            scanModulesInList(hiddenList, false, false, false, true, hiddenNames);
131
        Collections.sort(enabledNames);
146
        Collections.sort(enabledNames);
132
        Collections.sort(disabledNames);
147
        Collections.sort(disabledNames);
133
        Collections.sort(autoloadNames);
148
        Collections.sort(autoloadNames);
Lines 155-273 Link Here
155
        File dir = scan.getBasedir();
170
        File dir = scan.getBasedir();
156
        for (String kid : scan.getIncludedFiles()) {
171
        for (String kid : scan.getIncludedFiles()) {
157
            File module = new File(dir, kid);
172
            File module = new File(dir, kid);
158
            if (!module.exists()) throw new BuildException("Module file does not exist: " + module, getLocation());
173
            scanOneModule(module, kid, isEnabled, isAutoload, isEager, isHidden, names);
159
            if (!module.getName().endsWith(".jar")) throw new BuildException("Only *.jar may be listed, check the fileset: " + module, getLocation());
174
        }
175
    }
176
177
    private void scanModulesInList(String modulesList, boolean isEnabled, boolean isAutoload,
178
            boolean isEager, boolean isHidden, List<String> names) throws BuildException {
179
        String[] modules = modulesList.split(",");
180
        for (String modulePath : modules) {
181
            File module = new File(modulePath);
182
            scanOneModule(module, null, isEnabled, isAutoload, isEager, isHidden, names);
183
        }
184
    }
185
186
    private void scanOneModule(File module, String kid, boolean isEnabled,boolean isAutoload, boolean isEager, boolean isHidden, List<String> names) throws BuildException {
187
        if (!module.exists()) {
188
            throw new BuildException("Module file does not exist: " + module, getLocation());
189
        }
190
        if (!module.getName().endsWith(".jar")) {
191
            throw new BuildException("Only *.jar may be listed, check the fileset: " + module, getLocation());
192
        }
193
        try {
194
            JarFile jar = new JarFile(module);
160
            try {
195
            try {
161
                JarFile jar = new JarFile(module);
196
                Manifest m = jar.getManifest();
162
                try {
197
                Attributes attr = m.getMainAttributes();
163
                    Manifest m = jar.getManifest();
198
                String codename = attr.getValue("OpenIDE-Module");
164
                    Attributes attr = m.getMainAttributes();
199
                if (codename == null) {
165
                    String codename = attr.getValue("OpenIDE-Module");
200
                    throw new BuildException("Missing manifest tag OpenIDE-Module; " + module + " is not a module", getLocation());
166
                    if (codename == null) {
201
                }
167
                        throw new BuildException("Missing manifest tag OpenIDE-Module; " + module + " is not a module", getLocation());
202
                if (codename.endsWith(" ") || codename.endsWith("\t")) {
203
                    // #62887
204
                    throw new BuildException("Illegal trailing space in OpenIDE-Module value from " + module, getLocation());
205
                }
206
                int idx = codename.lastIndexOf('/');
207
                String codenamebase;
208
                int rel;
209
                if (idx == -1) {
210
                    codenamebase = codename;
211
                    rel = -1;
212
                } else {
213
                    codenamebase = codename.substring(0, idx);
214
                    try {
215
                        rel = Integer.parseInt(codename.substring(idx + 1));
216
                    } catch (NumberFormatException e) {
217
                        throw new BuildException("Invalid OpenIDE-Module '" + codename + "' in " + module, getLocation());
168
                    }
218
                    }
169
                    if (codename.endsWith(" ") || codename.endsWith("\t")) { // #62887
219
                }
170
                        throw new BuildException("Illegal trailing space in OpenIDE-Module value from " + module, getLocation());
220
                File xml = new File(xmldir, codenamebase.replace('.', '-') + ".xml");
171
                    }
221
                if (xml.exists()) {
172
                    int idx = codename.lastIndexOf('/');
222
                    // XXX should check that the old file actually matches what we would have written
173
                    String codenamebase;
223
                    log("Will not overwrite " + xml + "; skipping...", Project.MSG_VERBOSE);
174
                    int rel;
224
                    return;
175
                    if (idx == -1) {
225
                }
176
                        codenamebase = codename;
226
                String displayname = attr.getValue("OpenIDE-Module-Name");
177
                        rel = -1;
227
                if (displayname == null) {
178
                    } else {
228
                    String bundle = attr.getValue("OpenIDE-Module-Localizing-Bundle");
179
                        codenamebase = codename.substring(0, idx);
229
                    if (bundle != null) {
230
                        // Display name actually found in a bundle, not manifest.
231
                        ZipEntry entry = jar.getEntry(bundle);
232
                        InputStream is;
233
                        if (entry != null) {
234
                            is = jar.getInputStream(entry);
235
                        } else {
236
                            File moduleloc = new File(new File(module.getParentFile(), "locale"), module.getName());
237
                            if (!moduleloc.isFile()) {
238
                                throw new BuildException("Expecting localizing bundle: " + bundle + " in: " + module);
239
                            }
240
                            JarFile jarloc = new JarFile(moduleloc);
241
                            try {
242
                                ZipEntry entry2 = jarloc.getEntry(bundle);
243
                                if (entry2 == null) {
244
                                    throw new BuildException("Expecting localizing bundle: " + bundle + " in: " + module);
245
                                }
246
                                is = jarloc.getInputStream(entry2);
247
                            } finally {
248
                                jarloc.close();
249
                            }
250
                        }
180
                        try {
251
                        try {
181
                            rel = Integer.parseInt(codename.substring(idx + 1));
252
                            Properties p = new Properties();
182
                        } catch (NumberFormatException e) {
253
                            p.load(is);
183
                            throw new BuildException("Invalid OpenIDE-Module '" + codename + "' in " + module, getLocation());
254
                            displayname = p.getProperty("OpenIDE-Module-Name");
255
                        } finally {
256
                            is.close();
184
                        }
257
                        }
185
                    }
258
                    }
186
                    File xml = new File(xmldir, codenamebase.replace('.', '-') + ".xml");
259
                }
187
                    if (xml.exists()) {
260
                if (displayname == null) {
188
                        // XXX should check that the old file actually matches what we would have written
261
                    displayname = codename;
189
                        log("Will not overwrite " + xml + "; skipping...", Project.MSG_VERBOSE);
262
                }
190
                        continue;
263
                names.add(displayname);
264
                String spec = attr.getValue("OpenIDE-Module-Specification-Version");
265
                if (isHidden) {
266
                    File h = new File(xml.getParentFile(), xml.getName() + "_hidden");
267
                    h.createNewFile();
268
                }
269
                if (isEager || isAutoload || isEnabled) {
270
                    OutputStream os = new FileOutputStream(xml);
271
                    try {
272
                        PrintWriter pw = new PrintWriter(new OutputStreamWriter(os, "UTF-8"));
273
                        // Please make sure formatting matches what the IDE actually spits
274
                        // out; it could matter.
275
                        pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
276
                        pw.println("<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"");
277
                        pw.println("                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">");
278
                        pw.println("<module name=\"" + codenamebase + "\">");
279
                        pw.println("    <param name=\"autoload\">" + isAutoload + "</param>");
280
                        pw.println("    <param name=\"eager\">" + isEager + "</param>");
281
                        if (!isAutoload && !isEager) {
282
                            pw.println("    <param name=\"enabled\">" + isEnabled + "</param>");
283
                        }
284
                        pw.println("    <param name=\"jar\">" + kid.replace(File.separatorChar, '/') + "</param>");
285
                        if (rel != -1) {
286
                            pw.println("    <param name=\"release\">" + rel + "</param>");
287
                        }
288
                        pw.println("    <param name=\"reloadable\">false</param>");
289
                        if (spec != null) {
290
                            pw.println("    <param name=\"specversion\">" + spec + "</param>");
291
                        }
292
                        pw.println("</module>");
293
                        pw.flush();
294
                        pw.close();
295
                    } finally {
296
                        os.close();
191
                    }
297
                    }
192
                    String displayname = attr.getValue("OpenIDE-Module-Name");
193
                    if (displayname == null) {
194
                        String bundle = attr.getValue("OpenIDE-Module-Localizing-Bundle");
195
                        if (bundle != null) {
196
                            // Display name actually found in a bundle, not manifest.
197
                            ZipEntry entry = jar.getEntry(bundle);
198
                            InputStream is;
199
                            if (entry != null) {
200
                                is = jar.getInputStream(entry);
201
                            } else {
202
                                File moduleloc = new File(new File(module.getParentFile(), "locale"), module.getName());
203
                                if (! moduleloc.isFile()) {
204
                                    throw new BuildException("Expecting localizing bundle: " + bundle + " in: " + module);
205
                                }
206
                                JarFile jarloc = new JarFile(moduleloc);
207
                                try {
208
                                    ZipEntry entry2 = jarloc.getEntry(bundle);
209
                                    if (entry2 == null) {
210
                                        throw new BuildException("Expecting localizing bundle: " + bundle + " in: " + module);
211
                                    }
212
                                    is = jarloc.getInputStream(entry2);
213
                                } finally {
214
                                    jarloc.close();
215
                                }
216
                            }
217
                            try {
218
                                Properties p = new Properties();
219
                                p.load(is);
220
                                displayname = p.getProperty("OpenIDE-Module-Name");
221
                            } finally {
222
                                is.close();
223
                            }
224
                        }
225
                    }
226
                    if (displayname == null) displayname = codename;
227
                    names.add(displayname);
228
                    String spec = attr.getValue("OpenIDE-Module-Specification-Version");
229
                    
230
                    if (isHidden) {
231
                        File h = new File(xml.getParentFile(), xml.getName() + "_hidden");
232
                        h.createNewFile();
233
                    }
234
                    
235
                    if (isEager || isAutoload || isEnabled) {
236
                        OutputStream os = new FileOutputStream(xml);
237
                        try {
238
                            PrintWriter pw = new PrintWriter(new OutputStreamWriter(os, "UTF-8"));
239
                            // Please make sure formatting matches what the IDE actually spits
240
                            // out; it could matter.
241
                            pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
242
                            pw.println("<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"");
243
                            pw.println("                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">");
244
                            pw.println("<module name=\"" + codenamebase + "\">");
245
                            pw.println("    <param name=\"autoload\">" + isAutoload + "</param>");
246
                            pw.println("    <param name=\"eager\">" + isEager + "</param>");
247
                            if (!isAutoload && !isEager) {
248
                                pw.println("    <param name=\"enabled\">" + isEnabled + "</param>");
249
                            }
250
                            pw.println("    <param name=\"jar\">" + kid.replace(File.separatorChar, '/') + "</param>");
251
                            if (rel != -1) {
252
                                pw.println("    <param name=\"release\">" + rel + "</param>");
253
                            }
254
                            pw.println("    <param name=\"reloadable\">false</param>");
255
                            if (spec != null) {
256
                                pw.println("    <param name=\"specversion\">" + spec + "</param>");
257
                            }
258
                            pw.println("</module>");
259
                            pw.flush();
260
                            pw.close();
261
                        } finally {
262
                            os.close();
263
                        }
264
                    }
265
                } finally {
266
                    jar.close();
267
                }
298
                }
268
            } catch (IOException ioe) {
299
            } finally {
269
                throw new BuildException("Caught while processing " + module + ": " + ioe, ioe, getLocation());
300
                jar.close();
270
            }
301
            }
302
        } catch (IOException ioe) {
303
            throw new BuildException("Caught while processing " + module + ": " + ioe, ioe, getLocation());
271
        }
304
        }
272
    }
305
    }
273
    
306
    
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/ModuleListParser.java (-34 / +74 lines)
Lines 500-519 Link Here
500
    /**
500
    /**
501
     * Find all modules in a binary build, possibly from cache.
501
     * Find all modules in a binary build, possibly from cache.
502
     */
502
     */
503
    private static Map<String,Entry> scanBinaries(Project project, File build) throws IOException {
503
    private static Map<String,Entry> scanBinaries(Project project, File[] clusters) throws IOException {
504
        Map<String,Entry> entries = BINARY_SCAN_CACHE.get(build);
504
        Map<String,Entry> allEntries = new HashMap<String,Entry>();
505
        if (entries == null) {
505
506
            if (project != null) {
506
        for (File cluster : clusters) {
507
                project.log("Scanning for modules in " + build);
507
            Map<String, Entry> entries = BINARY_SCAN_CACHE.get(cluster);
508
            if (entries == null) {
509
                if (project != null) {
510
                    project.log("Scanning for modules in " + cluster);
511
                }
512
                entries = new HashMap<String, Entry>();
513
                doScanBinaries(cluster, entries);
514
                if (project != null) {
515
                    project.log("Found modules: " + entries.keySet(), Project.MSG_VERBOSE);
516
                }
517
                BINARY_SCAN_CACHE.put(cluster, entries);
508
            }
518
            }
509
            entries = new HashMap<String,Entry>();
519
            allEntries.putAll(entries);
510
            doScanBinaries(build, entries);
511
            if (project != null) {
512
                project.log("Found modules: " + entries.keySet(), Project.MSG_VERBOSE);
513
            }
514
            BINARY_SCAN_CACHE.put(build, entries);
515
        }
520
        }
516
        return entries;
521
        return allEntries;
517
    }
522
    }
518
    
523
    
519
    private static final String[] MODULE_DIRS = {
524
    private static final String[] MODULE_DIRS = {
Lines 528-541 Link Here
528
     * Checks modules/{,autoload/,eager/}*.jar as well as well-known core/*.jar and lib/boot.jar in each cluster.
533
     * Checks modules/{,autoload/,eager/}*.jar as well as well-known core/*.jar and lib/boot.jar in each cluster.
529
     * XXX would be slightly more precise to check config/Modules/*.xml rather than scan for module JARs.
534
     * XXX would be slightly more precise to check config/Modules/*.xml rather than scan for module JARs.
530
     */
535
     */
531
    private static void doScanBinaries(File build, Map<String,Entry> entries) throws IOException {
536
    private static void doScanBinaries(File cluster, Map<String,Entry> entries) throws IOException {
532
        File[] clusters = build.listFiles();
533
        if (clusters == null) {
534
            throw new IOException("Cannot examine dir " + build);
535
        }
536
        for (int i = 0; i < clusters.length; i++) {
537
            for (int j = 0; j < MODULE_DIRS.length; j++) {
537
            for (int j = 0; j < MODULE_DIRS.length; j++) {
538
                File dir = new File(clusters[i], MODULE_DIRS[j].replace('/', File.separatorChar));
538
                File dir = new File(cluster, MODULE_DIRS[j].replace('/', File.separatorChar));
539
                if (!dir.isDirectory()) {
539
                if (!dir.isDirectory()) {
540
                    continue;
540
                    continue;
541
                }
541
                }
Lines 577-583 Link Here
577
                        String moduleDependencies = attr.getValue("OpenIDE-Module-Module-Dependencies");
577
                        String moduleDependencies = attr.getValue("OpenIDE-Module-Module-Dependencies");
578
                        
578
                        
579
                        
579
                        
580
                        Entry entry = new Entry(codenamebase, m, exts,dir, null, null, clusters[i].getName(),
580
                        Entry entry = new Entry(codenamebase, m, exts,dir, null, null, cluster.getName(),
581
                                parseRuntimeDependencies(moduleDependencies), Collections.<String,String[]>emptyMap());
581
                                parseRuntimeDependencies(moduleDependencies), Collections.<String,String[]>emptyMap());
582
                        if (entries.containsKey(codenamebase)) {
582
                        if (entries.containsKey(codenamebase)) {
583
                            throw new IOException("Duplicated module " + codenamebase + ": found in " + entries.get(codenamebase) + " and " + entry);
583
                            throw new IOException("Duplicated module " + codenamebase + ": found in " + entries.get(codenamebase) + " and " + entry);
Lines 589-595 Link Here
589
                    }
589
                    }
590
                }
590
                }
591
            }
591
            }
592
        }
593
    }
592
    }
594
    
593
    
595
    private static Map<String,Entry> scanSuiteSources(Map<String,String> properties, Project project) throws IOException {
594
    private static Map<String,Entry> scanSuiteSources(Map<String,String> properties, Project project) throws IOException {
Lines 666-672 Link Here
666
     * Properties interpreted:
665
     * Properties interpreted:
667
     * <ol>
666
     * <ol>
668
     * <li> ${nb_all} - location of NB sources (used only for netbeans.org modules)
667
     * <li> ${nb_all} - location of NB sources (used only for netbeans.org modules)
669
     * <li> ${netbeans.dest.dir} - location of NB build
668
     * <li> ${netbeans.dest.dir} - location of NB build (used only for NB.org modules)
669
     * <li> ${cluster.path} - location of clusters to build against (used only for suite and standalone modules)
670
     * <li> ${basedir} - directory of the project initiating the scan (most significant for standalone modules)
670
     * <li> ${basedir} - directory of the project initiating the scan (most significant for standalone modules)
671
     * <li> ${suite.dir} - directory of the suite (used only for suite modules)
671
     * <li> ${suite.dir} - directory of the suite (used only for suite modules)
672
     * <li> ${nb.cluster.TOKEN} - list of module paths included in cluster TOKEN (comma-separated) (used only for netbeans.org modules)
672
     * <li> ${nb.cluster.TOKEN} - list of module paths included in cluster TOKEN (comma-separated) (used only for netbeans.org modules)
Lines 679-701 Link Here
679
     */
679
     */
680
    public ModuleListParser(Map<String,String> properties, int type, Project project) throws IOException {
680
    public ModuleListParser(Map<String,String> properties, int type, Project project) throws IOException {
681
        String nball = properties.get("nb_all");
681
        String nball = properties.get("nb_all");
682
        String buildS = properties.get("netbeans.dest.dir");
683
        File basedir = new File(properties.get("basedir"));
682
        File basedir = new File(properties.get("basedir"));
684
        if (buildS == null) {
683
        final FileUtils fu = FileUtils.getFileUtils();
685
            throw new IOException("No definition of netbeans.dest.dir in " + basedir);
684
686
        }
687
        // Resolve against basedir, and normalize ../ sequences and so on in case they are used.
688
        // Neither operation is likely to be needed, but just in case.
689
        File build = FileUtils.getFileUtils().normalize(FileUtils.getFileUtils().resolveFile(basedir, buildS).getAbsolutePath());
690
        if (!build.isDirectory()) {
691
            throw new IOException("No such netbeans.dest.dir: " + build);
692
        }
693
        if (type != ParseProjectXml.TYPE_NB_ORG) {
685
        if (type != ParseProjectXml.TYPE_NB_ORG) {
686
            // add extra clusters
687
            String suiteDirS = properties.get("suite.dir");
688
            boolean hasSuiteDir = suiteDirS != null && suiteDirS.length() > 0;
689
            String clusterPath = properties.get("cluster.path");
690
            File[] clusters = null;
691
692
            if (clusterPath != null) {
693
                String[] clustersS;
694
                if (hasSuiteDir) {
695
                    // resolve suite modules against fake suite project
696
                    Project fakeproj = new Project();
697
                    fakeproj.setBaseDir(new File(suiteDirS));
698
                    clustersS = Path.translatePath(fakeproj, clusterPath);
699
                } else {
700
                    clustersS = Path.translatePath(project, clusterPath);
701
                }
702
                clusters = new File[clustersS.length];
703
                if (clustersS != null && clustersS.length > 0) {
704
                    for (int j = 0; j < clustersS.length; j++) {
705
                        File cluster = new File(clustersS[j]);
706
                        if (! cluster.isDirectory()) {
707
                            throw new IOException("No such cluster " + cluster + " referred to from ${cluster.path}: " + clusterPath);
708
                        }
709
                        clusters[j] = cluster;
710
                    }
711
                }
712
            }
713
714
            if (clusters == null || clusters.length == 0)
715
                throw new IOException("Invalid ${cluster.path}: " + clusterPath);
716
694
            // External module.
717
            // External module.
695
            if (nball != null && project != null) {
718
            if (nball != null && project != null) {
696
                project.log("You must *not* declare <suite-component/> or <standalone/> for a netbeans.org module in " + basedir + "; fix project.xml to use the /2 schema", Project.MSG_WARN);
719
                project.log("You must *not* declare <suite-component/> or <standalone/> for a netbeans.org module in " + basedir + "; fix project.xml to use the /2 schema", Project.MSG_WARN);
697
            }
720
            }
698
            entries = scanBinaries(project, build);
721
            entries = scanBinaries(project, clusters);
699
            if (type == ParseProjectXml.TYPE_SUITE) {
722
            if (type == ParseProjectXml.TYPE_SUITE) {
700
                entries.putAll(scanSuiteSources(properties, project));
723
                entries.putAll(scanSuiteSources(properties, project));
701
            } else {
724
            } else {
Lines 705-716 Link Here
705
            }
728
            }
706
        } else {
729
        } else {
707
            // netbeans.org module.
730
            // netbeans.org module.
731
            String buildS = properties.get("netbeans.dest.dir");
732
            if (buildS == null) {
733
                throw new IOException("No definition of netbeans.dest.dir in " + basedir);
734
            }
735
            // Resolve against basedir, and normalize ../ sequences and so on in case they are used.
736
            // Neither operation is likely to be needed, but just in case.
737
            File build = fu.normalize(fu.resolveFile(basedir, buildS).getAbsolutePath());
738
            if (!build.isDirectory()) {
739
                throw new IOException("No such netbeans.dest.dir: " + build);
740
            }
741
742
            // expand clusters in build
743
            File[] clusters = build.listFiles();
744
            if (clusters == null) {
745
                throw new IOException("Cannot examine dir " + build);
746
            }
747
708
            if (nball == null) {
748
            if (nball == null) {
709
                throw new IOException("You must declare either <suite-component/> or <standalone/> for an external module in " + new File(properties.get("basedir")));
749
                throw new IOException("You must declare either <suite-component/> or <standalone/> for an external module in " + new File(properties.get("basedir")));
710
            }
750
            }
711
            if (!build.equals(new File(new File(nball, "nbbuild"), "netbeans"))) {
751
            if (!build.equals(new File(new File(nball, "nbbuild"), "netbeans"))) {
712
                // Potentially orphaned module to be built against specific binaries, plus perhaps other source deps.
752
                // Potentially orphaned module to be built against specific binaries, plus perhaps other source deps.
713
                entries = scanBinaries(project, build);
753
                entries = scanBinaries(project, clusters);
714
                // Add referenced module in case it does not appear otherwise.
754
                // Add referenced module in case it does not appear otherwise.
715
                Entry e = scanStandaloneSource(properties, project);
755
                Entry e = scanStandaloneSource(properties, project);
716
                if (e != null) {
756
                if (e != null) {
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/ParseProjectXml.java (-11 / +14 lines)
Lines 899-915 Link Here
899
        if (module == null) {
899
        if (module == null) {
900
            throw new BuildException("No dependent module " + cnb, getLocation());
900
            throw new BuildException("No dependent module " + cnb, getLocation());
901
        }
901
        }
902
        String cluster = module.getClusterName();
902
//  XXX - no more included/excluded clusters
903
        if (cluster != null) { // #68716
903
//        String cluster = module.getClusterName();   // TODO - abs. path in clusterName, get rid of netbeans.dest.dir altogether
904
            if ((includedClusters != null && !includedClusters.isEmpty() && ! ModuleSelector.clusterMatch(includedClusters, cluster)) ||
904
//        if (cluster != null) { // #68716
905
                    ((includedClusters == null || includedClusters.isEmpty()) && excludedClusters != null && excludedClusters.contains(cluster))) {
905
//            if ((includedClusters != null && !includedClusters.isEmpty() && ! ModuleSelector.clusterMatch(includedClusters, cluster)) ||
906
                throw new BuildException("The module " + cnb + " cannot be compiled against because it is part of the cluster " + cluster +
906
//                    ((includedClusters == null || includedClusters.isEmpty()) && excludedClusters != null && excludedClusters.contains(cluster))) {
907
                                         " which has been excluded from the target platform in your suite configuration", getLocation());
907
//                throw new BuildException("The module " + cnb + " cannot be compiled against because it is part of the cluster " + cluster +
908
            }
908
//                                         " which has been excluded from the target platform in your suite configuration", getLocation());
909
            if (excludedModules != null && excludedModules.contains(cnb)) { // again #68716
909
//            }
910
                throw new BuildException("Module " + cnb + " excluded from the target platform", getLocation());
910
//            if (excludedModules != null && excludedModules.contains(cnb)) { // again #68716
911
            }
911
//                throw new BuildException("Module " + cnb + " excluded from the target platform", getLocation());
912
        }
912
//            }
913
//        }
913
        return module.getJar();
914
        return module.getJar();
914
    }
915
    }
915
 
916
 
Lines 966-971 Link Here
966
                // no cluster name is specified for standalone or module in module suite
967
                // no cluster name is specified for standalone or module in module suite
967
                cluster = "cluster";
968
                cluster = "cluster";
968
            }
969
            }
970
            // TODO - path probably composed wrongly with respect to cluster.path
969
            return ParseProjectXml.cachedTestDistLocation + sep + testtype + sep + cluster + sep + cnb.replace('.','-');
971
            return ParseProjectXml.cachedTestDistLocation + sep + testtype + sep + cluster + sep + cnb.replace('.','-');
970
        }
972
        }
971
973
Lines 1176-1181 Link Here
1176
        if (cluster == null) {
1178
        if (cluster == null) {
1177
            cluster = "cluster";
1179
            cluster = "cluster";
1178
        }
1180
        }
1181
        // TODO - path probably composed wrongly with respect to cluster.path
1179
        return ParseProjectXml.cachedTestDistLocation + sep + testType + sep + cluster + sep + entry.getCnb().replace('.', '-') + sep + "tests.jar";
1182
        return ParseProjectXml.cachedTestDistLocation + sep + testType + sep + cluster + sep + entry.getCnb().replace('.', '-') + sep + "tests.jar";
1180
    }
1183
    }
1181
1184
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/PathFileSet.java (+262 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.nbbuild;
41
42
import java.io.File;
43
import java.util.ArrayList;
44
import java.util.Enumeration;
45
import java.util.List;
46
import org.apache.tools.ant.BuildException;
47
import org.apache.tools.ant.DirectoryScanner;
48
import org.apache.tools.ant.Project;
49
import org.apache.tools.ant.Task;
50
import org.apache.tools.ant.types.Path;
51
import org.apache.tools.ant.types.selectors.AbstractSelectorContainer;
52
import org.apache.tools.ant.types.selectors.AndSelector;
53
import org.apache.tools.ant.types.selectors.ContainsRegexpSelector;
54
import org.apache.tools.ant.types.selectors.ContainsSelector;
55
import org.apache.tools.ant.types.selectors.DateSelector;
56
import org.apache.tools.ant.types.selectors.DependSelector;
57
import org.apache.tools.ant.types.selectors.DepthSelector;
58
import org.apache.tools.ant.types.selectors.DifferentSelector;
59
import org.apache.tools.ant.types.selectors.ExtendSelector;
60
import org.apache.tools.ant.types.selectors.FileSelector;
61
import org.apache.tools.ant.types.selectors.FilenameSelector;
62
import org.apache.tools.ant.types.selectors.MajoritySelector;
63
import org.apache.tools.ant.types.selectors.NoneSelector;
64
import org.apache.tools.ant.types.selectors.NotSelector;
65
import org.apache.tools.ant.types.selectors.OrSelector;
66
import org.apache.tools.ant.types.selectors.PresentSelector;
67
import org.apache.tools.ant.types.selectors.SelectSelector;
68
import org.apache.tools.ant.types.selectors.SelectorContainer;
69
import org.apache.tools.ant.types.selectors.SizeSelector;
70
import org.apache.tools.ant.types.selectors.TypeSelector;
71
import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector;
72
73
/**
74
 * Does the same as ant's fileset, only for given path instead of single basedir.
75
 * Files in set are returned as absolute paths.
76
 *
77
 * @author Richard Michalsky
78
 */
79
public class PathFileSet extends Task implements SelectorContainer {
80
    private Path clusterPath;
81
    private String property;
82
//    private String excludedModules;
83
    private String pathsep = File.pathSeparator;
84
    private String include;
85
    private AbstractSelectorContainer selectors = new AbstractSelectorContainer() {};
86
87
    public PathFileSet() {
88
89
    }
90
91
    /**
92
     * Returned fileset is stored in property specified with 'property' attribute.
93
     * @param property
94
     */
95
    public void setProperty(String property) {
96
        this.property = property;
97
    }
98
99
//    public void setExcludedModules(String excludedModules) {
100
//        this.excludedModules = excludedModules;
101
//    }
102
103
    /**
104
     * Separator of entries in fileset. Defaults to path separator.
105
     * @param pathsep
106
     */
107
    public void setPathsep(String pathsep) {
108
        this.pathsep = pathsep;
109
    }
110
111
    /**
112
     * Optional include pattern for filtering files. The same as fileset's nested &gt;include&lt; tag.
113
     * @param include
114
     */
115
    public void setInclude(String include) {
116
        this.include = include;
117
    }
118
119
    private List<Path> paths = new ArrayList<Path>();
120
121
    /**
122
     * Elements of nested paths are used as basedirs for fileset.
123
     * @param clusterPath
124
     */
125
    public void addPath(Path clusterPath) {
126
        paths.add(clusterPath);
127
    }
128
129
    @Override
130
    public void execute() throws BuildException {
131
        try {
132
            log("Scanning " + paths.size() + " paths.", Project.MSG_VERBOSE);
133
            DirectoryScanner scanner = new DirectoryScanner();
134
            if (paths.size() == 0)
135
                throw new BuildException("No path specified");
136
            if (property == null)
137
                throw new BuildException("No output property specified.");
138
139
            StringBuilder sb = new StringBuilder();
140
141
            for (Path path : paths) {
142
                String[] includedClusters = path.list();
143
                for (String clusterName : includedClusters) {
144
                    scanner.setBasedir(clusterName);
145
                    scanner.setSelectors(selectors.getSelectors(getProject()));
146
                    if (include != null)
147
                        scanner.setIncludes(new String[] { include });
148
                    scanner.scan();
149
150
                    log("Scanned pathelement '" + clusterName + "', "
151
                        + scanner.getIncludedFilesCount() + " files found.", Project.MSG_VERBOSE);
152
                    for (String relFile: scanner.getIncludedFiles()) {
153
                        if (sb.length() > 0)
154
                            sb.append(pathsep);
155
                        sb.append(new File(clusterName, relFile).getPath());
156
                    }
157
                }
158
            }
159
            getProject().setNewProperty(property, sb.toString());
160
            log("Set property " + property + " = " + sb.toString(), Project.MSG_VERBOSE);
161
        } catch (Exception ex) {
162
            throw new BuildException(ex);
163
        }
164
    }
165
166
    public Enumeration selectorElements() {
167
        return selectors.selectorElements();
168
    }
169
170
    public int selectorCount() {
171
        return selectors.selectorCount();
172
    }
173
174
    public boolean hasSelectors() {
175
        return selectors.hasSelectors();
176
    }
177
178
    public FileSelector[] getSelectors(Project p) {
179
        return selectors.getSelectors(p);
180
    }
181
182
    public void appendSelector(FileSelector selector) {
183
        selectors.appendSelector(selector);
184
    }
185
186
    public void addType(TypeSelector selector) {
187
        selectors.addType(selector);
188
    }
189
190
    public void addSize(SizeSelector selector) {
191
        selectors.addSize(selector);
192
    }
193
194
    public void addSelector(SelectSelector selector) {
195
        selectors.addSelector(selector);
196
    }
197
198
    public void addPresent(PresentSelector selector) {
199
        selectors.addPresent(selector);
200
    }
201
202
    public void addOr(OrSelector selector) {
203
        selectors.addOr(selector);
204
    }
205
206
    public void addNot(NotSelector selector) {
207
        selectors.addNot(selector);
208
    }
209
210
    public void addNone(NoneSelector selector) {
211
        selectors.addNone(selector);
212
    }
213
214
    public void addModified(ModifiedSelector selector) {
215
        selectors.addModified(selector);
216
    }
217
218
    public void addMajority(MajoritySelector selector) {
219
        selectors.addMajority(selector);
220
    }
221
222
    public void addFilename(FilenameSelector selector) {
223
        selectors.addFilename(selector);
224
    }
225
226
    public void addDifferent(DifferentSelector selector) {
227
        selectors.addDifferent(selector);
228
    }
229
230
    public void addDepth(DepthSelector selector) {
231
        selectors.addDepth(selector);
232
    }
233
234
    public void addDepend(DependSelector selector) {
235
        selectors.addDepend(selector);
236
    }
237
238
    public void addDate(DateSelector selector) {
239
        selectors.addDate(selector);
240
    }
241
242
    public void addCustom(ExtendSelector selector) {
243
        selectors.addCustom(selector);
244
    }
245
246
    public void addContainsRegexp(ContainsRegexpSelector selector) {
247
        selectors.addContainsRegexp(selector);
248
    }
249
250
    public void addContains(ContainsSelector selector) {
251
        selectors.addContains(selector);
252
    }
253
254
    public void addAnd(AndSelector selector) {
255
        selectors.addAnd(selector);
256
    }
257
258
    public void add(FileSelector selector) {
259
        selectors.add(selector);
260
    }
261
262
}
(-)a/nbbuild/templates/common.xml (-1 / +4 lines)
Lines 324-329 Link Here
324
        <mkdir dir="build"/>
324
        <mkdir dir="build"/>
325
        <property name="nbm.target.cluster" value=""/> <!-- fallback -->
325
        <property name="nbm.target.cluster" value=""/> <!-- fallback -->
326
        <property name="license.file.override" value="${license.file}"/>
326
        <property name="license.file.override" value="${license.file}"/>
327
        <pathfileset property="updater.jar.path" include="modules/ext/updater.jar">
328
            <path path="${cluster.path}"/>
329
        </pathfileset>
327
        <makenbm file="build/${nbm}"
330
        <makenbm file="build/${nbm}"
328
                 productdir="${cluster}"
331
                 productdir="${cluster}"
329
                 module="${module.jar}"
332
                 module="${module.jar}"
Lines 337-343 Link Here
337
            <license file="${license.file.override}"/>
340
            <license file="${license.file.override}"/>
338
            <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
341
            <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
339
            <updaterjar>
342
            <updaterjar>
340
                <fileset dir="${netbeans.dest.dir}" includes="platform*/modules/ext/updater.jar"/>
343
                <path location="${updater.jar.path}"/>
341
            </updaterjar>
344
            </updaterjar>
342
        </makenbm>
345
        </makenbm>
343
    </target>
346
    </target>
(-)a/nbbuild/test/unit/src/org/netbeans/nbbuild/PathFileSetTest.java (+233 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.nbbuild;
41
42
import java.io.File;
43
import java.io.IOException;
44
import java.util.ArrayList;
45
import java.util.Arrays;
46
import java.util.StringTokenizer;
47
import org.apache.tools.ant.BuildEvent;
48
import org.apache.tools.ant.BuildException;
49
import org.apache.tools.ant.BuildListener;
50
import org.apache.tools.ant.DirectoryScanner;
51
import org.apache.tools.ant.Project;
52
import org.apache.tools.ant.types.Path;
53
import org.apache.tools.ant.types.selectors.FilenameSelector;
54
import org.junit.AfterClass;
55
import org.junit.BeforeClass;
56
import org.junit.Test;
57
import org.netbeans.junit.NbTestCase;
58
import static org.junit.Assert.*;
59
60
/**
61
 *
62
 * @author Richard Michalsky
63
 */
64
public class PathFileSetTest extends NbTestCase {
65
66
    private PathFileSet task;
67
    private Project fakeproj;
68
    private ClusterRecord cl1;
69
    private ClusterRecord cl2;
70
71
    public PathFileSetTest(String testName) {
72
        super(testName);
73
    }
74
75
    @BeforeClass
76
    public static void setUpClass() throws Exception {
77
    }
78
79
    @AfterClass
80
    public static void tearDownClass() throws Exception {
81
    }
82
83
//    @Before
84
    @Override
85
    protected void setUp() throws IOException {
86
        clearWorkDir();
87
        task = new PathFileSet();
88
        fakeproj = new Project();
89
        fakeproj.setBaseDir(getWorkDir());
90
        fakeproj.addBuildListener(new BuildListener() {
91
92
            public void messageLogged(BuildEvent buildEvent) {
93
                if (buildEvent.getPriority() <= Project.MSG_VERBOSE) {
94
                    System.err.println(buildEvent.getMessage());
95
                }
96
            }
97
98
            public void taskStarted(BuildEvent buildEvent) {
99
            }
100
101
            public void taskFinished(BuildEvent buildEvent) {
102
            }
103
104
            public void targetStarted(BuildEvent buildEvent) {
105
            }
106
107
            public void targetFinished(BuildEvent buildEvent) {
108
            }
109
110
            public void buildStarted(BuildEvent buildEvent) {
111
            }
112
113
            public void buildFinished(BuildEvent buildEvent) {
114
            }
115
        });
116
        task.setProject(fakeproj);
117
        cl1 = new ClusterRecord("cl1").create().addModule("org-m1", true, true, true);
118
        cl2 = new ClusterRecord("cl2").create().addModule("org-m2", true, false, false);
119
        task.addPath(new Path(fakeproj, "cl1" + File.pathSeparator + "cl2"));
120
    }
121
122
//    @After
123
    protected void tearDown() {
124
    }
125
126
    private void executeAndCheckResults(String[] expected) throws BuildException, IOException {
127
        task.setProperty("output");
128
        task.execute();
129
        String[] output = fakeproj.getProperty("output").replace('\\', '/').split(File.pathSeparator);
130
        Arrays.sort(output);
131
        String wd = getWorkDir().getPath().replace('\\', '/').concat("/");
132
        for (int i = 0; i < expected.length; i++) {
133
            expected[i] = wd + expected[i];
134
        }
135
        assertArrayEquals(expected, output);
136
    }
137
138
    private class ClusterRecord {
139
140
        File ut;
141
        File cm;
142
        File m;
143
        private String clusterName;
144
145
        public ClusterRecord(String clusterName) {
146
            this.clusterName = clusterName;
147
        }
148
149
        public ClusterRecord create() throws IOException {
150
            ut = new File(getWorkDir(), clusterName + "/update_tracking");
151
            ut.mkdirs();
152
            assertTrue(ut.isDirectory());
153
154
            cm = new File(getWorkDir(), clusterName + "/config/Modules");
155
            cm.mkdirs();
156
            assertTrue(cm.isDirectory());
157
158
            m = new File(getWorkDir(), clusterName + "/modules");
159
            m.mkdirs();
160
            assertTrue(m.isDirectory());
161
            return this;
162
        }
163
164
        public ClusterRecord addModule(String dashedCNB, boolean jar, boolean config, boolean updateTracking) throws IOException {
165
            if (updateTracking) {
166
                assertTrue(new File(ut, dashedCNB + ".xml").createNewFile());
167
            }
168
            if (jar) {
169
                assertTrue(new File(m, dashedCNB + ".jar").createNewFile());
170
            }
171
            if (config) {
172
                assertTrue(new File(cm, dashedCNB + ".xml").createNewFile());
173
            }
174
            return this;
175
        }
176
    }
177
178
    @Test
179
    public void testFindAllFiles() throws IOException {
180
        executeAndCheckResults(new String[]{"cl1/config/Modules/org-m1.xml",
181
                    "cl1/modules/org-m1.jar",
182
                    "cl1/update_tracking/org-m1.xml",
183
                    "cl2/modules/org-m2.jar"});
184
    }
185
186
    @Test
187
    public void testSeparator() throws IOException {
188
        task.setPathsep(",");
189
        String[] expected = new String[]{"cl1/config/Modules/org-m1.xml",
190
            "cl1/modules/org-m1.jar",
191
            "cl1/update_tracking/org-m1.xml",
192
            "cl2/modules/org-m2.jar"};
193
        task.setProperty("output");
194
        task.execute();
195
        String[] output = fakeproj.getProperty("output").replace('\\', '/').split(",");
196
        Arrays.sort(output);
197
        String wd = getWorkDir().getPath().replace('\\', '/').concat("/");
198
        for (int i = 0; i < expected.length; i++) {
199
            expected[i] = wd + expected[i];
200
        }
201
        assertArrayEquals(expected, output);
202
    }
203
204
    @Test
205
    public void testWildcardIncludes() throws IOException {
206
        task.setInclude("**/*.jar");
207
        executeAndCheckResults(new String[]{"cl1/modules/org-m1.jar", "cl2/modules/org-m2.jar"});
208
    }
209
210
    @Test
211
    public void testSimpleIncludes() throws IOException {
212
        task.setInclude("modules/org-m1.jar");
213
        executeAndCheckResults(new String[]{"cl1/modules/org-m1.jar"});
214
    }
215
216
    @Test
217
    public void testEmptySet() throws IOException {
218
        task.setProperty("output");
219
        task.setInclude("pattern not present");
220
        task.execute();
221
        String output = fakeproj.getProperty("output");
222
        assertEquals(0, output.length());
223
    }
224
225
    @Test
226
    public void testFileNameSelector() throws IOException {
227
        FilenameSelector sel = new FilenameSelector();
228
        sel.setCasesensitive(false);
229
        sel.setName("**/config/**/*.xml");
230
        task.add(sel);
231
        executeAndCheckResults(new String[]{"cl1/config/Modules/org-m1.xml"});
232
    }
233
}

Return to bug 152960