Lines 48-58
Link Here
|
48 |
import java.io.StringWriter; |
48 |
import java.io.StringWriter; |
49 |
import java.io.Writer; |
49 |
import java.io.Writer; |
50 |
import java.util.ArrayList; |
50 |
import java.util.ArrayList; |
51 |
import java.util.Collections; |
|
|
52 |
import java.util.Enumeration; |
51 |
import java.util.Enumeration; |
53 |
import java.util.HashMap; |
52 |
import java.util.HashMap; |
54 |
import java.util.HashSet; |
53 |
import java.util.HashSet; |
55 |
import java.util.Iterator; |
54 |
import java.util.Iterator; |
|
|
55 |
import java.util.LinkedHashMap; |
56 |
import java.util.List; |
56 |
import java.util.List; |
57 |
import java.util.Map; |
57 |
import java.util.Map; |
58 |
import java.util.Properties; |
58 |
import java.util.Properties; |
Lines 155-160
Link Here
|
155 |
public void addIndirectJars(FileSet fs) { |
155 |
public void addIndirectJars(FileSet fs) { |
156 |
indirectJars = fs; |
156 |
indirectJars = fs; |
157 |
} |
157 |
} |
|
|
158 |
|
159 |
private FileSet indirectFiles; |
160 |
/** |
161 |
* Other non-JAR files which should be made available to InstalledFileLocator. |
162 |
* The basedir of the fileset should be a cluster root; each |
163 |
* such file will be packed into a ZIP entry META-INF/files/$relpath |
164 |
* where the JAR will be available at runtime in a flat classpath, |
165 |
* using ClassLoader.getResource. |
166 |
*/ |
167 |
public void addIndirectFiles(FileSet fs) { |
168 |
indirectFiles = fs; |
169 |
} |
158 |
|
170 |
|
159 |
private boolean signJars = true; |
171 |
private boolean signJars = true; |
160 |
/** |
172 |
/** |
Lines 204-215
Link Here
|
204 |
} |
216 |
} |
205 |
|
217 |
|
206 |
private void generateFiles() throws IOException, BuildException { |
218 |
private void generateFiles() throws IOException, BuildException { |
207 |
Set<String> indirectJarPaths = Collections.emptySet(); |
219 |
Set<String> indirectFilePaths = new HashSet<String>(); |
208 |
if (indirectJars != null) { |
220 |
for (FileSet fs : new FileSet[] {indirectJars, indirectFiles}) { |
209 |
DirectoryScanner scan = indirectJars.getDirectoryScanner(getProject()); |
221 |
if (fs != null) { |
210 |
indirectJarPaths = new HashSet<String>(); |
222 |
DirectoryScanner scan = fs.getDirectoryScanner(getProject()); |
211 |
for (String f : scan.getIncludedFiles()) { |
223 |
for (String f : scan.getIncludedFiles()) { |
212 |
indirectJarPaths.add(f.replace(File.pathSeparatorChar, '/')); |
224 |
indirectFilePaths.add(f.replace(File.pathSeparatorChar, '/')); |
|
|
225 |
} |
213 |
} |
226 |
} |
214 |
} |
227 |
} |
215 |
|
228 |
|
Lines 263-269
Link Here
|
263 |
} |
276 |
} |
264 |
} |
277 |
} |
265 |
|
278 |
|
266 |
Map<String,List<File>> localizedFiles = verifyExtensions(jar, theJar.getManifest(), dashcnb, codenamebase, verify, indirectJarPaths); |
279 |
Map<String,List<File>> localizedFiles = verifyExtensions(jar, theJar.getManifest(), dashcnb, codenamebase, verify, indirectFilePaths); |
267 |
|
280 |
|
268 |
new File(targetFile, dashcnb).mkdir(); |
281 |
new File(targetFile, dashcnb).mkdir(); |
269 |
|
282 |
|
Lines 286-295
Link Here
|
286 |
} else { |
299 |
} else { |
287 |
writeJNLP.write(" <resources os='" + osDep + "'>\n"); |
300 |
writeJNLP.write(" <resources os='" + osDep + "'>\n"); |
288 |
} |
301 |
} |
289 |
writeJNLP.write(" <jar href='" + dashcnb + '/' + jar.getName() + "'/>\n"); |
302 |
writeJNLP.write(" <jar href='" + dashcnb + '/' + jar.getName() + "'/>\n"); |
290 |
|
303 |
|
291 |
processExtensions(jar, theJar.getManifest(), writeJNLP, dashcnb, codebase); |
304 |
processExtensions(jar, theJar.getManifest(), writeJNLP, dashcnb, codebase); |
292 |
processIndirectJars(writeJNLP, dashcnb, codebase); |
305 |
processIndirectJars(writeJNLP, dashcnb); |
|
|
306 |
processIndirectFiles(writeJNLP, dashcnb); |
293 |
|
307 |
|
294 |
writeJNLP.write(" </resources>\n"); |
308 |
writeJNLP.write(" </resources>\n"); |
295 |
|
309 |
|
Lines 334-340
Link Here
|
334 |
|
348 |
|
335 |
} |
349 |
} |
336 |
|
350 |
|
337 |
private Map<String,List<File>> verifyExtensions(File f, Manifest mf, String dashcnb, String codebasename, boolean verify, Set<String> indirectJarPaths) throws IOException, BuildException { |
351 |
private Map<String,List<File>> verifyExtensions(File f, Manifest mf, String dashcnb, String codebasename, boolean verify, Set<String> indirectFilePaths) throws IOException, BuildException { |
338 |
Map<String,List<File>> localizedFiles = new HashMap<String,List<File>>(); |
352 |
Map<String,List<File>> localizedFiles = new HashMap<String,List<File>>(); |
339 |
|
353 |
|
340 |
|
354 |
|
Lines 403-409
Link Here
|
403 |
|
417 |
|
404 |
fileToOwningModule.remove("ant/nblib/" + dashcnb + ".jar"); |
418 |
fileToOwningModule.remove("ant/nblib/" + dashcnb + ".jar"); |
405 |
|
419 |
|
406 |
fileToOwningModule.keySet().removeAll(indirectJarPaths); |
420 |
fileToOwningModule.keySet().removeAll(indirectFilePaths); |
407 |
|
421 |
|
408 |
if (verifyExcludes != null) { |
422 |
if (verifyExcludes != null) { |
409 |
StringTokenizer tok = new StringTokenizer(verifyExcludes, ", "); |
423 |
StringTokenizer tok = new StringTokenizer(verifyExcludes, ", "); |
Lines 515-521
Link Here
|
515 |
} |
529 |
} |
516 |
} |
530 |
} |
517 |
|
531 |
|
518 |
private void processIndirectJars(Writer fileWriter, String dashcnb, String codebase) throws IOException, BuildException { |
532 |
private void processIndirectJars(Writer fileWriter, String dashcnb) throws IOException, BuildException { |
519 |
if (indirectJars == null) { |
533 |
if (indirectJars == null) { |
520 |
return; |
534 |
return; |
521 |
} |
535 |
} |
Lines 523-529
Link Here
|
523 |
for (String f : scan.getIncludedFiles()) { |
537 |
for (String f : scan.getIncludedFiles()) { |
524 |
File jar = new File(scan.getBasedir(), f); |
538 |
File jar = new File(scan.getBasedir(), f); |
525 |
String rel = f.replace(File.separatorChar, '/'); |
539 |
String rel = f.replace(File.separatorChar, '/'); |
526 |
String sig = isSigned(jar); |
540 |
String sig; |
|
|
541 |
try { |
542 |
sig = isSigned(jar); |
543 |
} catch (IOException x) { |
544 |
throw new BuildException("Cannot check signature on " + jar, x, getLocation()); |
545 |
} |
527 |
// javaws will reject .zip files even with signatures. |
546 |
// javaws will reject .zip files even with signatures. |
528 |
String rel2 = rel.endsWith(".jar") ? rel : rel.replaceFirst("(\\.zip)?$", ".jar"); |
547 |
String rel2 = rel.endsWith(".jar") ? rel : rel.replaceFirst("(\\.zip)?$", ".jar"); |
529 |
File ext = new File(new File(targetFile, dashcnb), rel2.replace('/', '-').replaceFirst("^modules-", "")); |
548 |
File ext = new File(new File(targetFile, dashcnb), rel2.replace('/', '-').replaceFirst("^modules-", "")); |
Lines 549-554
Link Here
|
549 |
} |
568 |
} |
550 |
} |
569 |
} |
551 |
|
570 |
|
|
|
571 |
private void processIndirectFiles(Writer fileWriter, String dashcnb) throws IOException, BuildException { |
572 |
if (indirectFiles == null) { |
573 |
return; |
574 |
} |
575 |
DirectoryScanner scan = indirectFiles.getDirectoryScanner(getProject()); |
576 |
Map<String,File> entries = new LinkedHashMap<String,File>(); |
577 |
for (String f : scan.getIncludedFiles()) { |
578 |
entries.put(f.replace(File.separatorChar, '/'), new File(scan.getBasedir(), f)); |
579 |
} |
580 |
if (entries.isEmpty()) { |
581 |
return; |
582 |
} |
583 |
File ext = new File(new File(targetFile, dashcnb), "extra-files.jar"); |
584 |
Zip jartask = (Zip) getProject().createTask("jar"); |
585 |
jartask.setDestFile(ext); |
586 |
for (Map.Entry<String,File> entry : entries.entrySet()) { |
587 |
ZipFileSet zfs = new ZipFileSet(); |
588 |
zfs.setFile(entry.getValue()); |
589 |
zfs.setFullpath("META-INF/files/" + entry.getKey()); |
590 |
jartask.addZipfileset(zfs); |
591 |
} |
592 |
jartask.execute(); |
593 |
fileWriter.write(" <jar href='" + dashcnb + '/' + ext.getName() + "'/>\n"); |
594 |
signOrCopy(ext, null); |
595 |
} |
596 |
|
552 |
private static String relative(File file, File root) { |
597 |
private static String relative(File file, File root) { |
553 |
String sfile = file.toString().replace(File.separatorChar, '/'); |
598 |
String sfile = file.toString().replace(File.separatorChar, '/'); |
554 |
String sroot = (root.toString() + File.separator).replace(File.separatorChar, '/'); |
599 |
String sroot = (root.toString() + File.separator).replace(File.separatorChar, '/'); |