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

(-)a/apisupport.harness/jnlp-src/org/netbeans/modules/apisupport/jnlplauncher/InstalledFileLocatorImpl.java (-2 / +32 lines)
Lines 42-58 Link Here
42
package org.netbeans.modules.apisupport.jnlplauncher;
42
package org.netbeans.modules.apisupport.jnlplauncher;
43
43
44
import java.io.File;
44
import java.io.File;
45
import java.io.FileOutputStream;
46
import java.io.IOException;
47
import java.io.InputStream;
48
import java.io.OutputStream;
45
import java.net.URI;
49
import java.net.URI;
46
import java.net.URL;
50
import java.net.URL;
47
import java.util.Iterator;
51
import java.util.Iterator;
48
import org.openide.modules.InstalledFileLocator;
52
import org.openide.modules.InstalledFileLocator;
53
import org.openide.util.Exceptions;
49
import org.openide.util.NbBundle;
54
import org.openide.util.NbBundle;
50
import org.openide.util.lookup.ServiceProvider;
55
import org.openide.util.lookup.ServiceProvider;
51
56
52
/**
57
/**
53
 * Special locator for JNLP mode.
58
 * Special locator for JNLP mode.
54
 * Currently just locates JARs with the special META-INF/clusterpath/$relpath
59
 * Locates files in userdir; JARs with the special META-INF/clusterpath/$relpath entry;
55
 * entry inserted by common.xml -> <makenjnlp>.
60
 * and JARs present in extra-files.jar.
56
 * @author Jesse Glick
61
 * @author Jesse Glick
57
 */
62
 */
58
@ServiceProvider(service=InstalledFileLocator.class, supersedes="org.netbeans.core.startup.InstalledFileLocatorImpl")
63
@ServiceProvider(service=InstalledFileLocator.class, supersedes="org.netbeans.core.startup.InstalledFileLocatorImpl")
Lines 103-108 Link Here
103
                    }
108
                    }
104
                }
109
                }
105
            }
110
            }
111
            try {
112
                InputStream is = loader.getResourceAsStream("META-INF/files/" + relativePath);
113
                if (is != null) {
114
                    try {
115
                        // XXX could try to cache previously created files
116
                        File temp = File.createTempFile("nbjnlp-", relativePath.replaceFirst("^.+/", ""));
117
                        temp.deleteOnExit();
118
                        OutputStream os = new FileOutputStream(temp);
119
                        try {
120
                            byte[] buf = new byte[4096];
121
                            int read;
122
                            while ((read = is.read(buf)) != -1) {
123
                                os.write(buf, 0, read);
124
                            }
125
                        } finally {
126
                            os.close();
127
                        }
128
                        return temp;
129
                    } finally {
130
                        is.close();
131
                    }
132
                }
133
            } catch (IOException x) {
134
                Exceptions.printStackTrace(x);
135
            }
106
        }
136
        }
107
        return null;
137
        return null;
108
    }
138
    }
(-)a/apisupport.harness/release/README (+9 lines)
Lines 855-860 Link Here
855
  entry META-INF/clusterpath/$path where $path is the ('/'-separated) path
855
  entry META-INF/clusterpath/$path where $path is the ('/'-separated) path
856
  within the cluster where the JAR would be found in a normal installation.
856
  within the cluster where the JAR would be found in a normal installation.
857
857
858
jnlp.indirect.files [since 7.0M1] - optional pattern of files in the cluster to
859
  load in JNLP mode. The module may load these files using InstalledFileLocator
860
  using the same path in regular as in JNLP mode. Note that the physical path on
861
  disk to the resulting file will not necessarily contain the directory prefix
862
  that the file in the cluster uses, so do not expect that file.getParentFile()
863
  is meaningful. The implementation creates a JAR entry META-INF/files/$path
864
  where $path is the ('/'-separated) path within the cluster where the file
865
  would be found in a normal installation.
866
858
jnlp.verify.excludes - the default implementation of "jnlp" task in common.xml
867
jnlp.verify.excludes - the default implementation of "jnlp" task in common.xml
859
  does verification and compares that all files from module NBM are really
868
  does verification and compares that all files from module NBM are really
860
  referenced from the JNLP file. Sometimes not all of them need to be, for
869
  referenced from the JNLP file. Sometimes not all of them need to be, for
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/MakeJNLP.java (-14 / +59 lines)
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, '/');
(-)a/nbbuild/templates/common.xml (+3 lines)
Lines 283-288 Link Here
283
            <available file="${jnlp.signjar.keystore}"/>
283
            <available file="${jnlp.signjar.keystore}"/>
284
        </condition>
284
        </condition>
285
        <property name="jnlp.sign.jars" value="false"/>
285
        <property name="jnlp.sign.jars" value="false"/>
286
        <property name="jnlp.indirect.jars" value="[NOTHING]"/>
287
        <property name="jnlp.indirect.files" value="[NOTHING]"/>
286
    </target>
288
    </target>
287
289
288
    <target name="jnlp" depends="init,netbeans,jnlp-master,-jnlp-init" description="Builds JNLP descriptor and signs JAR files" >
290
    <target name="jnlp" depends="init,netbeans,jnlp-master,-jnlp-init" description="Builds JNLP descriptor and signs JAR files" >
Lines 301-306 Link Here
301
                <include name="${module.jar}" />
303
                <include name="${module.jar}" />
302
            </modules>
304
            </modules>
303
            <indirectjars dir="${cluster}" includes="${jnlp.indirect.jars}"/>
305
            <indirectjars dir="${cluster}" includes="${jnlp.indirect.jars}"/>
306
            <indirectfiles dir="${cluster}" includes="${jnlp.indirect.files}"/>
304
        </makejnlp>
307
        </makejnlp>
305
    </target>
308
    </target>
306
309

Return to bug 154471