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

(-)antsrc/org/netbeans/nbbuild/FixTestDependencies.java (-98 / +113 lines)
Lines 75-179 Link Here
75
                prjFis.close();
75
                prjFis.close();
76
            }
76
            }
77
            String xml = new String(xmlBytes);
77
            String xml = new String(xmlBytes);
78
            int projectType = ParseProjectXml.TYPE_NB_ORG;
78
            String oldXsd = "<data xmlns=\"http://www.netbeans.org/ns/nb-module-project/2";
79
            if (xml.contains("<suite-component/>")) {
79
            int xsdIndex = xml.indexOf(oldXsd);
80
                projectType = ParseProjectXml.TYPE_SUITE;
80
            if (xsdIndex != -1) {
81
            } else if (xml.contains("<standalone/>")) {
81
                // increase schema version
82
                projectType = ParseProjectXml.TYPE_NB_ORG;
82
                String part1 = xml.substring(0,xsdIndex + oldXsd.length() - 1);
83
            } 
83
                String part2 = xml.substring(xsdIndex + oldXsd.length(), xml.length());
84
            //grrr
84
                xml = part1 + "3" + part2;
85
            int typeStart = xml.indexOf("<code-name-base>");
85
                
86
            int typeEnd = xml.indexOf("</code-name-base>");
86
                int projectType = ParseProjectXml.TYPE_NB_ORG;
87
            if (typeStart <= 0 || typeEnd <= 0 || typeEnd <= typeStart) {
87
                if (xml.contains("<suite-component/>")) {
88
                throw new BuildException("Parsing of project.xml failed.");
88
                    projectType = ParseProjectXml.TYPE_SUITE;
89
                } else if (xml.contains("<standalone/>")) {
90
                    projectType = ParseProjectXml.TYPE_NB_ORG;
91
                } 
92
                //grrr
93
                int typeStart = xml.indexOf("<code-name-base>");
94
                int typeEnd = xml.indexOf("</code-name-base>");
95
                if (typeStart <= 0 || typeEnd <= 0 || typeEnd <= typeStart) {
96
                    throw new BuildException("Parsing of project.xml failed.");
97
                }
98
                cnb = xml.substring(typeStart + "<code-name-base>".length(), typeEnd).trim();
99
                if (cnb.length() <= 0) {
100
                    throw new BuildException("Invalid codename base:" + cnb);
101
                }
102
                // test if project.xml contains test-deps
103
                if (xml.contains("<test-dependencies>")) {
104
                    // yes -> exit
105
                    log("<test-dependencies> already exists.");
106
                    log("update only schema version");
107
                    PrintStream ps = new PrintStream(projectXmlFile);
108
                    ps.print(xml);
109
                    ps.close();                  
110
                    return ;
111
                }
112
                // no :
113
                // scan for all modules
114
                ModuleListParser listParser;
115
                listParser = new ModuleListParser(getProject().getProperties(), projectType, getProject());
116
                Set/*<ModuleListParser.Entry>*/ entries =  listParser.findAll();
117
                Set/*<String>*/ allCnbs = getCNBsFromEntries(entries);
118
                // read properties
119
120
                // remove modules and test from properties and put it to project.xml
121
122
                // unittest
123
                //
124
                Set/*<String>*/ compileCNB = new HashSet();
125
                Set/*<String>*/ compileTestCNB = new HashSet();
126
                Set/*<String>*/ runtimeCNB = new HashSet();
127
                Set/*<String>*/ runtimeTestCNB = new HashSet();
128
129
                Properties projectProperties = getTestProperties();
130
                readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.unit.cp",allCnbs,entries);
131
                readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.unit.cp.extra",allCnbs,entries);
132
133
                readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.unit.run.cp",allCnbs,entries);
134
                readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.unit.run.cp.extra",allCnbs,entries);
135
136
                updateProperties(projectProperties,new String[]{"test.unit.cp","test.unit.cp.extra","test.unit.run.cp","test.unit.run.cp.extra"});
137
138
                StringBuffer buffer = new StringBuffer();
139
                buffer.append("\n          <test-dependencies>\n");
140
                buffer.append("              <test-type>\n");
141
                buffer.append("                  <name>unit</name>\n");
142
                addDependency(buffer,cnb,true,true,false);
143
144
                runtimeCNB.removeAll(compileCNB);
145
                //compileCNB.removeAll(runtimeCNB);
146
                compileCNB.addAll(compileTestCNB);
147
                runtimeTestCNB.removeAll(compileTestCNB);
148
                runtimeCNB.addAll(runtimeTestCNB);
149
                addDependencies(buffer,compileCNB,compileTestCNB,true,false);
150
                addDependencies(buffer,runtimeCNB,runtimeTestCNB,false,false);
151
                buffer.append("              </test-type>\n");
152
153
                // qa functional tests
154
                compileCNB.clear();
155
                runtimeCNB.clear();
156
                compileTestCNB.clear();
157
                runtimeTestCNB.clear();
158
159
                buffer.append("              <test-type>\n");
160
                buffer.append("                  <name>qa-functional</name>\n");
161
162
                readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.qa-functional.cp",allCnbs,entries);
163
                readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.qa-functional.cp.extra",allCnbs,entries);
164
165
                readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.qa-functional.runtime.cp",allCnbs,entries);
166
                readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.qa-functional.runtime.extra",allCnbs,entries);
167
168
                addDependencies(buffer,compileCNB,compileTestCNB,true,false);
169
                addDependencies(buffer,runtimeCNB,runtimeTestCNB,false,false);
170
                buffer.append("              </test-type>\n");
171
                buffer.append("            </test-dependencies>\n");
172
                updateProperties(projectProperties,new String[]{"test.qa-functional.cp","test.qa-functional.cp","test.qa-functional.runtime.cp","test.qa-functional.runtime.extra"});
173
174
                // merge project properties
175
                String MODULE_DEP_END = "</module-dependencies>";
176
                int moduleDepEnd = xml.indexOf(MODULE_DEP_END);
177
                if (moduleDepEnd == -1) {
178
                    throw new BuildException("No module dependency found.");
179
                }
180
                moduleDepEnd += MODULE_DEP_END.length();
181
                StringBuffer resultXml = new StringBuffer();
182
                resultXml.append(xml.substring(0,moduleDepEnd));
183
                resultXml.append(buffer);
184
                resultXml.append(xml.substring(moduleDepEnd + 1, xml.length()));
185
186
               PrintStream ps = new PrintStream(projectXmlFile);
187
               ps.print(resultXml);
188
               ps.close();
89
            }
189
            }
