Lines 44-49
Link Here
|
44 |
|
44 |
|
45 |
package org.netbeans.nbbuild; |
45 |
package org.netbeans.nbbuild; |
46 |
|
46 |
|
|
|
47 |
import java.io.BufferedReader; |
47 |
import java.util.HashMap; |
48 |
import java.util.HashMap; |
48 |
import java.util.LinkedHashMap; |
49 |
import java.util.LinkedHashMap; |
49 |
import java.util.Map; |
50 |
import java.util.Map; |
Lines 57-62
Link Here
|
57 |
import java.io.FileOutputStream; |
58 |
import java.io.FileOutputStream; |
58 |
import java.io.IOException; |
59 |
import java.io.IOException; |
59 |
import java.io.InputStream; |
60 |
import java.io.InputStream; |
|
|
61 |
import java.io.InputStreamReader; |
60 |
import java.io.OutputStream; |
62 |
import java.io.OutputStream; |
61 |
import java.io.OutputStreamWriter; |
63 |
import java.io.OutputStreamWriter; |
62 |
import java.io.PrintWriter; |
64 |
import java.io.PrintWriter; |
Lines 67-78
Link Here
|
67 |
import java.util.Collection; |
69 |
import java.util.Collection; |
68 |
import java.util.Comparator; |
70 |
import java.util.Comparator; |
69 |
import java.util.Date; |
71 |
import java.util.Date; |
|
|
72 |
import java.util.Enumeration; |
70 |
import java.util.List; |
73 |
import java.util.List; |
71 |
import java.util.Properties; |
74 |
import java.util.Properties; |
72 |
import java.util.TimeZone; |
75 |
import java.util.TimeZone; |
73 |
import java.util.TreeMap; |
76 |
import java.util.TreeMap; |
74 |
import java.util.TreeSet; |
77 |
import java.util.TreeSet; |
75 |
import java.util.jar.Attributes; |
78 |
import java.util.jar.Attributes; |
|
|
79 |
import java.util.jar.JarEntry; |
76 |
import java.util.jar.JarFile; |
80 |
import java.util.jar.JarFile; |
77 |
import java.util.regex.Matcher; |
81 |
import java.util.regex.Matcher; |
78 |
import java.util.regex.Pattern; |
82 |
import java.util.regex.Pattern; |
Lines 380-386
Link Here
|
380 |
for (Module m : entry.getValue()) { |
384 |
for (Module m : entry.getValue()) { |
381 |
Element module = m.xml; |
385 |
Element module = m.xml; |
382 |
if (module.getAttribute("downloadsize").equals("0")) { |
386 |
if (module.getAttribute("downloadsize").equals("0")) { |
383 |
module.setAttribute("downloadsize", Long.toString(m.nbm.length())); |
387 |
module.setAttribute("downloadsize", Long.toString(m.nbm.length() + m.externalDownloadSize)); |
384 |
} |
388 |
} |
385 |
Element manifest = (Element) module.getElementsByTagName("manifest").item(0); |
389 |
Element manifest = (Element) module.getElementsByTagName("manifest").item(0); |
386 |
String name = manifest.getAttribute("OpenIDE-Module-Name"); |
390 |
String name = manifest.getAttribute("OpenIDE-Module-Name"); |
Lines 462-467
Link Here
|
462 |
public File nbm; |
466 |
public File nbm; |
463 |
public String relativePath; |
467 |
public String relativePath; |
464 |
public boolean autoload, eager; |
468 |
public boolean autoload, eager; |
|
|
469 |
public long externalDownloadSize; |
465 |
} |
470 |
} |
466 |
|
471 |
|
467 |
private void writeNotification(PrintWriter pw) { |
472 |
private void writeNotification(PrintWriter pw) { |
Lines 596-601
Link Here
|
596 |
} |
601 |
} |
597 |
} |
602 |
} |
598 |
} |
603 |
} |
|
|
604 |
Enumeration<JarEntry> en = jar.entries(); |
605 |
while (en.hasMoreElements()) { |
606 |
JarEntry e = en.nextElement(); |
607 |
if (e.getName().endsWith(".external")) { |
608 |
InputStream eStream = jar.getInputStream(e); |
609 |
try { |
610 |
m.externalDownloadSize += externalSize(eStream); |
611 |
} finally { |
612 |
eStream.close(); |
613 |
} |
614 |
} |
615 |
} |
599 |
moduleCollection.add(m); |
616 |
moduleCollection.add(m); |
600 |
} finally { |
617 |
} finally { |
601 |
jar.close(); |
618 |
jar.close(); |
Lines 611-616
Link Here
|
611 |
return r; |
628 |
return r; |
612 |
} |
629 |
} |
613 |
|
630 |
|
|
|
631 |
private long externalSize(InputStream is) throws IOException { |
632 |
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")); |
633 |
for (;;) { |
634 |
String line = br.readLine(); |
635 |
if (line == null) { |
636 |
break; |
637 |
} |
638 |
if (line.startsWith("SIZE:")) { |
639 |
return Long.parseLong(line.substring(5).trim()); |
640 |
} |
641 |
} |
642 |
return 0; |
643 |
} |
644 |
|
614 |
/** |
645 |
/** |
615 |
* Create the equivalent of {@code Info/info.xml} for an OSGi bundle. |
646 |
* Create the equivalent of {@code Info/info.xml} for an OSGi bundle. |
616 |
* @param jar a bundle |
647 |
* @param jar a bundle |