Index: ide/applemenu/manifest.mf =================================================================== RCS file: /cvs/ide/applemenu/manifest.mf,v retrieving revision 1.1 diff -u -r1.1 manifest.mf --- ide/applemenu/manifest.mf 8 Jun 2004 12:46:02 -0000 1.1 +++ ide/applemenu/manifest.mf 2 Aug 2004 14:22:06 -0000 @@ -4,6 +4,7 @@ OpenIDE-Module-Install: org/netbeans/modules/applemenu/Install.class OpenIDE-Module-Layer: org/netbeans/modules/applemenu/layer.xml OpenIDE-Module-Specification-Version: 1.1 +OpenIDE-Module-Requires: org.openide.modules.os.MacOSX Index: ide/applemenu/nbproject/project.properties =================================================================== RCS file: /cvs/ide/applemenu/nbproject/project.properties,v retrieving revision 1.1 diff -u -r1.1 project.properties --- ide/applemenu/nbproject/project.properties 8 Jun 2004 12:46:08 -0000 1.1 +++ ide/applemenu/nbproject/project.properties 2 Aug 2004 14:22:06 -0000 @@ -11,3 +11,4 @@ nbm.needs.restart=true cp.extra=eawtstub/dist/eawtstub.jar +is.eager=true Index: core/src/org/netbeans/core/modules/Module.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/modules/Module.java,v retrieving revision 1.54 diff -u -r1.54 Module.java --- core/src/org/netbeans/core/modules/Module.java 29 Jul 2004 18:35:01 -0000 1.54 +++ core/src/org/netbeans/core/modules/Module.java 2 Aug 2004 14:22:06 -0000 @@ -438,6 +438,18 @@ throw new IllegalArgumentException("Duplicate entries in OpenIDE-Module-Provides: " + providesS); // NOI18N } } + String[] additionalProvides = mgr.refineProvides (this); + if (additionalProvides != null) { + if (provides == null) { + provides = additionalProvides; + } else { + ArrayList l = new ArrayList (); + l.addAll (Arrays.asList (provides)); + l.addAll (Arrays.asList (additionalProvides)); + provides = (String[])l.toArray (provides); + } + } + // Exports String exportsS = attr.getValue("OpenIDE-Module-Public-Packages"); // NOI18N if (exportsS != null) { Index: core/src/org/netbeans/core/modules/ModuleInstaller.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/modules/ModuleInstaller.java,v retrieving revision 1.9 diff -u -r1.9 ModuleInstaller.java --- core/src/org/netbeans/core/modules/ModuleInstaller.java 18 Dec 2002 23:41:29 -0000 1.9 +++ core/src/org/netbeans/core/modules/ModuleInstaller.java 2 Aug 2004 14:22:06 -0000 @@ -156,6 +156,14 @@ public void refineClassLoader(Module m, List parents) { // do nothing } + + /** Optionally adds additional token for the module. + * @param m the module to add token to + * @return null or list of tokens this module provides + */ + public String[] refineProvides (Module m) { + return null; + } /** Is this package special in that the package domain cache should be disabled for it? * The result must never change between subsequent calls for the same argument. Index: core/src/org/netbeans/core/modules/ModuleManager.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/modules/ModuleManager.java,v retrieving revision 1.62 diff -u -r1.62 ModuleManager.java --- core/src/org/netbeans/core/modules/ModuleManager.java 2 Jul 2003 18:56:33 -0000 1.62 +++ core/src/org/netbeans/core/modules/ModuleManager.java 2 Aug 2004 14:22:06 -0000 @@ -500,6 +500,11 @@ void refineDependencies(Module m, Set dependencies) { installer.refineDependencies(m, dependencies); } + /** Allows the installer to add provides (used to provide name of platform we run on) + */ + String[] refineProvides (Module m) { + return installer.refineProvides (m); + } /** Used by Module to communicate with the ModuleInstaller re. classloader. */ void refineClassLoader(Module m, List parents) { // #27853: Index: core/src/org/netbeans/core/modules/NbInstaller.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/modules/NbInstaller.java,v retrieving revision 1.76 diff -u -r1.76 NbInstaller.java --- core/src/org/netbeans/core/modules/NbInstaller.java 16 May 2004 16:09:20 -0000 1.76 +++ core/src/org/netbeans/core/modules/NbInstaller.java 2 Aug 2004 14:22:07 -0000 @@ -721,6 +721,21 @@ } } + public String[] refineProvides (Module m) { + String token = null; + if (m.getCodeNameBase ().equals ("org.openide")) { // NOI18N + if (org.openide.util.Utilities.isUnix ()) { + token = "org.openide.modules.os.Unix"; // NOI18N + } else if (org.openide.util.Utilities.isWindows ()) { + token = "org.openide.modules.os.Windows"; // NOI18N + } else if ((org.openide.util.Utilities.getOperatingSystem () & org.openide.util.Utilities.OS_MAC) != 0) { + token = "org.openide.modules.os.MacOSX"; // NOI18N + } + } + return token == null ? null : new String[] { token }; + } + + private void addLoadersRecursively(List parents, Dependency[] deps, Set parentModules, Module master, Set addedParentNames) { for (int i = 0; i < deps.length; i++) { if (deps[i].getType() != Dependency.TYPE_MODULE) { Index: core/test/unit/src/org/netbeans/core/modules/PlatformDependencySatisfied.java =================================================================== RCS file: core/test/unit/src/org/netbeans/core/modules/PlatformDependencySatisfied.java diff -N core/test/unit/src/org/netbeans/core/modules/PlatformDependencySatisfied.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ core/test/unit/src/org/netbeans/core/modules/PlatformDependencySatisfied.java 2 Aug 2004 14:22:07 -0000 @@ -0,0 +1,88 @@ +/* + * Sun Public License Notice + * + * The contents of this file are subject to the Sun Public License + * Version 1.0 (the "License"). You may not use this file except in + * compliance with the License. A copy of the License is available at + * http://www.sun.com/ + * + * The Original Code is NetBeans. The Initial Developer of the Original + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun + * Microsystems, Inc. All Rights Reserved. + */ + +package org.netbeans.core.modules; + +import java.io.*; +import java.io.File; +import java.util.Collections; +import java.util.Locale; +import java.util.jar.*; +import org.netbeans.junit.*; +import junit.textui.TestRunner; +import org.openide.filesystems.Repository; +import org.netbeans.core.NbTopManager; + +/** Checks whether a module with generated + * @author Jaroslav Tulach + */ +public class PlatformDependencySatisfied extends SetupHid { + private File moduleJarFile; + + public PlatformDependencySatisfied(String name) { + super(name); + } + + public static void main(String[] args) { + TestRunner.run(new NbTestSuite(PlatformDependencySatisfied.class)); + } + + protected void setUp() throws Exception { + super.setUp(); + System.setProperty("org.netbeans.core.modules.NbInstaller.noAutoDeps", "true"); + + File tmp = File.createTempFile ("PlatformDependencySatisfiedModule", ".jar"); + moduleJarFile = tmp; + + Manifest man = new Manifest (); + man.getMainAttributes ().putValue ("Manifest-Version", "1.0"); + man.getMainAttributes ().putValue ("OpenIDE-Module", "org.test.PlatformDependency/1"); + + String req = null; + if (org.openide.util.Utilities.isWindows ()) { + req = "org.openide.modules.os.Windows"; + } else if (org.openide.util.Utilities.isUnix ()) { + req = "org.openide.modules.os.Unix"; + } else if ((org.openide.util.Utilities.getOperatingSystem () & org.openide.util.Utilities.OS_MAC) != 0) { + req = "org.openide.modules.os.MacOSX"; + } + assertNotNull ("This test is supposed to run on windows, unix and macosx, fail otherwise on this line", req); + + man.getMainAttributes ().putValue ("OpenIDE-Module-Requires", req); + + JarOutputStream os = new JarOutputStream (new FileOutputStream (tmp), man); + os.putNextEntry (new JarEntry ("empty/test.txt")); + os.close (); + } + + /** */ + public void testTryToInstallTheModuleWhichRequiresTheOS () throws Exception { + NbTopManager.get(); // init module system + final FakeEvents ev = new FakeEvents(); + NbInstaller installer = new NbInstaller(ev); + ModuleManager mgr = new ModuleManager(installer, ev); + installer.registerManager(mgr); + mgr.mutexPrivileged().enterWriteAccess(); + try { + addOpenide(mgr); + Module m1 = mgr.create(moduleJarFile, null, false, false, false); + assertEquals(Collections.EMPTY_SET, m1.getProblems()); + mgr.enable(m1); + mgr.disable(m1); + mgr.delete(m1); + } finally { + mgr.mutexPrivileged().exitWriteAccess(); + } + } + +}