90
            cnb = xml.substring(typeStart + "<code-name-base>".length(), typeEnd).trim();
91
            if (cnb.length() <= 0) {
92
                throw new BuildException("Invalid codename base:" + cnb);
93
            }
94
            // test if project.xml contains test-deps
95
            if (xml.contains("<test-dependencies>")) {
96
                // yes -> exit
97
                log("<test-dependencies> already exists.");
98
                return ;
99
            }
100
            // no :
101
            // scan for all modules
102
            ModuleListParser listParser;
103
            listParser = new ModuleListParser(getProject().getProperties(), projectType, getProject());
104
            Set/*<ModuleListParser.Entry>*/ entries =  listParser.findAll();
105
            Set/*<String>*/ allCnbs = getCNBsFromEntries(entries);
106
            // read properties
107
            
108
            // remove modules and test from properties and put it to project.xml
109
            
110
            // unittest
111
            //
112
            Set/*<String>*/ compileCNB = new HashSet();
113
            Set/*<String>*/ compileTestCNB = new HashSet();
114
            Set/*<String>*/ runtimeCNB = new HashSet();
115
            Set/*<String>*/ runtimeTestCNB = new HashSet();
116
            
117
            Properties projectProperties = getTestProperties();
118
            readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.unit.cp",allCnbs,entries);
119
            readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.unit.cp.extra",allCnbs,entries);
120
            
121
            readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.unit.run.cp",allCnbs,entries);
122
            readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.unit.run.cp.extra",allCnbs,entries);
123
            
124
            updateProperties(projectProperties,new String[]{"test.unit.cp","test.unit.cp.extra","test.unit.run.cp","test.unit.run.cp.extra"});
125
            
126
            StringBuffer buffer = new StringBuffer();
127
            buffer.append("\n          <test-dependencies>\n");
128
            buffer.append("              <test-type>\n");
129
            buffer.append("                  <name>unit</name>\n");
130
            addDependency(buffer,cnb,true,true,false);
131
            
132
            runtimeCNB.removeAll(compileCNB);
133
            //compileCNB.removeAll(runtimeCNB);
134
            compileCNB.addAll(compileTestCNB);
135
            runtimeTestCNB.removeAll(compileTestCNB);
136
            runtimeCNB.addAll(runtimeTestCNB);
137
            addDependencies(buffer,compileCNB,compileTestCNB,true,false);
138
            addDependencies(buffer,runtimeCNB,runtimeTestCNB,false,false);
139
            buffer.append("              </test-type>\n");
140
            
141
            // qa functional tests
142
            compileCNB.clear();
143
            runtimeCNB.clear();
144
            compileTestCNB.clear();
145
            runtimeTestCNB.clear();
146
            
147
            buffer.append("              <test-type>\n");
148
            buffer.append("                  <name>qa-functional</name>\n");
149
            
150
            readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.qa-functional.cp",allCnbs,entries);
151
            readCodeNameBases(compileCNB,compileTestCNB,projectProperties,"test.qa-functional.cp.extra",allCnbs,entries);
152
            
153
            readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.qa-functional.runtime.cp",allCnbs,entries);
154
            readCodeNameBases(runtimeCNB,runtimeTestCNB,projectProperties,"test.qa-functional.runtime.extra",allCnbs,entries);
155
            
156
            addDependencies(buffer,compileCNB,compileTestCNB,true,false);
157
            addDependencies(buffer,runtimeCNB,runtimeTestCNB,false,false);
158
            buffer.append("              </test-type>\n");
159
            buffer.append("            </test-dependencies>\n");
160
            updateProperties(projectProperties,new String[]{"test.qa-functional.cp","test.qa-functional.cp","test.qa-functional.runtime.cp","test.qa-functional.runtime.extra"});
161
            
162
            // merge project properties
163
            String MODULE_DEP_END = "</module-dependencies>";
164
            int moduleDepEnd = xml.indexOf(MODULE_DEP_END);
165
            if (moduleDepEnd == -1) {
166
                throw new BuildException("No module dependency found.");
167
            }
168
            moduleDepEnd += MODULE_DEP_END.length();
169
            StringBuffer resultXml = new StringBuffer();
170
            resultXml.append(xml.substring(0,moduleDepEnd));
171
            resultXml.append(buffer);
172
            resultXml.append(xml.substring(moduleDepEnd + 1, xml.length()));
173
            
174
           PrintStream ps = new PrintStream(projectXmlFile);
175
           ps.print(resultXml);
176
           ps.close();
177
            
190
            
178
        } catch (IOException ex) {
191
        } catch (IOException ex) {
179
            throw new BuildException(ex);
192
            throw new BuildException(ex);
Lines 236-241 Link Here
236
                        if (newProp.length() > 0) {
249
                        if (newProp.length() > 0) {
237
                            newProp.append(":");
250
                            newProp.append(":");
238
                        }
251
                        }
252
                        // windows platform
253
                        token = token.replace(File.separatorChar,'/');
239
                        newProp.append(token);
254
                        newProp.append(token);
240
                    }
255
                    }
241
                }
256
                }
(-)antsrc/org/netbeans/nbbuild/ModuleListParser.java (-8 / +8 lines)
Lines 179-192 Link Here
179
            return false;
179
            return false;
180
        }
180
        }
181
        Element configEl = XMLUtil.findElement(doc.getDocumentElement(), "configuration", ParseProjectXml.PROJECT_NS);
