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 |
} |