Lines 45-50
Link Here
|
45 |
import java.util.jar.JarFile; |
45 |
import java.util.jar.JarFile; |
46 |
import java.util.jar.JarInputStream; |
46 |
import java.util.jar.JarInputStream; |
47 |
import java.util.jar.Manifest; |
47 |
import java.util.jar.Manifest; |
|
|
48 |
import java.util.regex.Matcher; |
49 |
import java.util.regex.Pattern; |
48 |
import java.util.zip.ZipEntry; |
50 |
import java.util.zip.ZipEntry; |
49 |
import java.util.zip.ZipFile; |
51 |
import java.util.zip.ZipFile; |
50 |
import org.apache.tools.ant.BuildException; |
52 |
import org.apache.tools.ant.BuildException; |
Lines 170-178
Link Here
|
170 |
shrt = prop.getProperty("OpenIDE-Module-Long-Description", oneline); |
172 |
shrt = prop.getProperty("OpenIDE-Module-Long-Description", oneline); |
171 |
} |
173 |
} |
172 |
|
174 |
|
173 |
if (verify) { |
175 |
Map localizedFiles = verifyExtensions(jar, theJar.getManifest(), dashcnb, codenamebase, verify); |
174 |
verifyExtensions(jar, theJar.getManifest(), dashcnb, codenamebase); |
|
|
175 |
} |
176 |
|
176 |
|
177 |
|
177 |
|
178 |
File signed = new File(target, jar.getName()); |
178 |
File signed = new File(target, jar.getName()); |
Lines 194-199
Link Here
|
194 |
processExtensions(jar, theJar.getManifest(), writeJNLP, dashcnb, codebase); |
194 |
processExtensions(jar, theJar.getManifest(), writeJNLP, dashcnb, codebase); |
195 |
|
195 |
|
196 |
writeJNLP.write(" </resources>\n"); |
196 |
writeJNLP.write(" </resources>\n"); |
|
|
197 |
|
198 |
{ |
199 |
// write down locales |
200 |
Iterator it = localizedFiles.entrySet().iterator(); |
201 |
while (it.hasNext()) { |
202 |
Map.Entry e = (Map.Entry)it.next(); |
203 |
String locale = (String)e.getKey(); |
204 |
List files = (List)e.getValue(); |
205 |
|
206 |
writeJNLP.write(" <resources locale='" + locale + "'>\n"); |
207 |
|
208 |
Iterator fit = files.iterator(); |
209 |
while (fit.hasNext()) { |
210 |
File n = (File)fit.next(); |
211 |
File t = new File(target, n.getName()); |
212 |
|
213 |
getSignTask().setJar(n); |
214 |
getSignTask().setSignedjar(t); |
215 |
getSignTask().execute(); |
216 |
|
217 |
writeJNLP.write(" <jar href='"); writeJNLP.write(n.getName()); writeJNLP.write("'/>\n"); |
218 |
} |
219 |
|
220 |
writeJNLP.write(" </resources>\n"); |
221 |
|
222 |
} |
223 |
} |
224 |
|
197 |
writeJNLP.write(" <component-desc/>\n"); |
225 |
writeJNLP.write(" <component-desc/>\n"); |
198 |
writeJNLP.write("</jnlp>\n"); |
226 |
writeJNLP.write("</jnlp>\n"); |
199 |
writeJNLP.close(); |
227 |
writeJNLP.close(); |
Lines 212-218
Link Here
|
212 |
|
240 |
|
213 |
} |
241 |
} |
214 |
|
242 |
|
215 |
private void verifyExtensions(File f, Manifest mf, String dashcnb, String codebasename) throws IOException, BuildException { |
243 |
private Map verifyExtensions(File f, Manifest mf, String dashcnb, String codebasename, boolean verify) throws IOException, BuildException { |
|
|
244 |
Map localizedFiles = new HashMap(); |
245 |
|
246 |
|
216 |
File clusterRoot = f.getParentFile(); |
247 |
File clusterRoot = f.getParentFile(); |
217 |
String moduleDirPrefix = ""; |
248 |
String moduleDirPrefix = ""; |
218 |
File updateTracking; |
249 |
File updateTracking; |
Lines 224-229
Link Here
|
224 |
moduleDirPrefix = clusterRoot.getName() + "/" + moduleDirPrefix; |
255 |
moduleDirPrefix = clusterRoot.getName() + "/" + moduleDirPrefix; |
225 |
clusterRoot = clusterRoot.getParentFile(); |
256 |
clusterRoot = clusterRoot.getParentFile(); |
226 |
if (clusterRoot == null || !clusterRoot.exists()) { |
257 |
if (clusterRoot == null || !clusterRoot.exists()) { |
|
|
258 |
if (!verify) { |
259 |
return localizedFiles; |
260 |
} |
261 |
|
227 |
throw new BuildException("Cannot find update_tracking directory for module " + f); |
262 |
throw new BuildException("Cannot find update_tracking directory for module " + f); |
228 |
} |
263 |
} |
229 |
} |
264 |
} |
Lines 247-262
Link Here
|
247 |
log("project files: " + fileToOwningModule, Project.MSG_DEBUG); |
282 |
log("project files: " + fileToOwningModule, Project.MSG_DEBUG); |
248 |
String name = relative(f, clusterRoot); |
283 |
String name = relative(f, clusterRoot); |
249 |
log(" removing: " + name, Project.MSG_DEBUG); |
284 |
log(" removing: " + name, Project.MSG_DEBUG); |
250 |
fileToOwningModule.remove(name); |
285 |
removeWithLocales(fileToOwningModule, name, clusterRoot, localizedFiles); |
251 |
name = "config/Modules/" + dashcnb + ".xml"; |
286 |
name = "config/Modules/" + dashcnb + ".xml"; |
252 |
log(" removing: " + name, Project.MSG_DEBUG); |
287 |
log(" removing: " + name, Project.MSG_DEBUG); |
253 |
fileToOwningModule.remove(name); |
288 |
removeWithLocales(fileToOwningModule, name, clusterRoot, localizedFiles); |
254 |
name = "config/ModuleAutoDeps/" + dashcnb + ".xml"; |
289 |
name = "config/ModuleAutoDeps/" + dashcnb + ".xml"; |
255 |
log(" removing: " + name, Project.MSG_DEBUG); |
290 |
log(" removing: " + name, Project.MSG_DEBUG); |
256 |
fileToOwningModule.remove(name); |
291 |
removeWithLocales(fileToOwningModule, name, clusterRoot, localizedFiles); |
257 |
name = "update_tracking/" + dashcnb + ".xml"; |
292 |
name = "update_tracking/" + dashcnb + ".xml"; |
258 |
log(" removing: " + name, Project.MSG_DEBUG); |
293 |
log(" removing: " + name, Project.MSG_DEBUG); |
259 |
fileToOwningModule.remove(name); |
294 |
removeWithLocales(fileToOwningModule, name, clusterRoot, localizedFiles); |
|
|
295 |
|
296 |
|
297 |
|
260 |
|
298 |
|
261 |
String path = mf.getMainAttributes().getValue("Class-Path"); |
299 |
String path = mf.getMainAttributes().getValue("Class-Path"); |
262 |
if (path != null) { |
300 |
if (path != null) { |
Lines 265-287
Link Here
|
265 |
String s = tok.nextToken(); |
303 |
String s = tok.nextToken(); |
266 |
File e = new File(f.getParentFile(), s); |
304 |
File e = new File(f.getParentFile(), s); |
267 |
String r = relative(e, clusterRoot); |
305 |
String r = relative(e, clusterRoot); |
268 |
fileToOwningModule.remove(r); |
306 |
removeWithLocales(fileToOwningModule, r, clusterRoot, localizedFiles); |
269 |
} |
307 |
} |
270 |
} |
308 |
} |
271 |
|
309 |
|
272 |
if (verifyExcludes != null) { |
310 |
if (verifyExcludes != null) { |
273 |
StringTokenizer tok = new StringTokenizer(verifyExcludes, ", "); |
311 |
StringTokenizer tok = new StringTokenizer(verifyExcludes, ", "); |
274 |
while(tok.hasMoreElements()) { |
312 |
while(tok.hasMoreElements()) { |
275 |
fileToOwningModule.remove(tok.nextToken()); |
313 |
removeWithLocales(fileToOwningModule, tok.nextToken(), clusterRoot, localizedFiles); |
276 |
} |
314 |
} |
277 |
} |
315 |
} |
278 |
|
316 |
|
279 |
|
317 |
|
280 |
if (!fileToOwningModule.isEmpty()) { |
318 |
if (verify) { |
281 |
throw new BuildException( |
319 |
if (!fileToOwningModule.isEmpty()) { |
282 |
"Cannot build JNLP for module " + f + " as these files are in " + |
320 |
throw new BuildException( |
283 |
"module's NBM, but are not referenced from any path:\n" + fileToOwningModule.keySet() |
321 |
"Cannot build JNLP for module " + f + " as these files are in " + |
284 |
); |
322 |
"module's NBM, but are not referenced from any path:\n" + fileToOwningModule.keySet() |
|
|
323 |
); |
324 |
} |
325 |
} |
326 |
|
327 |
return localizedFiles; |
328 |
} |
329 |
|
330 |
private static void removeWithLocales(Map removeFrom, String removeWhat, File clusterRoot, Map/*<String,List<File>>*/ recordLocales) { |
331 |
if (removeFrom.remove(removeWhat) != null && removeWhat.endsWith(".jar")) { |
332 |
int basedir = removeWhat.indexOf('/'); |
333 |
String base = basedir == -1 ? "" : removeWhat.substring(0, basedir); |
334 |
String name = removeWhat.substring(basedir + 1, removeWhat.length() - 4); |
335 |
Pattern p = Pattern.compile(base + "/locale/" + name + "(|_[a-zA-Z0-9_]+)\\.jar"); |
336 |
|
337 |
Iterator it = removeFrom.keySet().iterator(); |
338 |
while (it.hasNext()) { |
339 |
String s = (String)it.next(); |
340 |
Matcher m = p.matcher(s); |
341 |
if (m.matches()) { |
342 |
String locale = m.group(1).substring(1); |
343 |
|
344 |
List l = (List)recordLocales.get(locale); |
345 |
if (l == null) { |
346 |
l = new ArrayList(); |
347 |
recordLocales.put(locale, l); |
348 |
} |
349 |
l.add(new File(clusterRoot, s.replace('/', File.separatorChar))); |
350 |
it.remove(); |
351 |
} |
352 |
} |
285 |
} |
353 |
} |
286 |
} |
354 |
} |
287 |
|
355 |
|