181
        Element configEl = XMLUtil.findElement(doc.getDocumentElement(), "configuration", ParseProjectXml.PROJECT_NS);
182
        Element dataEl = XMLUtil.findElement(configEl, "data", ParseProjectXml.NBM_NS);
182
        Element dataEl = ParseProjectXml.findNBMElement(configEl, "data");
183
        if (dataEl == null) {
183
        if (dataEl == null) {
184
            if (project != null) {
184
            if (project != null) {
185
                project.log(projectxml.toString() + ": warning: module claims to be a NBM project but is missing <data xmlns=\"" + ParseProjectXml.NBM_NS + "\">; maybe an old NB 4.[01] project?", Project.MSG_WARN);
185
                project.log(projectxml.toString() + ": warning: module claims to be a NBM project but is missing <data xmlns=\"" + ParseProjectXml.NBM_NS3 + "\">; maybe an old NB 4.[01] project?", Project.MSG_WARN);
186
            }
186
            }
187
            return false;
187
            return false;
188
        }
188
        }
189
        Element cnbEl = XMLUtil.findElement(dataEl, "code-name-base", ParseProjectXml.NBM_NS);
189
        Element cnbEl = ParseProjectXml.findNBMElement(dataEl, "code-name-base");
190
        String cnb = XMLUtil.findText(cnbEl);
190
        String cnb = XMLUtil.findText(cnbEl);
191
        // Clumsy but the best way I know of to evaluate properties.
191
        // Clumsy but the best way I know of to evaluate properties.
192
        Project fakeproj = new Project();
192
        Project fakeproj = new Project();
Lines 294-300 Link Here
294
            if (!ext.getLocalName().equals("class-path-extension")) {
294
            if (!ext.getLocalName().equals("class-path-extension")) {
295
                continue;
295
                continue;
296
            }
296
            }
297
            Element binaryOrigin = XMLUtil.findElement(ext, "binary-origin", ParseProjectXml.NBM_NS);
297
            Element binaryOrigin = ParseProjectXml.findNBMElement(ext, "binary-origin");
298
            File origBin = null;
298
            File origBin = null;
