Index: ant/build.xml =================================================================== RCS file: /shared/data/ccvs/repository/ant/build.xml,v retrieving revision 1.121 diff -u -r1.121 build.xml --- ant/build.xml 2 Dec 2006 23:59:02 -0000 1.121 +++ ant/build.xml 3 Dec 2006 21:48:54 -0000 @@ -95,34 +95,35 @@ - - + + + - + - + - + - + - + - + @@ -134,9 +135,9 @@ - - - + + + Index: apisupport/harness/build.xml =================================================================== RCS file: /shared/data/ccvs/repository/apisupport/harness/build.xml,v retrieving revision 1.14 diff -u -r1.14 build.xml --- apisupport/harness/build.xml 17 Oct 2006 13:49:34 -0000 1.14 +++ apisupport/harness/build.xml 3 Dec 2006 21:48:55 -0000 @@ -37,7 +37,7 @@ - + Index: apisupport/harness/jnlp-src/META-INF/services/org.openide.modules.InstalledFileLocator =================================================================== RCS file: apisupport/harness/jnlp-src/META-INF/services/org.openide.modules.InstalledFileLocator diff -N apisupport/harness/jnlp-src/META-INF/services/org.openide.modules.InstalledFileLocator --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apisupport/harness/jnlp-src/META-INF/services/org.openide.modules.InstalledFileLocator 3 Dec 2006 21:48:55 -0000 @@ -0,0 +1,2 @@ +#-org.netbeans.core.startup.InstalledFileLocatorImpl +org.netbeans.modules.apisupport.jnlplauncher.InstalledFileLocatorImpl Index: apisupport/harness/jnlp-src/org/netbeans/modules/apisupport/jnlplauncher/InstalledFileLocatorImpl.java =================================================================== RCS file: apisupport/harness/jnlp-src/org/netbeans/modules/apisupport/jnlplauncher/InstalledFileLocatorImpl.java diff -N apisupport/harness/jnlp-src/org/netbeans/modules/apisupport/jnlplauncher/InstalledFileLocatorImpl.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ apisupport/harness/jnlp-src/org/netbeans/modules/apisupport/jnlplauncher/InstalledFileLocatorImpl.java 3 Dec 2006 21:48:55 -0000 @@ -0,0 +1,86 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.modules.apisupport.jnlplauncher; + +import java.io.File; +import java.net.URI; +import java.net.URL; +import java.util.Iterator; +import org.openide.modules.InstalledFileLocator; +import org.openide.util.NbBundle; + +/** + * Special locator for JNLP mode. + * Currently just locates JARs with the special META-INF/exists/$relpath + * entry inserted by common.xml -> . + * @author Jesse Glick + */ +public class InstalledFileLocatorImpl extends InstalledFileLocator { + + public InstalledFileLocatorImpl() {} + + public File locate(String relativePath, String codeNameBase, boolean localized) { + if (localized) { + int i = relativePath.lastIndexOf('.'); + String baseName, ext; + if (i == -1 || i < relativePath.lastIndexOf('/')) { + baseName = relativePath; + ext = ""; + } else { + baseName = relativePath.substring(0, i); + ext = relativePath.substring(i); + } + Iterator it = NbBundle.getLocalizingSuffixes(); + while (it.hasNext()) { + String locName = baseName + it.next() + ext; + File f = locate(locName, codeNameBase, false); + if (f != null) { + return f; + } + } + } else { + String userdir = System.getProperty("netbeans.user"); + if (userdir != null) { + File f = new File(userdir, relativePath.replace('/', File.separatorChar)); + if (f.exists()) { + return f; + } + } + String resource = "META-INF/exists/" + relativePath; + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + URL found = loader.getResource(resource); + if (found != null) { + String foundS = found.toExternalForm(); + String prefix = "jar:"; + String suffix = "!/" + resource; + if (foundS.startsWith(prefix) && foundS.endsWith(suffix)) { + String infix = foundS.substring(prefix.length(), foundS.length() - suffix.length()); + if (infix.startsWith("file:")) { + File jar = new File(URI.create(infix)); + assert jar.isFile(); + return jar; + } + } + } + } + return null; + } + +} Index: apisupport/harness/nbproject/project.properties =================================================================== RCS file: /shared/data/ccvs/repository/apisupport/harness/nbproject/project.properties,v retrieving revision 1.21 diff -u -r1.21 project.properties --- apisupport/harness/nbproject/project.properties 17 Oct 2006 13:49:34 -0000 1.21 +++ apisupport/harness/nbproject/project.properties 3 Dec 2006 21:48:55 -0000 @@ -15,7 +15,10 @@ # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. -jnlp.cp=${core/bootstrap.dir}/lib/boot.jar +jnlp.cp=\ + ${core/bootstrap.dir}/lib/boot.jar:\ + ${openide/modules.dir}/lib/org-openide-modules.jar:\ + ${openide/util.dir}/lib/org-openide-util.jar extra.module.files=\ jnlp/jnlp-launcher.jar,\ Index: apisupport/harness/nbproject/project.xml =================================================================== RCS file: /shared/data/ccvs/repository/apisupport/harness/nbproject/project.xml,v retrieving revision 1.8 diff -u -r1.8 project.xml --- apisupport/harness/nbproject/project.xml 30 Jun 2006 18:12:05 -0000 1.8 +++ apisupport/harness/nbproject/project.xml 3 Dec 2006 21:48:55 -0000 @@ -38,6 +38,7 @@ ${jnlp.cp} build/jnlp-launcher-classes ${cluster}/jnlp/jnlp-launcher.jar + 1.5 Index: apisupport/harness/release/README =================================================================== RCS file: /shared/data/ccvs/repository/apisupport/harness/release/README,v retrieving revision 1.52 diff -u -r1.52 README --- apisupport/harness/release/README 2 Dec 2006 19:44:07 -0000 1.52 +++ apisupport/harness/release/README 3 Dec 2006 21:49:01 -0000 @@ -807,6 +807,15 @@ http://www.netbeans.org/download/6_0/jnlp/ http://deadlock.nbextras.org/hudson/job/javadoc-nbms/lastSuccessfulBuild/artifact/nbbuild/build/jnlp/ +jnlp.indirect.jars [since 6.0] - optional pattern of JARs in the cluster to load + in JNLP mode even though they are not listed as Class-Path extensions of the + module JAR. The module ought not directly refer to classes in these JARs (it + could not do so in non-JNLP mode) but it may load them reflectively using + InstalledFileLocator using the same path in regular as in JNLP mode. Note that + the physical path on disk to the resulting JAR will not necessarily contain + the directory prefix that the JAR in the cluster uses, so do not expect that + jar.getParentFile() is meaningful. + jnlp.verify.excludes - the default implementation of "jnlp" task in common.xml does verification and compares that all files from module NBM are really referenced from the JNLP file. Sometimes not all of them need to be, for Index: apisupport/harness/release/jnlp.xml =================================================================== RCS file: /shared/data/ccvs/repository/apisupport/harness/release/jnlp.xml,v retrieving revision 1.39 diff -u -r1.39 jnlp.xml --- apisupport/harness/release/jnlp.xml 21 Nov 2006 14:24:32 -0000 1.39 +++ apisupport/harness/release/jnlp.xml 3 Dec 2006 21:49:01 -0000 @@ -185,6 +185,7 @@ + Index: extbrowser/build.xml =================================================================== RCS file: /shared/data/ccvs/repository/extbrowser/build.xml,v retrieving revision 1.42 diff -u -r1.42 build.xml --- extbrowser/build.xml 30 Jun 2006 19:24:01 -0000 1.42 +++ extbrowser/build.xml 3 Dec 2006 21:49:01 -0000 @@ -18,5 +18,42 @@ Microsystems, Inc. All Rights Reserved. --> + + + + + + + + + + + + + + + + + + + + + + ${OpenIDE-Module-Name} + NetBeans + ${OpenIDE-Module-Short-Description} + ${OpenIDE-Module-Long-Description} + + + + + + + + + ]]> + + + Index: java/j2seplatform/nbproject/project.properties =================================================================== RCS file: /shared/data/ccvs/repository/java/j2seplatform/nbproject/project.properties,v retrieving revision 1.19 diff -u -r1.19 project.properties --- java/j2seplatform/nbproject/project.properties 15 Aug 2006 16:10:51 -0000 1.19 +++ java/j2seplatform/nbproject/project.properties 3 Dec 2006 21:49:01 -0000 @@ -18,6 +18,6 @@ javac.compilerargs=-Xlint:unchecked spec.version.base=1.7.0 extra.module.files=modules/ext/org-netbeans-modules-java-j2seplatform-probe.jar +jnlp.indirect.jars=modules/ext/org-netbeans-modules-java-j2seplatform-probe.jar javadoc.arch=${basedir}/arch.xml - Index: java/j2seproject/nbproject/project.properties =================================================================== RCS file: /shared/data/ccvs/repository/java/j2seproject/nbproject/project.properties,v retrieving revision 1.34 diff -u -r1.34 project.properties --- java/j2seproject/nbproject/project.properties 29 Nov 2006 23:20:18 -0000 1.34 +++ java/j2seproject/nbproject/project.properties 3 Dec 2006 21:49:01 -0000 @@ -27,3 +27,4 @@ test-unit-sys-prop.test.ant.home=${cluster}/ant test-unit-sys-prop.test.junit.jar=${junit.dir}/modules/ext/junit-3.8.2.jar extra.module.files=ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar +jnlp.indirect.jars=ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar Index: junit/nbproject/project.properties =================================================================== RCS file: /shared/data/ccvs/repository/junit/nbproject/project.properties,v retrieving revision 1.10 diff -u -r1.10 project.properties --- junit/nbproject/project.properties 16 Aug 2006 06:28:27 -0000 1.10 +++ junit/nbproject/project.properties 3 Dec 2006 21:49:01 -0000 @@ -24,3 +24,6 @@ extra.module.files=\ docs/junit-3.8.2-api.zip,\ modules/ext/junit*.jar +jnlp.indirect.jars=\ + docs/junit-3.8.2-api.zip,\ + modules/ext/junit*.jar Index: nbbuild/build.properties =================================================================== RCS file: /shared/data/ccvs/repository/nbbuild/build.properties,v retrieving revision 1.433 diff -u -r1.433 build.properties --- nbbuild/build.properties 2 Dec 2006 07:30:11 -0000 1.433 +++ nbbuild/build.properties 3 Dec 2006 21:49:01 -0000 @@ -351,11 +351,9 @@ # list of modules for jnlp: config.fixedmodules.jnlp= -config.modules.jnlp=${nb.cluster.platform},\ - ${nb.pkg.ideextensions},\ - ${nb.pkg.idesupport},\ - ant,\ - ant/browsetask +config.modules.jnlp=\ + ${nb.cluster.platform},\ + ${nb.cluster.ide} # commit validation test depencies config.commit.validation=openide/windows,\ Index: nbbuild/antsrc/org/netbeans/nbbuild/MakeJNLP.java =================================================================== RCS file: /shared/data/ccvs/repository/nbbuild/antsrc/org/netbeans/nbbuild/MakeJNLP.java,v retrieving revision 1.20 diff -u -r1.20 MakeJNLP.java --- nbbuild/antsrc/org/netbeans/nbbuild/MakeJNLP.java 6 Nov 2006 16:37:16 -0000 1.20 +++ nbbuild/antsrc/org/netbeans/nbbuild/MakeJNLP.java 3 Dec 2006 21:49:01 -0000 @@ -26,12 +26,15 @@ import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.StringTokenizer; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -46,7 +49,9 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Copy; import org.apache.tools.ant.taskdefs.SignJar; +import org.apache.tools.ant.taskdefs.Zip; import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.ZipFileSet; import org.xml.sax.SAXException; /** Generates JNLP files for signed versions of the module JAR files. @@ -116,6 +121,19 @@ permissions = s; } + private FileSet indirectJars; + /** + * Other JARs which should be copied into the destination directory and referred to as resources, + * even though they are not listed as Class-Path extensions of the module and would not normally + * be in its effective classpath. The basedir of the fileset should be a cluster root; for each + * such JAR, a file META-INF/exists/$relpath will be inserted in the JAR, where $relpath is the + * relative path within the cluster. This permits the JAR to be located at runtime in a flat classpath, + * using ClassLoader.getResource. + */ + public void addIndirectJars(FileSet fs) { + indirectJars = fs; + } + public void execute() throws BuildException { if (target == null) throw new BuildException("Output dir must be provided"); if (files == null) throw new BuildException("modules must be provided"); @@ -128,6 +146,15 @@ } private void generateFiles() throws IOException, BuildException { + Set indirectJarPaths = Collections.emptySet(); + if (indirectJars != null) { + DirectoryScanner scan = indirectJars.getDirectoryScanner(getProject()); + indirectJarPaths = new HashSet(); + for (String f : scan.getIncludedFiles()) { + indirectJarPaths.add(f.replace(File.pathSeparatorChar, '/')); + } + } + DirectoryScanner scan = files.getDirectoryScanner(getProject()); for (String f : scan.getIncludedFiles()) { File jar = new File (files.getDir(getProject()), f); @@ -170,10 +197,11 @@ shrt = prop.getProperty("OpenIDE-Module-Long-Description", oneline); } - Map> localizedFiles = verifyExtensions(jar, theJar.getManifest(), dashcnb, codenamebase, verify); + Map> localizedFiles = verifyExtensions(jar, theJar.getManifest(), dashcnb, codenamebase, verify, indirectJarPaths); + new File(target, dashcnb).mkdir(); - File signed = new File(target, jar.getName()); + File signed = new File(new File(target, dashcnb), jar.getName()); File jnlp = new File(target, dashcnb + ".jnlp"); StringWriter writeJNLP = new StringWriter(); @@ -187,9 +215,10 @@ writeJNLP.write(" \n"); writeJNLP.write(permissions +"\n"); writeJNLP.write(" \n"); - writeJNLP.write(" \n"); + writeJNLP.write(" \n"); processExtensions(jar, theJar.getManifest(), writeJNLP, dashcnb, codebase); + processIndirectJars(writeJNLP, dashcnb, codebase); writeJNLP.write(" \n"); @@ -202,13 +231,13 @@ writeJNLP.write(" \n"); for (File n : files) { - File t = new File(target, n.getName()); + File t = new File(new File(target, dashcnb), n.getName()); getSignTask().setJar(n); getSignTask().setSignedjar(t); getSignTask().execute(); - writeJNLP.write(" \n"); + writeJNLP.write(" \n"); } writeJNLP.write(" \n"); @@ -234,7 +263,7 @@ } - private Map> verifyExtensions(File f, Manifest mf, String dashcnb, String codebasename, boolean verify) throws IOException, BuildException { + private Map> verifyExtensions(File f, Manifest mf, String dashcnb, String codebasename, boolean verify, Set indirectJarPaths) throws IOException, BuildException { Map> localizedFiles = new HashMap>(); @@ -302,6 +331,8 @@ } fileToOwningModule.remove("ant/nblib/" + dashcnb + ".jar"); + + fileToOwningModule.keySet().removeAll(indirectJarPaths); if (verifyExcludes != null) { StringTokenizer tok = new StringTokenizer(verifyExcludes, ", "); @@ -352,10 +383,9 @@ private void processExtensions(File f, Manifest mf, Writer fileWriter, String dashcnb, String codebase) throws IOException, BuildException { File nblibJar = new File(new File(new File(f.getParentFile().getParentFile(), "ant"), "nblib"), dashcnb + ".jar"); - //System.err.println(nblibJar + ".isFile=" + nblibJar.isFile()); if (nblibJar.isFile()) { - File ext = new File(target, "ant-nblib-" + nblibJar.getName()); - fileWriter.write(" \n"); + File ext = new File(new File(target, dashcnb), "ant-nblib-" + nblibJar.getName()); + fileWriter.write(" \n"); getSignTask().setJar(nblibJar); getSignTask().setSignedjar(ext); getSignTask().execute(); @@ -379,36 +409,36 @@ n = n.substring(0, n.length() - 4); } - if (isSigned (e)) { + if (isSigned(e) != null) { Copy copy = (Copy)getProject().createTask("copy"); copy.setFile(e); - File t = new File(target, e.getName()); + File t = new File(new File(target, dashcnb), s.replace('/', '-')); copy.setTofile(t); copy.execute(); - String extJnlpName = dashcnb + "-ext-" + n + ".jnlp"; - File jnlp = new File(target, extJnlpName); + String extJnlpName = t.getName().replaceFirst("\\.jar$", "") + ".jnlp"; + File jnlp = new File(new File(target, dashcnb), extJnlpName); FileWriter writeJNLP = new FileWriter(jnlp); writeJNLP.write("\n"); writeJNLP.write("\n"); writeJNLP.write(" \n"); - writeJNLP.write(" " + n + "\n"); - writeJNLP.write(" NetBeans\n"); + writeJNLP.write(" " + n + "\n"); + writeJNLP.write(" NetBeans\n"); writeJNLP.write(" \n"); writeJNLP.write(permissions +"\n"); writeJNLP.write(" \n"); - writeJNLP.write(" \n"); + writeJNLP.write(" \n"); writeJNLP.write(" \n"); writeJNLP.write(" \n"); writeJNLP.write("\n"); writeJNLP.close(); - fileWriter.write(" \n"); + fileWriter.write(" \n"); } else { - File ext = new File(target, e.getName()); + File ext = new File(new File(target, dashcnb), s.replace('/', '-')); - fileWriter.write(" \n"); + fileWriter.write(" \n"); getSignTask().setJar(e); getSignTask().setSignedjar(ext); @@ -416,6 +446,39 @@ } } } + + private void processIndirectJars(Writer fileWriter, String dashcnb, String codebase) throws IOException, BuildException { + DirectoryScanner scan = indirectJars.getDirectoryScanner(getProject()); + for (String f : scan.getIncludedFiles()) { + File jar = new File(scan.getBasedir(), f); + String rel = f.replace(File.separatorChar, '/'); + String sig = isSigned(jar); + // javaws will reject .zip files even with signatures. + String rel2 = rel.endsWith(".jar") ? rel : rel.replaceFirst("(\\.zip)?$", ".jar"); + File ext = new File(new File(target, dashcnb), rel2.replace('/', '-').replaceFirst("^modules-", "")); + Zip jartask = (Zip) getProject().createTask("jar"); + jartask.setDestFile(ext); + ZipFileSet zfs = new ZipFileSet(); + zfs.setSrc(jar); + if (sig != null) { + // Need to cancel original signature since we are adding one entry to the JAR. + zfs.setExcludes("META-INF/" + sig + ".*"); + } + jartask.addZipfileset(zfs); + zfs = new ZipFileSet(); + File blank = File.createTempFile("empty", ""); + blank.deleteOnExit(); + zfs.setFile(blank); + zfs.setFullpath("META-INF/exists/" + rel); + jartask.addZipfileset(zfs); + jartask.execute(); + blank.delete(); + fileWriter.write(" \n"); + getSignTask().setJar(ext); + getSignTask().setSignedjar(null); + getSignTask().execute(); + } + } private static String relative(File file, File root) { String sfile = file.toString().replace(File.separatorChar, '/'); @@ -426,18 +489,22 @@ return sfile; } - private static boolean isSigned(File f) throws IOException { + /** return alias if signed, or null if not */ + private static String isSigned(File f) throws IOException { JarFile jar = new JarFile(f); - Enumeration en = jar.entries(); - while (en.hasMoreElements()) { - JarEntry e = en.nextElement(); - if (e.getName().endsWith(".SF")) { - jar.close(); - return true; + try { + Enumeration en = jar.entries(); + while (en.hasMoreElements()) { + Matcher m = SF.matcher(en.nextElement().getName()); + if (m.matches()) { + return m.group(1); + } } + return null; + } finally { + jar.close(); } - jar.close(); - return false; } + private static final Pattern SF = Pattern.compile("META-INF/(.+)\\.SF"); } Index: nbbuild/templates/common.xml =================================================================== RCS file: /shared/data/ccvs/repository/nbbuild/templates/common.xml,v retrieving revision 1.53 diff -u -r1.53 common.xml --- nbbuild/templates/common.xml 22 Oct 2006 18:52:13 -0000 1.53 +++ nbbuild/templates/common.xml 3 Dec 2006 21:49:15 -0000 @@ -259,6 +259,7 @@ + Index: websvc/jaxrpc16/nbproject/project.properties =================================================================== RCS file: /shared/data/ccvs/repository/websvc/jaxrpc16/nbproject/project.properties,v retrieving revision 1.3 diff -u -r1.3 project.properties --- websvc/jaxrpc16/nbproject/project.properties 30 Jun 2006 22:41:11 -0000 1.3 +++ websvc/jaxrpc16/nbproject/project.properties 3 Dec 2006 21:49:15 -0000 @@ -29,3 +29,4 @@ modules/ext/jaxrpc16/saaj-api.jar,\ modules/ext/jaxrpc16/saaj-impl.jar,\ modules/ext/jaxrpc16/xsdlib.jar +jnlp.indirect.jars=${extra.module.files} Index: websvc/jaxws20/nbproject/project.properties =================================================================== RCS file: /shared/data/ccvs/repository/websvc/jaxws20/nbproject/project.properties,v retrieving revision 1.4 diff -u -r1.4 project.properties --- websvc/jaxws20/nbproject/project.properties 16 Nov 2006 22:52:43 -0000 1.4 +++ websvc/jaxws20/nbproject/project.properties 3 Dec 2006 21:49:15 -0000 @@ -32,3 +32,10 @@ modules/ext/jaxws20/saaj-api.jar,\ modules/ext/jaxws20/saaj-impl.jar,\ modules/ext/jaxws20/sjsxp.jar +jnlp.indirect.jars=\ + modules/ext/jaxws20/FastInfoset.jar,\ + modules/ext/jaxws20/resolver.jar,\ + modules/ext/jaxws20/saaj-impl.jar,\ + modules/ext/jaxws20/saaj-api.jar,\ + modules/ext/jaxws20/jsr250-api.jar,\ + modules/ext/jaxws20/http.jar