protected State getBuildState() { State main = TargetPlatformHelper.getState(); if (fStateCopy == null) copyState(main); //this state is expected to get platform properties set by pde.build and re-resolved there. //TODO should main.getPlatformProperties() be passed to pde/build? return fStateCopy; }
private static final Set<String> getAvailableExportedPackages() { State state = TargetPlatformHelper.getState(); ExportPackageDescription[] packages = state.getExportedPackages(); Set<String> set = new HashSet<>(); for (ExportPackageDescription exportedPackage : packages) { set.add(exportedPackage.getName()); } return set; }
/** * @return a set of plug-in IDs * */ public static Set getDependencies(Object[] selected, boolean includeOptional) { return getDependencies(selected, getImplicitDependencies(), TargetPlatformHelper.getState(), true, includeOptional); }
/** * @return a set of plug-in IDs * */ public static Set getSelfAndDependencies(IPluginModelBase model) { return getDependencies(new Object[] {model}, getImplicitDependencies(), TargetPlatformHelper.getState(), false, true); }
/** * @return a set of plug-in IDs * */ public static Set getSelfandDependencies(IPluginModelBase[] models) { return getDependencies(models, getImplicitDependencies(), TargetPlatformHelper.getState(), false, true); }
private IPluginModelBase[] getBundles() { List<IPluginModelBase> pluginModelBaseList = new ArrayList<>(); IProduct product = getProduct(); BundleDescription[] bundles = TargetPlatformHelper.getState().getBundles(); for (BundleDescription bundleDescription : bundles) { if (!product.containsPlugin(bundleDescription.getSymbolicName())) { IPluginModelBase pluginModel = PluginRegistry.findModel(bundleDescription); if (pluginModel != null) { pluginModelBaseList.add(pluginModel); } } } return pluginModelBaseList.toArray(new IPluginModelBase[pluginModelBaseList.size()]); }
protected State getState(String os, String ws, String arch) { State main = TargetPlatformHelper.getState(); if (os.equals(TargetPlatform.getOS()) && ws.equals(TargetPlatform.getWS()) && arch.equals(TargetPlatform.getOSArch())) { return main; } if (fStateCopy == null) { copyState(main); } Dictionary<String, String>[] dictionaries = fStateCopy.getPlatformProperties(); for (int i = 0; i < dictionaries.length; i++) { Dictionary<String, String> properties = dictionaries[i]; properties.put("osgi.os", os); //$NON-NLS-1$ properties.put("osgi.ws", ws); //$NON-NLS-1$ properties.put("osgi.arch", arch); //$NON-NLS-1$ } fStateCopy.resolve(false); return fStateCopy; }
protected State getState(String os, String ws, String arch) { State main = TargetPlatformHelper.getState(); if (os.equals(TargetPlatform.getOS()) && ws.equals(TargetPlatform.getWS()) && arch.equals(TargetPlatform.getOSArch())) { return main; } if (fStateCopy == null) { copyState(main); } Dictionary[] dictionaries = fStateCopy.getPlatformProperties(); for (int i = 0; i < dictionaries.length; i++) { Dictionary properties = dictionaries[i]; properties.put("osgi.os", os); //$NON-NLS-1$ properties.put("osgi.ws", ws); //$NON-NLS-1$ properties.put("osgi.arch", arch); //$NON-NLS-1$ } fStateCopy.resolve(false); return fStateCopy; }
/** * Returns a {@link Set} of bundle ids for the dependents of the given * {@link IPluginModelBase}. The set includes the id of the given model base * as well as all computed implicit / optional dependencies. * * @param model the {@link IPluginModelBase} to compute dependencies for * @param excludeFragments a collection of <b>fragment</b> bundle symbolic names to exclude from the dependency resolution * or <code>null</code> if none * @return a set of bundle IDs */ public static Set<String> getSelfAndDependencies(IPluginModelBase model, String[] excludeFragments) { return getDependencies(new Object[] {model}, getImplicitDependencies(), TargetPlatformHelper.getState(), false, true, toSet(excludeFragments)); }
private BundleDescription[] getPluginModels() { ArrayList list = new ArrayList(); State state = TargetPlatformHelper.getState(); IProductPlugin[] plugins = fProductModel.getProduct().getPlugins(); for (int i = 0; i < plugins.length; i++) { BundleDescription bundle = state.getBundle(plugins[i].getId(), null); if (bundle != null) list.add(bundle); } // implicitly add the new launcher plug-in/fragment if we are to use the // new launching story and the launcher plug-in/fragment are not already included in the .product file IPluginModelBase launcherPlugin = PluginRegistry.findModel("org.eclipse.equinox.launcher"); //$NON-NLS-1$ if (launcherPlugin != null) { BundleDescription bundle = launcherPlugin.getBundleDescription(); if (bundle != null && !list.contains(bundle)) { list.add(bundle); BundleDescription[] fragments = bundle.getFragments(); for (int i = 0; i < fragments.length; i++) { if (!list.contains(fragments[i])) { list.add(fragments[i]); } } } } return (BundleDescription[]) list.toArray(new BundleDescription[list.size()]); }
/** * Returns a {@link Set} of bundle ids for the dependents of the given * {@link IPluginModelBase}s. The set includes the ids of the given model bases * as well as all computed implicit / optional dependencies. * * @param models the array of {@link IPluginModelBase}s to compute dependencies for * @param excludeFragments a collection of <b>fragment</b> bundle symbolic names to exclude from the dependency resolution * or <code>null</code> if none * @return a set of bundle IDs */ public static Set<String> getSelfandDependencies(IPluginModelBase[] models, String[] excludeFragments) { return getDependencies(models, getImplicitDependencies(), TargetPlatformHelper.getState(), false, true, toSet(excludeFragments)); }
/** * Returns a {@link Set} of bundle ids for the dependents of the given * objects. The set does not include the ids of the given objects * but does include the computed set of implicit dependencies. * * @param selected selected the group of objects to compute dependencies for. Any items * in this array that are not {@link IPluginModelBase}s are ignored. * @param includeOptional if optional bundle ids should be included * @param excludeFragments a collection of <b>fragment</b> bundle symbolic names to exclude from the dependency resolution * or <code>null</code> if none * @return a set of bundle IDs */ public static Set<String> getDependencies(Object[] selected, boolean includeOptional, String[] excludeFragments) { return getDependencies(selected, getImplicitDependencies(), TargetPlatformHelper.getState(), true, includeOptional, toSet(excludeFragments)); }
private BundleDescription[] getPluginModels() { ArrayList<BundleDescription> list = new ArrayList<>(); State state = TargetPlatformHelper.getState(); IProductPlugin[] plugins = fProductModel.getProduct().getPlugins(); for (IProductPlugin plugin : plugins) { BundleDescription bundle = null; String v = plugin.getVersion(); if (v != null && v.length() > 0) { bundle = state.getBundle(plugin.getId(), Version.parseVersion(v)); } // if there's no version, just grab a bundle like before if (bundle == null) bundle = state.getBundle(plugin.getId(), null); if (bundle != null) list.add(bundle); } return list.toArray(new BundleDescription[list.size()]); }
protected State getState(String os, String ws, String arch) { State main = TargetPlatformHelper.getState(); if (os.equals(TargetPlatform.getOS()) && ws.equals(TargetPlatform.getWS()) && arch.equals(TargetPlatform.getOSArch())) { return main; } if (fStateCopy == null) { fStateCopy = main.getFactory().createState(main); fStateCopy.setResolver(Platform.getPlatformAdmin().getResolver()); fStateCopy.setPlatformProperties(main.getPlatformProperties()); } Dictionary[] dictionaries = fStateCopy.getPlatformProperties(); for (int i = 0; i < dictionaries.length; i++) { Dictionary properties = dictionaries[i]; properties.put("osgi.os", os); //$NON-NLS-1$ properties.put("osgi.ws", ws); //$NON-NLS-1$ properties.put("osgi.arch", arch); //$NON-NLS-1$ } fStateCopy.resolve(false); return fStateCopy; }
private Set<String> getForbiddenIds() { HashSet<String> set = new HashSet<>(); IPluginModelBase model = (IPluginModelBase) getPage().getPDEEditor().getAggregateModel(); if (model == null) { return set; } String id = model.getPluginBase().getId(); if (id != null) set.add(id); IPluginImport[] imports = model.getPluginBase().getImports(); State state = TargetPlatformHelper.getState(); for (IPluginImport pluginImport : imports) { addDependency(state, pluginImport.getId(), set); } return set; }
private Image getObjectImage(IProductPlugin obj) { Version version = (obj.getVersion() != null && obj.getVersion().length() > 0 && !obj.getVersion().equals(ICoreConstants.DEFAULT_VERSION)) ? Version.parseVersion(obj.getVersion()) : null; BundleDescription desc = TargetPlatformHelper.getState().getBundle(obj.getId(), version); if (desc != null) { return desc.getHost() == null ? get(PDEPluginImages.DESC_PLUGIN_OBJ) : get(PDEPluginImages.DESC_FRAGMENT_OBJ); } return get(PDEPluginImages.DESC_PLUGIN_OBJ, F_ERROR); }
@Override protected boolean shouldAddPlugin(BundleDescription bundle, Dictionary<String, String> environment) { // if there is an environment conflict boolean conflict = !super.shouldAddPlugin(bundle, environment); if (conflict) { // make a copy of the state if we haven't already if (fStateCopy == null) copyState(TargetPlatformHelper.getState()); // replace the current BundleDescription with a copy who does not have the platform filter. This will allow the plug-in to be resolved BundleDescription desc = fStateCopy.removeBundle(bundle.getBundleId()); BundleDescription newDesc = fStateCopy.getFactory().createBundleDescription(desc.getBundleId(), desc.getSymbolicName(), desc.getVersion(), desc.getLocation(), desc.getRequiredBundles(), desc.getHost(), desc.getImportPackages(), desc.getExportPackages(), desc.isSingleton(), desc.attachFragments(), desc.dynamicFragments(), null, desc.getExecutionEnvironments(), desc.getGenericRequires(), desc.getGenericCapabilities()); fStateCopy.addBundle(newDesc); } // always include plug-ins, even ones with environment conflicts return true; }
protected boolean shouldAddPlugin(BundleDescription bundle, Dictionary environment) { // if there is an environment conflict boolean conflict = !super.shouldAddPlugin(bundle, environment); if (conflict) { // make a copy of the state if we haven't already if (fStateCopy == null) copyState(TargetPlatformHelper.getState()); // replace the current BundleDescription with a copy who does not have the platform filter. This will allow the plug-in to be resolved BundleDescription desc = fStateCopy.removeBundle(bundle.getBundleId()); BundleDescription newDesc = fStateCopy.getFactory().createBundleDescription(desc.getBundleId(), desc.getSymbolicName(), desc.getVersion(), desc.getLocation(), desc.getRequiredBundles(), desc.getHost(), desc.getImportPackages(), desc.getExportPackages(), desc.isSingleton(), desc.attachFragments(), desc.dynamicFragments(), null, desc.getExecutionEnvironments(), desc.getGenericRequires(), desc.getGenericCapabilities()); fStateCopy.addBundle(newDesc); } // always include plug-ins, even ones with environment conflicts return true; }
protected void makeScripts(IProgressMonitor monitor) throws InvocationTargetException, CoreException { AJBuildScriptGenerator generator = new AJBuildScriptGenerator(); AJBuildScriptGenerator.setEmbeddedSource(AbstractScriptGenerator .getDefaultEmbeddedSource()); AJBuildScriptGenerator.setForceUpdateJar(AbstractScriptGenerator .getForceUpdateJarFormat()); AJBuildScriptGenerator.setConfigInfo(AbstractScriptGenerator .getDefaultConfigInfos()); IProject project = fManifestFile.getProject(); List inpath = getInpath(project); List aspectpath = getAspectpath(project); generator.setInpath(inpath); generator.setAspectpath(aspectpath); generator.setWorkingDirectory(project.getLocation().toOSString()); String url = ClasspathHelper.getDevEntriesProperties(project .getLocation().addTrailingSeparator().toString() + "dev.properties", false); //$NON-NLS-1$ generator.setDevEntries(url); generator.setPDEState(TargetPlatformHelper.getState()); generator.setNextId(TargetPlatformHelper.getPDEState().getNextId()); generator.setStateExtraData(TargetPlatformHelper.getBundleClasspaths(TargetPlatformHelper.getPDEState()), TargetPlatformHelper.getPatchMap(TargetPlatformHelper.getPDEState())); generator.setBuildingOSGi(true); IPluginModelBase model = PDECore.getDefault().getModelManager().findModel(project); generator.setElements(new String[] { "plugin@" +model.getPluginBase().getId() }); //$NON-NLS-1$ generator.generate(); }
@Override protected void makeScripts(IProgressMonitor monitor) throws InvocationTargetException, CoreException { IFeatureModel[] models = PDECore.getDefault().getFeatureModelManager().getModels(); for (IFeatureModel model : models) { if (model.getUnderlyingResource() != null) { IResource underlying = model.getUnderlyingResource(); if (underlying.equals(fManifestFile) || underlying.getProject().equals(fManifestFile.getProject())) fFeatureModel = model; } } BuildScriptGenerator generator = new BuildScriptGenerator(); generator.setChildren(true); AbstractScriptGenerator.setEmbeddedSource(AbstractScriptGenerator.getDefaultEmbeddedSource()); String url = ClasspathHelper.getDevEntriesProperties(fManifestFile.getProject().getLocation().addTrailingSeparator().toString() + "dev.properties", false); //$NON-NLS-1$ generator.setDevEntries(url); generator.setWorkingDirectory(fManifestFile.getProject().getLocation().toOSString()); String configInfo = TargetPlatform.getOS() + ", " + TargetPlatform.getWS() + ", " + TargetPlatform.getOSArch(); //$NON-NLS-1$ //$NON-NLS-2$ AbstractScriptGenerator.setConfigInfo(configInfo); //This needs to be set before we set the format generator.setArchivesFormat(AbstractScriptGenerator.getDefaultConfigInfos() + '-' + IXMLConstants.FORMAT_ANTZIP); generator.setElements(new String[] {"feature@" + fFeatureModel.getFeature().getId() + (fFeatureModel.getFeature().getVersion() == null ? "" : ":" + fFeatureModel.getFeature().getVersion())}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ generator.setPluginPath(TargetPlatformHelper.getFeaturePaths()); generator.setPDEState(TargetPlatformHelper.getState()); generator.setNextId(TargetPlatformHelper.getPDEState().getNextId()); generator.setStateExtraData(TargetPlatformHelper.getBundleClasspaths(TargetPlatformHelper.getPDEState()), TargetPlatformHelper.getPatchMap(TargetPlatformHelper.getPDEState())); generator.setGenerateAssembleScript(false); generator.generate(); }