299
            if (binaryOrigin != null) {
299
            if (binaryOrigin != null) {
300
                String reltext = XMLUtil.findText(binaryOrigin);
300
                String reltext = XMLUtil.findText(binaryOrigin);
Lines 310-316 Link Here
310
310
311
            File resultBin = null;
311
            File resultBin = null;
312
            if (origBin == null || !origBin.exists()) {
312
            if (origBin == null || !origBin.exists()) {
313
                Element runtimeRelativePath = XMLUtil.findElement(ext, "runtime-relative-path", ParseProjectXml.NBM_NS);
313
                Element runtimeRelativePath = ParseProjectXml.findNBMElement(ext, "runtime-relative-path");
314
                if (runtimeRelativePath == null) {
314
                if (runtimeRelativePath == null) {
315
                    throw new IOException("Have malformed <class-path-extension> in " + projectxml);
315
                    throw new IOException("Have malformed <class-path-extension> in " + projectxml);
316
                }
316
                }
Lines 329-348 Link Here
329
        }
329
        }
330
        List/*<String>*/ prereqs = new ArrayList();
330
        List/*<String>*/ prereqs = new ArrayList();
331
        List/*<String>*/ rundeps = new ArrayList();
331
        List/*<String>*/ rundeps = new ArrayList();
332
        Element depsEl = XMLUtil.findElement(dataEl, "module-dependencies", ParseProjectXml.NBM_NS);
332
        Element depsEl = ParseProjectXml.findNBMElement(dataEl, "module-dependencies");
333
        if (depsEl == null) {
333
        if (depsEl == null) {
334
            throw new IOException("Malformed project file " + projectxml);
334
            throw new IOException("Malformed project file " + projectxml);
335
        }
335
        }
336
        Iterator deps = XMLUtil.findSubElements(depsEl).iterator();
336
        Iterator deps = XMLUtil.findSubElements(depsEl).iterator();
337
        while (deps.hasNext()) {
337
        while (deps.hasNext()) {
338
            Element dep = (Element) deps.next();
338
            Element dep = (Element) deps.next();
339
            Element cnbEl2 = XMLUtil.findElement(dep, "code-name-base", ParseProjectXml.NBM_NS);
339
            Element cnbEl2 = ParseProjectXml.findNBMElement(dep, "code-name-base");
340
            if (cnbEl2 == null) {
340
            if (cnbEl2 == null) {
341
                throw new IOException("Malformed project file " + projectxml);
341
                throw new IOException("Malformed project file " + projectxml);
342
            }
342
            }
343
            String cnb2 = XMLUtil.findText(cnbEl2);
343
            String cnb2 = XMLUtil.findText(cnbEl2);
344
            rundeps.add(cnb2);
344
            rundeps.add(cnb2);
345
            if (XMLUtil.findElement(dep, "build-prerequisite", ParseProjectXml.NBM_NS) == null) {
345
            if (ParseProjectXml.findNBMElement(dep, "build-prerequisite") == null) {
346
                continue;
346
                continue;
347
            }
347
            }
348
            prereqs.add(cnb2);
348
            prereqs.add(cnb2);
(-)antsrc/org/netbeans/nbbuild/ParseProjectXml.java (-21 / +32 lines)
Lines 60-66 Link Here
60
public final class ParseProjectXml extends Task {
60
public final class ParseProjectXml extends Task {
61
61
62
    static final String PROJECT_NS = "http://www.netbeans.org/ns/project/1";
62
    static final String PROJECT_NS = "http://www.netbeans.org/ns/project/1";
63
    static final String NBM_NS = "http://www.netbeans.org/ns/nb-module-project/2";
63
//    static final String NBM_NS = "http://www.netbeans.org/ns/nb-module-project/2";
64
    static final String NBM_NS2 = "http://www.netbeans.org/ns/nb-module-project/2";
65
    static final String NBM_NS3 = "http://www.netbeans.org/ns/nb-module-project/3";
64
    
66
    
65
    static final int TYPE_NB_ORG = 0;
67
    static final int TYPE_NB_ORG = 0;
66
    static final int TYPE_SUITE = 1;
68
    static final int TYPE_SUITE = 1;
Lines 462-468 Link Here
462
        if (c == null) {
464
        if (c == null) {
463
            throw new BuildException("No <configuration>", getLocation());
465
            throw new BuildException("No <configuration>", getLocation());
464
        }
466
        }
465
        Element d = XMLUtil.findElement(c, "data", NBM_NS);
467
        Element d = findNBMElement(c, "data");
466
        if (d == null) {
468
        if (d == null) {
467
            throw new BuildException("No <data> in " + getProjectFile(), getLocation());
469
            throw new BuildException("No <data> in " + getProjectFile(), getLocation());
468
        }
470
        }
Lines 481-489 Link Here
481
483
482
    private PublicPackage[] getPublicPackages(Document d) throws BuildException {
484
    private PublicPackage[] getPublicPackages(Document d) throws BuildException {
483
        Element cfg = getConfig(d);
485
        Element cfg = getConfig(d);
484
        Element pp = XMLUtil.findElement(cfg, "public-packages", NBM_NS);
486
        Element pp = findNBMElement(cfg, "public-packages");
485
        if (pp == null) {
487
        if (pp == null) {
486
            pp = XMLUtil.findElement(cfg, "friend-packages", NBM_NS);
488
            pp = findNBMElement(cfg, "friend-packages");
487
        }
489
        }
488
        if (pp == null) {
490
        if (pp == null) {
489
            throw new BuildException("No <public-packages>", getLocation());
491
            throw new BuildException("No <public-packages>", getLocation());
Lines 515-521 Link Here
515
    
517
    
516
    private String[] getFriends(Document d) throws BuildException {
518
    private String[] getFriends(Document d) throws BuildException {
517
        Element cfg = getConfig(d);
519
        Element cfg = getConfig(d);
518
        Element pp = XMLUtil.findElement(cfg, "friend-packages", NBM_NS);
520
        Element pp = findNBMElement(cfg, "friend-packages");
519
        if (pp == null) {
521
        if (pp == null) {
520
            return null;
522
            return null;
521
        }
523
        }
Lines 661-667 Link Here
661
663
662
    private Dep[] getDeps(Document pDoc, ModuleListParser modules) throws BuildException {
664
    private Dep[] getDeps(Document pDoc, ModuleListParser modules) throws BuildException {
663
        Element cfg = getConfig(pDoc);
665
        Element cfg = getConfig(pDoc);
664
        Element md = XMLUtil.findElement(cfg, "module-dependencies", NBM_NS);
666
        Element md = findNBMElement(cfg, "module-dependencies");
665
        if (md == null) {
667
        if (md == null) {
666
            throw new BuildException("No <module-dependencies>", getLocation());
668
            throw new BuildException("No <module-dependencies>", getLocation());
667
        }
669
        }
Lines 671-677 Link Here
671
        while (it.hasNext()) {
673
        while (it.hasNext()) {
672
            Element dep = (Element)it.next();
674
            Element dep = (Element)it.next();
673
            Dep d = new Dep(modules);
675
            Dep d = new Dep(modules);
674
            Element cnb = XMLUtil.findElement(dep, "code-name-base", NBM_NS);
676
            Element cnb = findNBMElement(dep, "code-name-base");
675
            if (cnb == null) {
677
            if (cnb == null) {
676
                throw new BuildException("No <code-name-base>", getLocation());
678
                throw new BuildException("No <code-name-base>", getLocation());
677
            }
679
            }
Lines 680-689 Link Here
680
                throw new BuildException("No text in <code-name-base>", getLocation());
682
                throw new BuildException("No text in <code-name-base>", getLocation());
681
            }
683
            }
682
            d.codenamebase = t;
684
            d.codenamebase = t;
683
            Element rd = XMLUtil.findElement(dep, "run-dependency", NBM_NS);
685
            Element rd = findNBMElement(dep, "run-dependency");
684
            if (rd != null) {
686
            if (rd != null) {
685
                d.run = true;
687
                d.run = true;
686
                Element rv = XMLUtil.findElement(rd, "release-version", NBM_NS);
688
                Element rv = findNBMElement(rd, "release-version");
687
                if (rv != null) {
689
                if (rv != null) {
688
                    t = XMLUtil.findText(rv);
690
                    t = XMLUtil.findText(rv);
689
                    if (t == null) {
691
                    if (t == null) {
Lines 691-697 Link Here
691
                    }
693
                    }
692
                    d.release = t;
694
                    d.release = t;
693
                }
695
                }
694
                Element sv = XMLUtil.findElement(rd, "specification-version", NBM_NS);
696
                Element sv = findNBMElement(rd, "specification-version");
695
                if (sv != null) {
697
                if (sv != null) {
696
                    t = XMLUtil.findText(sv);
698
                    t = XMLUtil.findText(sv);
697
                    if (t == null) {
699
                    if (t == null) {
Lines 699-710 Link Here
699
                    }
701
                    }
700
                    d.spec = t;
702
                    d.spec = t;
701
                }
703
                }
702
                Element iv = XMLUtil.findElement(rd, "implementation-version", NBM_NS);
704
                Element iv = findNBMElement(rd, "implementation-version");
703
                if (iv != null) {
705
                if (iv != null) {
704
                    d.impl = true;
706
                    d.impl = true;
705
                }
707
                }
706
            }
708
            }
707
            d.compile = XMLUtil.findElement(dep, "compile-dependency", NBM_NS) != null;
709
            d.compile = findNBMElement(dep, "compile-dependency") != null;
708
            deps.add(d);
710
            deps.add(d);
709
        }
711
        }
710
        return (Dep[])deps.toArray(new Dep[deps.size()]);
712
        return (Dep[])deps.toArray(new Dep[deps.size()]);
Lines 712-718 Link Here
712
714
713
    private String getCodeNameBase(Document d) throws BuildException {
715
    private String getCodeNameBase(Document d) throws BuildException {
714
        Element data = getConfig(d);
716
        Element data = getConfig(d);
715
        Element name = XMLUtil.findElement(data, "code-name-base", NBM_NS);
717
        Element name = findNBMElement(data, "code-name-base");
716
        if (name == null) {
718
        if (name == null) {
717
            throw new BuildException("No <code-name-base>", getLocation());
719
            throw new BuildException("No <code-name-base>", getLocation());
718
        }
720
        }
Lines 725-733 Link Here
725
727
726
    private int getModuleType(Document d) throws BuildException {
728
    private int getModuleType(Document d) throws BuildException {
727
        Element data = getConfig(d);
729
        Element data = getConfig(d);
728
        if (XMLUtil.findElement(data, "suite-component", NBM_NS) != null) {
730
        if (findNBMElement(data, "suite-component") != null) {
729
            return TYPE_SUITE;
731
            return TYPE_SUITE;
730
        } else if (XMLUtil.findElement(data, "standalone", NBM_NS) != null) {
732
        } else if (findNBMElement(data, "standalone") != null) {
731
            return TYPE_STANDALONE;
733
            return TYPE_STANDALONE;
732
        } else {
734
        } else {
733
            return TYPE_NB_ORG;
735
            return TYPE_NB_ORG;
Lines 991-997 Link Here
991
            if (!ext.getLocalName().equals("class-path-extension")) {
993
            if (!ext.getLocalName().equals("class-path-extension")) {
992
                continue;
994
                continue;
993
            }
995
            }
994
            Element runtimeRelativePath = XMLUtil.findElement(ext, "runtime-relative-path", NBM_NS);
996
            Element runtimeRelativePath = findNBMElement(ext, "runtime-relative-path");
995
            if (runtimeRelativePath == null) {
997
            if (runtimeRelativePath == null) {
996
                throw new BuildException("Have malformed <class-path-extension> in " + getProjectFile(), getLocation());
998
                throw new BuildException("Have malformed <class-path-extension> in " + getProjectFile(), getLocation());
997
            }
999
            }
Lines 1094-1100 Link Here
1094
        assert modules != null;
1096
        assert modules != null;
1095
        Element cfg = getConfig(pDoc);
1097
        Element cfg = getConfig(pDoc);
1096
        List testDepsList = new ArrayList(); 
1098
        List testDepsList = new ArrayList(); 
1097
        Element pp = XMLUtil.findElement(cfg, "test-dependencies", NBM_NS);
1099
        Element pp = findNBMElement(cfg, "test-dependencies");
1098
        if (pp != null) {
1100
        if (pp != null) {
1099
            for (Iterator depssIt = XMLUtil.findSubElements(pp).iterator(); depssIt.hasNext();) {
1101
            for (Iterator depssIt = XMLUtil.findSubElements(pp).iterator(); depssIt.hasNext();) {
1100
                Element depssEl = (Element) depssIt.next();
1102
                Element depssEl = (Element) depssIt.next();
Lines 1108-1117 Link Here
1108
                    Element el = (Element) depsIt.next();
1110
                    Element el = (Element) depsIt.next();
1109
                    if (el.getTagName().equals("test-dependency")) {
1111
                    if (el.getTagName().equals("test-dependency")) {
1110
                        // parse test dep
1112
                        // parse test dep
1111
                        boolean  test =   (XMLUtil.findElement(el,"test",NBM_NS) != null);;
1113
                        boolean  test =   (findNBMElement(el,"test") != null);;
1112
                        String cnb =  findTextOrNull(el,"code-name-base");
1114
                        String cnb =  findTextOrNull(el,"code-name-base");
1113
                        boolean  recursive = (XMLUtil.findElement(el,"recursive",NBM_NS) != null);
1115
                        boolean  recursive = (findNBMElement(el,"recursive") != null);
1114
                        boolean  compile = (XMLUtil.findElement(el,"compile-dependency",NBM_NS) != null);                    
1116
                        boolean  compile = (findNBMElement(el,"compile-dependency") != null);                    
1115
                        testDeps.addDepenency(new TestDep(cnb,
1117
                        testDeps.addDepenency(new TestDep(cnb,
1116
                                                         modules,
1118
                                                         modules,
1117
                                                         recursive,
1119
                                                         recursive,
Lines 1128-1137 Link Here
1128
        return testDepss;      
1130
        return testDepss;      
1129
    }
1131
    }
1130
    private static String findTextOrNull(Element parentElement,String elementName) {
1132
    private static String findTextOrNull(Element parentElement,String elementName) {
1131
        Element el = XMLUtil.findElement(parentElement,elementName,NBM_NS);
1133
        Element el = findNBMElement(parentElement,elementName);
1132
        return (el == null) ? null :
1134
        return (el == null) ? null :
1133
                              XMLUtil.findText(el);
1135
                              XMLUtil.findText(el);
1134
                
1136
                
1137
    }
1138
    private static String NBM_NS_CACHE = NBM_NS3;
1139
    static Element findNBMElement(Element el,String name) {
1140
        Element retEl = XMLUtil.findElement(el,name,NBM_NS_CACHE) ;
1141
        if (retEl == null) {
1142
            NBM_NS_CACHE = (NBM_NS_CACHE == NBM_NS3) ? NBM_NS2 :NBM_NS3;
1143
            retEl = XMLUtil.findElement(el,name,NBM_NS_CACHE) ;            
1144
        }
1145
        return retEl;
1135
    }
1146
    }
1136
 
1147
 
1137
}
1148
}
(-)antsrc/org/netbeans/nbbuild/SortSuiteModules.java (-5 / +5 lines)
Lines 89-116 Link Here
89
            if (config == null) {
89
            if (config == null) {
90
                throw new BuildException("Malformed project file " + projectXml, getLocation());
90
                throw new BuildException("Malformed project file " + projectXml, getLocation());
91
            }
91
            }
92
            Element data = XMLUtil.findElement(config, "data", ParseProjectXml.NBM_NS);
92
            Element data = ParseProjectXml.findNBMElement(config, "data");
93
            if (data == null) {
93
            if (data == null) {
94
                throw new BuildException("Malformed project file " + projectXml, getLocation());
94
                throw new BuildException("Malformed project file " + projectXml, getLocation());
95
            }
95
            }
96
            Element cnbEl = XMLUtil.findElement(data, "code-name-base", ParseProjectXml.NBM_NS);
96
            Element cnbEl = ParseProjectXml.findNBMElement(data, "code-name-base");
97
            if (cnbEl == null) {
97
            if (cnbEl == null) {
98
                throw new BuildException("Malformed project file " + projectXml, getLocation());
98
                throw new BuildException("Malformed project file " + projectXml, getLocation());
99
            }
99
            }
100
            String cnb = XMLUtil.findText(cnbEl);
100
            String cnb = XMLUtil.findText(cnbEl);
101
            basedirsByCNB.put(cnb, d);
101
            basedirsByCNB.put(cnb, d);
102
            List/*<String>*/ deps = new LinkedList();
102
            List/*<String>*/ deps = new LinkedList();
103
            Element depsEl = XMLUtil.findElement(data, "module-dependencies", ParseProjectXml.NBM_NS);
103
            Element depsEl = ParseProjectXml.findNBMElement(data, "module-dependencies");
104
            if (depsEl == null) {
104
            if (depsEl == null) {
105
                throw new BuildException("Malformed project file " + projectXml, getLocation());
105
                throw new BuildException("Malformed project file " + projectXml, getLocation());
106
            }
106
            }
107
            Iterator it = XMLUtil.findSubElements(depsEl).iterator();
107
            Iterator it = XMLUtil.findSubElements(depsEl).iterator();
108
            while (it.hasNext()) {
108
            while (it.hasNext()) {
109
                Element dep = (Element) it.next();
109
                Element dep = (Element) it.next();
110
                if (XMLUtil.findElement(dep, "build-prerequisite", ParseProjectXml.NBM_NS) == null) {
110
                if (ParseProjectXml.findNBMElement(dep, "build-prerequisite") == null) {
111
                    continue;
111
                    continue;
112
                }
112
                }
113
                Element cnbEl2 = XMLUtil.findElement(dep, "code-name-base", ParseProjectXml.NBM_NS);
113
                Element cnbEl2 = ParseProjectXml.findNBMElement(dep, "code-name-base");
114
                if (cnbEl2 == null) {
114
                if (cnbEl2 == null) {
115
                    throw new BuildException("Malformed project file " + projectXml, getLocation());
115
                    throw new BuildException("Malformed project file " + projectXml, getLocation());
116
                }
116
                }
(-)test/unit/src/org/netbeans/nbbuild/FixTestDependenciesProject2.xml (+327 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
The contents of this file are subject to the terms of the Common Development
4
and Distribution License (the License). You may not use this file except in
5
compliance with the License.
6
7
You can obtain a copy of the License at http://www.netbeans.org/cddl.html
8
or http://www.netbeans.org/cddl.txt.
9
10
When distributing Covered Code, include this CDDL Header Notice in each file
11
and include the License file at http://www.netbeans.org/cddl.txt.
12
If applicable, add the following below the CDDL Header, with the fields
13
enclosed by brackets [] replaced by your own identifying information:
14
"Portions Copyrighted [year] [name of copyright owner]"
15
16
The Original Software is NetBeans. The Initial Developer of the Original
17
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
18
Microsystems, Inc. All Rights Reserved.
19
-->
20
<project xmlns="http://www.netbeans.org/ns/project/1">
21
    <type>org.netbeans.modules.apisupport.project</type>
22
    <configuration>
23
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
24
            <code-name-base>org.netbeans.modules.java.j2seproject</code-name-base>
25
            <module-dependencies>
26
                <dependency>
27
                    <code-name-base>javax.jmi.reflect</code-name-base>
28
                    <build-prerequisite/>
29
                    <compile-dependency/>
30
                    <run-dependency>
31
                        <release-version>1</release-version>
32
                    </run-dependency>
33
                </dependency>
34
                <dependency>
35
                    <code-name-base>org.apache.tools.ant.module</code-name-base>
36
                    <build-prerequisite/>
37
                    <compile-dependency/>
38
                    <run-dependency>
39
                        <release-version>3</release-version>
40
                        <specification-version>3.12</specification-version>
41
                    </run-dependency>
42
                </dependency>
43
                <dependency>
44
                    <code-name-base>org.netbeans.api.java</code-name-base>
45
                    <build-prerequisite/>
46
                    <compile-dependency/>
47
                    <run-dependency>
48
                        <release-version>1</release-version>
49
                    </run-dependency>
50
                </dependency>
51
                <dependency>
52
                    <code-name-base>org.netbeans.api.mdr</code-name-base>
53
                    <build-prerequisite/>
54
                    <compile-dependency/>
55
                    <run-dependency>
56
                        <release-version>1</release-version>
57
                    </run-dependency>
58
                </dependency>
59
                <dependency>
60
                    <code-name-base>org.netbeans.jmi.javamodel</code-name-base>
61
                    <build-prerequisite/>
62
                    <compile-dependency/>
63
                    <run-dependency>
64
                        <release-version>2</release-version>
65
                        <specification-version>1.16</specification-version>
66
                    </run-dependency>
67
                </dependency>
68
                <dependency>
69
                    <code-name-base>org.netbeans.modules.ant.browsetask</code-name-base>
70
                    <run-dependency/>
71
                </dependency>
72
                <dependency>
73
                    <code-name-base>org.netbeans.modules.debugger.jpda.ant</code-name-base>
74
                    <run-dependency/>
75
                </dependency>
76
                <dependency>
77
                    <code-name-base>org.netbeans.modules.java.platform</code-name-base>
78
                    <build-prerequisite/>
79
                    <compile-dependency/>
80
                    <run-dependency>
81
                        <release-version>1</release-version>
82
                    </run-dependency>
83
                </dependency>
84
                <dependency>
85
                    <code-name-base>org.netbeans.modules.java.project</code-name-base>
86
                    <build-prerequisite/>
87
                    <compile-dependency/>
88
                    <run-dependency>
89
                        <release-version>1</release-version>
90
                    </run-dependency>
91
                </dependency>
92
                <dependency>
93
                    <code-name-base>org.netbeans.modules.javacore</code-name-base>
94
                    <build-prerequisite/>
95
                    <compile-dependency/>
96
                    <run-dependency>
97
                        <release-version>1</release-version>
98
                    </run-dependency>
99
                </dependency>
100
                <dependency>
101
                    <code-name-base>org.netbeans.modules.jmiutils</code-name-base>
102
                    <build-prerequisite/>
103
                    <compile-dependency/>
104
                    <run-dependency>
105
                        <release-version>1</release-version>
106
                    </run-dependency>
107
                </dependency>
108
                <dependency>
109
                    <code-name-base>org.netbeans.modules.junit</code-name-base>
110
                    <run-dependency>
111
                        <release-version>2</release-version>
112
                    </run-dependency>
113
                </dependency>
114
                <dependency>
115
                    <code-name-base>org.netbeans.modules.project.ant</code-name-base>
116
                    <build-prerequisite/>
117
                    <compile-dependency/>
118
                    <run-dependency>
119
                        <release-version>1</release-version>
120
                        <specification-version>1.8</specification-version>
121
                    </run-dependency>
122
                </dependency>
123
                <dependency>
124
                    <code-name-base>org.netbeans.modules.project.libraries</code-name-base>
125
                    <build-prerequisite/>
126
                    <compile-dependency/>
127
                    <run-dependency>
128
                        <release-version>1</release-version>
129
                    </run-dependency>
130
                </dependency>
131
                <dependency>
132
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
133
                    <build-prerequisite/>
134
                    <compile-dependency/>
135
                    <run-dependency>
136
                        <release-version>1</release-version>
137
                        <specification-version>1.6</specification-version>
138
                    </run-dependency>
139
                </dependency>
140
                <dependency>
141
                    <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
142
                    <build-prerequisite/>
143
                    <compile-dependency/>
144
                    <run-dependency>
145
                        <release-version>1</release-version>
146
                    </run-dependency>
147
                </dependency>
148
                <dependency>
149
                    <code-name-base>org.netbeans.modules.queries</code-name-base>
150
                    <build-prerequisite/>
151
                    <compile-dependency/>
152
                    <run-dependency>
153
                        <release-version>1</release-version>
154
                    </run-dependency>
155
                </dependency>
156
                <dependency>
157
                    <code-name-base>org.openide.actions</code-name-base>
158
                    <build-prerequisite/>
159
                    <compile-dependency/>
160
                    <run-dependency>
161
                        <specification-version>6.2</specification-version>
162
                    </run-dependency>
163
                </dependency>
164
                <dependency>
165
                    <code-name-base>org.openide.awt</code-name-base>
166
                    <build-prerequisite/>
167
                    <compile-dependency/>
168
                    <run-dependency>
169
                        <specification-version>6.2</specification-version>
170
                    </run-dependency>
171
                </dependency>
172
                <dependency>
173
                    <code-name-base>org.openide.dialogs</code-name-base>
174
                    <build-prerequisite/>
175
                    <compile-dependency/>
176
                    <run-dependency>
177
                        <specification-version>6.2</specification-version>
178
                    </run-dependency>
179
                </dependency>
180
                <dependency>
181
                    <code-name-base>org.openide.execution</code-name-base>
182
                    <build-prerequisite/>
183
                    <compile-dependency/>
184
                    <run-dependency>
185
                        <specification-version>1.2</specification-version>
186
                    </run-dependency>
187
                </dependency>
188
                <dependency>
189
                    <code-name-base>org.openide.filesystems</code-name-base>
190
                    <build-prerequisite/>
191
                    <compile-dependency/>
192
                    <run-dependency>
193
                        <specification-version>6.2</specification-version>
194
                    </run-dependency>
195
                </dependency>
196
                <dependency>
197
                    <code-name-base>org.openide.loaders</code-name-base>
198
                    <build-prerequisite/>
199
                    <compile-dependency/>
200
                    <run-dependency/>
201
                </dependency>
202
                <dependency>
203
                    <code-name-base>org.openide.modules</code-name-base>
204
                    <build-prerequisite/>
205
                    <compile-dependency/>
206
                    <run-dependency>
207
                        <specification-version>6.2</specification-version>
208
                    </run-dependency>
209
                </dependency>
210
                <dependency>
211
                    <code-name-base>org.openide.nodes</code-name-base>
212
                    <build-prerequisite/>
213
                    <compile-dependency/>
214
                    <run-dependency>
215
                        <specification-version>6.5</specification-version>
216
                    </run-dependency>
217
                </dependency>
218
                <dependency>
219
                    <code-name-base>org.openide.options</code-name-base>
220
                    <build-prerequisite/>
221
                    <compile-dependency/>
222
                    <run-dependency>
223
                        <specification-version>6.2</specification-version>
224
                    </run-dependency>
225
                </dependency>
226
                <dependency>
227
                    <code-name-base>org.openide.src</code-name-base>
228
                    <build-prerequisite/>
229
                    <compile-dependency/>
230
                    <run-dependency/>
231
                </dependency>
232
                <dependency>
233
                    <code-name-base>org.openide.util</code-name-base>
234
                    <build-prerequisite/>
235
                    <compile-dependency/>
236
                    <run-dependency>
237
                        <specification-version>6.2</specification-version>
238
                    </run-dependency>
239
                </dependency>
240
                <dependency>
241
                    <code-name-base>org.openide.windows</code-name-base>
242
                    <build-prerequisite/>
243
                    <compile-dependency/>
244
                    <run-dependency>
245
                        <specification-version>6.2</specification-version>
246
                    </run-dependency>
247
                </dependency>
248
                <dependency>
249
                    <code-name-base>org.netbeans.modules.websvc.clientapi</code-name-base>
250
                    <build-prerequisite/>
251
                    <compile-dependency/>
252
                    <run-dependency>
253
                        <specification-version>1.2</specification-version>
254
                    </run-dependency>
255
                </dependency>                
256
            </module-dependencies>
257
          <test-dependencies>
258
              <test-type>
259
                  <name>unit</name>
260
                  <test-dependency>
261
                      <code-name-base>org.netbeans.modules.java.j2seproject</code-name-base>
262
                      <recursive/>
263
                      <compile-dependency/>
264
                  </test-dependency>
265
                  <test-dependency>
266
                      <code-name-base>org.openide.io</code-name-base>
267
                      <compile-dependency/>
268
                  </test-dependency>
269
                  <test-dependency>
270
                      <code-name-base>org.netbeans.modules.projectapi</code-name-base>
271
                      <compile-dependency/>
272
                      <test/>
273
                  </test-dependency>
274
                  <test-dependency>
275
                      <code-name-base>org.openide.compat</code-name-base>
276
                  </test-dependency>
277
                  <test-dependency>
278
                      <code-name-base>org.netbeans.core</code-name-base>
279
                  </test-dependency>
280
                  <test-dependency>
281
                      <code-name-base>org.openide.loaders</code-name-base>
282
                  </test-dependency>
283
                  <test-dependency>
284
                      <code-name-base>org.netbeans.modules.masterfs</code-name-base>
285
                  </test-dependency>
286
                  <test-dependency>
287
                      <code-name-base>org.netbeans.api.progress</code-name-base>
288
                  </test-dependency>
289
                  <test-dependency>
290
                      <code-name-base>org.openide.options</code-name-base>
291
                  </test-dependency>
292
                  <test-dependency>
293
                      <code-name-base>org.openide.explorer</code-name-base>
294
                  </test-dependency>
295
                  <test-dependency>
296
                      <code-name-base>org.openide.dialogs</code-name-base>
297
                  </test-dependency>
298
                  <test-dependency>
299
                      <code-name-base>org.openide.nodes</code-name-base>
300
                  </test-dependency>
301
                  <test-dependency>
302
                      <code-name-base>org.openide.text</code-name-base>
303
                  </test-dependency>
304
                  <test-dependency>
305
                      <code-name-base>org.openide.awt</code-name-base>
306
                  </test-dependency>
307
                  <test-dependency>
308
                      <code-name-base>org.openide.util</code-name-base>
309
                  </test-dependency>
310
                  <test-dependency>
311
                      <code-name-base>org.openide.actions</code-name-base>
312
                  </test-dependency>
313
                  <test-dependency>
314
                      <code-name-base>org.openide.modules</code-name-base>
315
                  </test-dependency>
316
                  <test-dependency>
317
                      <code-name-base>org.openide.filesystems</code-name-base>
318
                  </test-dependency>
319
              </test-type>
320
              <test-type>
321
                  <name>qa-functional</name>
322
              </test-type>
323
            </test-dependencies>
324
            <public-packages/>
325
        </data>
326
    </configuration>
327
</project>
(-)test/unit/src/org/netbeans/nbbuild/FixTestDependenciesProjectPass.xml (-1 / +1 lines)
Lines 20-26 Link Here
20
<project xmlns="http://www.netbeans.org/ns/project/1">
20
<project xmlns="http://www.netbeans.org/ns/project/1">
21
    <type>org.netbeans.modules.apisupport.project</type>
21
    <type>org.netbeans.modules.apisupport.project</type>
22
    <configuration>
22
    <configuration>
23
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
23
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
24
            <code-name-base>org.netbeans.modules.java.j2seproject</code-name-base>
24
            <code-name-base>org.netbeans.modules.java.j2seproject</code-name-base>
25
            <module-dependencies>
25
            <module-dependencies>
26
                <dependency>
26
                <dependency>
(-)test/unit/src/org/netbeans/nbbuild/FixTestDependenciesTest.java (-8 / +13 lines)
Lines 52-66 Link Here
52
    public void testSimple() throws IOException, Exception {
52
    public void testSimple() throws IOException, Exception {
53
          File prjFile = copyFile("FixTestDependenciesProject.xml"); 
53
          File prjFile = copyFile("FixTestDependenciesProject.xml"); 
54
          File propertiesFile = copyFile("FixTestDependencies.properties");
54
          File propertiesFile = copyFile("FixTestDependencies.properties");
55
          doFixProjectXml(propertiesFile, prjFile);
56
          doFixProjectXml(propertiesFile, copyFile("FixTestDependenciesProject2.xml"));
55
          
57
          
56
          PublicPackagesInProjectizedXMLTest.
58
    }
57
                  execute ("FixTestDependenciesTest.xml", new String[] {"-verbose", 
59
58
                        "-Dtest.project.xml=" + prjFile.getPath(),
60
    private void doFixProjectXml(final File propertiesFile, final File prjFile) throws Exception, IOException {
59
                        "-Dtest.properties.file=" + propertiesFile.getPath()});
61
60
          
62
        PublicPackagesInProjectizedXMLTest.
61
          assertFile(copyFile("FixTestDependenciesProjectPass.xml"),prjFile);
63
                execute ("FixTestDependenciesTest.xml", new String[] {"-verbose", 
62
          assertFile(copyFile("FixTestDependenciesPass.properties"),propertiesFile);
64
                      "-Dtest.project.xml=" + prjFile.getPath(),
63
          
65
                      "-Dtest.properties.file=" + propertiesFile.getPath()});
66
        
67
        assertFile(copyFile("FixTestDependenciesProjectPass.xml"),prjFile);
68
        assertFile(copyFile("FixTestDependenciesPass.properties"),propertiesFile);
64
    }
69
    }
65
70
66
    private File copyFile(String resourceName) throws IOException {
71
    private File copyFile(String resourceName) throws IOException {

Return to bug 80824