Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2011-04-01 13:27:02 -0400
committerDJ Houghton2011-04-01 13:27:02 -0400
commit27d353691aa3e6c76116d208b4d481f527bb6bcf (patch)
tree7acea9d2e0bddb37d7f10d12c774171a88fcb857 /bundles/org.eclipse.equinox.p2.publisher
parentb4136f528fd764b5f230ce5d361b860d267193ea (diff)
downloadrt.equinox.p2-27d353691aa3e6c76116d208b4d481f527bb6bcf.tar.gz
rt.equinox.p2-27d353691aa3e6c76116d208b4d481f527bb6bcf.tar.xz
rt.equinox.p2-27d353691aa3e6c76116d208b4d481f527bb6bcf.zip
Package was moved to new org.eclipse.equinox.p2.publisher.eclipse bundle.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.publisher')
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AccumulateConfigDataAction.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AdviceFileAdvice.java183
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AdviceFileParser.java592
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ApplicationLauncherAction.java149
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundleShapeAdvice.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java822
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigAdvice.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java398
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/DefaultCUsAction.java70
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EclipseInstallAction.java219
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java258
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java100
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/Feature.java326
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeatureEntry.java189
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java659
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAndBundlesPublisherApplication.java82
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IBrandingAdvice.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IBundleShapeAdvice.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IConfigAdvice.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IExecutableAdvice.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/InstallPublisherApplication.java101
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/LaunchingAdvice.java43
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java187
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java315
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java71
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/URLEntry.java42
26 files changed, 0 insertions, 5050 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AccumulateConfigDataAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AccumulateConfigDataAction.java
deleted file mode 100644
index a1353770c..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AccumulateConfigDataAction.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.DataLoader;
-import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData;
-import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
-import org.eclipse.equinox.p2.publisher.*;
-
-public class AccumulateConfigDataAction extends AbstractPublisherAction {
-
- private String configSpec;
- private DataLoader loader;
-
- public AccumulateConfigDataAction(IPublisherInfo info, String configSpec, File configurationLocation, File executableLocation) {
- this.configSpec = configSpec;
- loader = new DataLoader(configurationLocation, executableLocation);
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- storeConfigData(publisherInfo, configSpec, results);
- return Status.OK_STATUS;
- }
-
- protected void storeConfigData(IPublisherInfo publisherInfo, String config, IPublisherResult result) {
- ConfigData data = loader.getConfigData();
- if (data == null)
- return;
- publisherInfo.addAdvice(new ConfigAdvice(data, config));
- LauncherData launcherData = loader.getLauncherData();
- if (launcherData == null)
- return;
- publisherInfo.addAdvice(new LaunchingAdvice(launcherData, config));
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AdviceFileAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AdviceFileAdvice.java
deleted file mode 100644
index d3661dfbd..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AdviceFileAdvice.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.*;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
-import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.publisher.Activator;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.publisher.AbstractAdvice;
-import org.eclipse.equinox.p2.publisher.actions.*;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
-
-/**
- * Publishing advice from a p2 advice file. An advice file (p2.inf) can be embedded
- * in the source of a bundle, feature, or product to specify additional advice to be
- * added to the {@link IInstallableUnit} corresponding to the bundle, feature, or product.
- */
-public class AdviceFileAdvice extends AbstractAdvice implements ITouchpointAdvice, ICapabilityAdvice, IUpdateDescriptorAdvice, IPropertyAdvice, IAdditionalInstallableUnitAdvice {
-
- /**
- * The location of the bundle advice file, relative to the bundle root location.
- */
- public static final IPath BUNDLE_ADVICE_FILE = new Path("META-INF/p2.inf"); //$NON-NLS-1$
-
- private final String id;
- private final Version version;
-
- private Map<String, ITouchpointInstruction> touchpointInstructions;
- private IProvidedCapability[] providedCapabilities;
- private IRequirement[] requiredCapabilities;
- private IRequirement[] metaRequiredCapabilities;
- private Map<String, String> iuProperties;
- private InstallableUnitDescription[] additionalIUs;
- private IUpdateDescriptor updateDescriptor;
- private boolean containsAdvice = false;
-
- /**
- * Creates advice for an advice file at the given location. If <tt>basePath</tt>
- * is a directory, then <tt>adviceFilePath</tt> is appended to this location to
- * obtain the location of the advice file. If <tt>basePath</tt> is a file, then
- * <tt>adviceFilePath</tt> is used to
- * @param id The symbolic id of the installable unit this advice applies to
- * @param version The version of the installable unit this advice applies to
- * @param basePath The root location of the the advice file. This is either the location of
- * the jar containing the advice, or a directory containing the advice file
- * @param adviceFilePath The location of the advice file within the base path. This is
- * either the path of a jar entry, or the path of the advice file within the directory
- * specified by the base path.
- */
- public AdviceFileAdvice(String id, Version version, IPath basePath, IPath adviceFilePath) {
- Assert.isNotNull(id);
- Assert.isNotNull(version);
- Assert.isNotNull(basePath);
- Assert.isNotNull(adviceFilePath);
- this.id = id;
- this.version = version;
-
- Map<String, String> advice = loadAdviceMap(basePath, adviceFilePath);
- if (advice.isEmpty())
- return;
-
- AdviceFileParser parser = new AdviceFileParser(id, version, advice);
- try {
- parser.parse();
- } catch (Exception e) {
- String message = "An error occured while parsing advice file: basePath=" + basePath + ", adviceFilePath=" + adviceFilePath + "."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- IStatus status = new Status(IStatus.ERROR, Activator.ID, message, e);
- LogHelper.log(status);
- return;
- }
- touchpointInstructions = parser.getTouchpointInstructions();
- providedCapabilities = parser.getProvidedCapabilities();
- requiredCapabilities = parser.getRequiredCapabilities();
- metaRequiredCapabilities = parser.getMetaRequiredCapabilities();
- iuProperties = parser.getProperties();
- additionalIUs = parser.getAdditionalInstallableUnitDescriptions();
- updateDescriptor = parser.getUpdateDescriptor();
- containsAdvice = true;
- }
-
- public boolean containsAdvice() {
- return containsAdvice;
- }
-
- /**
- * Loads the advice file and returns it in map form.
- */
- private static Map<String, String> loadAdviceMap(IPath basePath, IPath adviceFilePath) {
- File location = basePath.toFile();
- if (location == null || !location.exists())
- return CollectionUtils.emptyMap();
-
- ZipFile jar = null;
- InputStream stream = null;
- try {
- if (location.isDirectory()) {
- File adviceFile = new File(location, adviceFilePath.toString());
- if (!adviceFile.isFile())
- return CollectionUtils.emptyMap();
- stream = new BufferedInputStream(new FileInputStream(adviceFile));
- } else if (location.isFile()) {
- jar = new ZipFile(location);
- ZipEntry entry = jar.getEntry(adviceFilePath.toString());
- if (entry == null)
- return CollectionUtils.emptyMap();
-
- stream = new BufferedInputStream(jar.getInputStream(entry));
- }
- return CollectionUtils.loadProperties(stream);
- } catch (IOException e) {
- String message = "An error occured while reading advice file: basePath=" + basePath + ", adviceFilePath=" + adviceFilePath + "."; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- IStatus status = new Status(IStatus.ERROR, Activator.ID, message, e);
- LogHelper.log(status);
- return CollectionUtils.emptyMap();
- } finally {
- if (stream != null)
- try {
- stream.close();
- } catch (IOException e) {
- // ignore secondary failure
- }
- if (jar != null)
- try {
- jar.close();
- } catch (IOException e) {
- // ignore secondary failure
- }
- }
- }
-
- public boolean isApplicable(String configSpec, boolean includeDefault, String candidateId, Version candidateVersion) {
- return id.equals(candidateId) && version.equals(candidateVersion);
- }
-
- /*(non-Javadoc)
- * @see org.eclipse.equinox.p2.publisher.eclipse.ITouchpointAdvice#getTouchpointData()
- */
- public ITouchpointData getTouchpointData(ITouchpointData existing) {
- return MetadataFactory.mergeTouchpointData(existing, touchpointInstructions);
- }
-
- public IProvidedCapability[] getProvidedCapabilities(InstallableUnitDescription iu) {
- return providedCapabilities;
- }
-
- public IRequirement[] getRequiredCapabilities(InstallableUnitDescription iu) {
- return requiredCapabilities;
- }
-
- public IRequirement[] getMetaRequiredCapabilities(InstallableUnitDescription iu) {
- return metaRequiredCapabilities;
- }
-
- public InstallableUnitDescription[] getAdditionalInstallableUnitDescriptions(IInstallableUnit iu) {
- return additionalIUs;
- }
-
- public IUpdateDescriptor getUpdateDescriptor(InstallableUnitDescription iu) {
- return updateDescriptor;
- }
-
- public Map<String, String> getArtifactProperties(IInstallableUnit iu, IArtifactDescriptor descriptor) {
- return null;
- }
-
- public Map<String, String> getInstallableUnitProperties(InstallableUnitDescription iu) {
- return iuProperties;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AdviceFileParser.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AdviceFileParser.java
deleted file mode 100644
index c2d5ce782..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/AdviceFileParser.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import java.util.Map.Entry;
-import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
-import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
-
-public class AdviceFileParser {
-
- private static final String ADVICE_VERSION = "advice.version"; //$NON-NLS-1$
-
- private static final String QUALIFIER_SUBSTITUTION = "$qualifier$"; //$NON-NLS-1$
- private static final String VERSION_SUBSTITUTION = "$version$"; //$NON-NLS-1$
-
- private static final String UPDATE_DESCRIPTION = "update.description"; //$NON-NLS-1$
- private static final String UPDATE_SEVERITY = "update.severity"; //$NON-NLS-1$
- private static final String UPDATE_RANGE = "update.range"; //$NON-NLS-1$
- private static final String UPDATE_ID = "update.id"; //$NON-NLS-1$
- private static final String CLASSIFIER = "classifier"; //$NON-NLS-1$
- private static final String TOUCHPOINT_VERSION = "touchpoint.version"; //$NON-NLS-1$
- private static final String TOUCHPOINT_ID = "touchpoint.id"; //$NON-NLS-1$
- private static final String COPYRIGHT_LOCATION = "copyright.location"; //$NON-NLS-1$
- private static final String COPYRIGHT = "copyright"; //$NON-NLS-1$
- private static final String ID = "id"; //$NON-NLS-1$
- private static final String SINGLETON = "singleton"; //$NON-NLS-1$
- private static final String IMPORT = "import"; //$NON-NLS-1$
- private static final String RANGE = "range"; //$NON-NLS-1$
- private static final String FILTER = "filter"; //$NON-NLS-1$
- private static final String MULTIPLE = "multiple"; //$NON-NLS-1$
- private static final String OPTIONAL = "optional"; //$NON-NLS-1$
- private static final String GREEDY = "greedy"; //$NON-NLS-1$
- private static final String VERSION = "version"; //$NON-NLS-1$
- private static final String NAMESPACE = "namespace"; //$NON-NLS-1$
- private static final String NAME = "name"; //$NON-NLS-1$
- private static final String LOCATION = "location"; //$NON-NLS-1$
- private static final String VALUE = "value"; //$NON-NLS-1$
-
- private static final String UNITS_PREFIX = "units."; //$NON-NLS-1$
- private static final String INSTRUCTIONS_PREFIX = "instructions."; //$NON-NLS-1$
- private static final String REQUIRES_PREFIX = "requires."; //$NON-NLS-1$
- private static final String META_REQUIREMENTS_PREFIX = "metaRequirements."; //$NON-NLS-1$
- private static final String PROVIDES_PREFIX = "provides."; //$NON-NLS-1$
- private static final String PROPERTIES_PREFIX = "properties."; //$NON-NLS-1$
- private static final String LICENSES_PREFIX = "licenses."; //$NON-NLS-1$
- private static final String ARTIFACTS_PREFIX = "artifacts."; //$NON-NLS-1$
- private static final String HOST_REQUIREMENTS_PREFIX = "hostRequirements."; //$NON-NLS-1$
- private static final String UPDATE_DESCRIPTOR_PREFIX = "update."; //$NON-NLS-1$
-
- public static final Version COMPATIBLE_VERSION = Version.createOSGi(1, 0, 0);
- public static final VersionRange VERSION_TOLERANCE = new VersionRange(COMPATIBLE_VERSION, true, Version.createOSGi(2, 0, 0), false);
-
- private Map<String, String> adviceProperties = new HashMap<String, String>();
- private List<IProvidedCapability> adviceProvides = new ArrayList<IProvidedCapability>();
- private List<IRequirement> adviceRequires = new ArrayList<IRequirement>();
- private List<IRequirement> adviceMetaRequires = new ArrayList<IRequirement>();
- private IUpdateDescriptor adviceUpdateDescriptor = null;
- private Map<String, ITouchpointInstruction> adviceInstructions = new HashMap<String, ITouchpointInstruction>();
- private List<InstallableUnitDescription> adviceOtherIUs = new ArrayList<InstallableUnitDescription>();
-
- private final Map<String, String> advice;
- private Iterator<String> keysIterator;
- private String current;
- private String hostId;
- private Version hostVersion;
-
- public AdviceFileParser(String id, Version version, Map<String, String> advice) {
- this.hostId = id;
- this.hostVersion = version;
- this.advice = advice;
- }
-
- public void parse() {
- String adviceVersion = advice.get(ADVICE_VERSION);
- if (adviceVersion != null)
- checkAdviceVersion(adviceVersion);
-
- List<String> keys = new ArrayList<String>(advice.keySet());
- Collections.sort(keys);
-
- keysIterator = keys.iterator();
- next();
-
- while (current != null) {
- if (current.startsWith(PROPERTIES_PREFIX))
- parseProperties(PROPERTIES_PREFIX, adviceProperties);
- else if (current.startsWith(UPDATE_DESCRIPTOR_PREFIX))
- this.adviceUpdateDescriptor = parseUpdateDescriptor(UPDATE_DESCRIPTOR_PREFIX, hostId);
- else if (current.startsWith(PROVIDES_PREFIX))
- parseProvides(PROVIDES_PREFIX, adviceProvides);
- else if (current.startsWith(REQUIRES_PREFIX))
- parseRequires(REQUIRES_PREFIX, adviceRequires);
- else if (current.startsWith(META_REQUIREMENTS_PREFIX))
- parseRequires(META_REQUIREMENTS_PREFIX, adviceMetaRequires);
- else if (current.startsWith(INSTRUCTIONS_PREFIX))
- parseInstructions(INSTRUCTIONS_PREFIX, adviceInstructions);
- else if (current.startsWith(UNITS_PREFIX))
- parseUnits(UNITS_PREFIX, adviceOtherIUs);
- else if (current.equals(ADVICE_VERSION)) {
- next();
- } else {
- // we ignore elements we do not understand
- next();
- }
- }
- }
-
- private void checkAdviceVersion(String adviceVersion) {
- Version version = Version.parseVersion(adviceVersion);
- if (!VERSION_TOLERANCE.isIncluded(version))
- throw new IllegalStateException("bad version: " + version + ". Expected range was " + VERSION_TOLERANCE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private void next() {
- current = keysIterator.hasNext() ? keysIterator.next() : null;
- }
-
- private String currentValue() {
- return advice.get(current).trim();
- }
-
- private void parseProperties(String prefix, Map<String, String> properties) {
- while (current != null && current.startsWith(prefix)) {
- int dotIndex = current.indexOf('.', prefix.length());
- if (dotIndex == -1)
- throw new IllegalStateException("bad token: " + current); //$NON-NLS-1$
-
- parseProperty(current.substring(0, dotIndex + 1), properties);
- }
- }
-
- private void parseProperty(String prefix, Map<String, String> properties) {
- String propertyName = null;
- String propertyValue = null;
- while (current != null && current.startsWith(prefix)) {
- String token = current.substring(prefix.length());
- if (token.equals(NAME)) {
- propertyName = currentValue();
- } else if (token.equals(VALUE)) {
- propertyValue = currentValue();
- } else {
- // we ignore elements we do not understand
- }
- next();
- }
-
- properties.put(propertyName, propertyValue);
- }
-
- private IUpdateDescriptor parseUpdateDescriptor(String prefix, String id) {
- String name = id;
- String description = null;
- String range = "[0.0.0,$version$)"; //$NON-NLS-1$
- String severity = "0"; //$NON-NLS-1$
-
- while (current != null && current.startsWith(prefix)) {
- String token = current;
- if (token.equals(UPDATE_ID)) {
- name = currentValue();
- } else if (token.equals(UPDATE_DESCRIPTION)) {
- description = currentValue();
- } else if (token.equals(UPDATE_RANGE)) {
- range = currentValue();
- } else if (token.equals(UPDATE_SEVERITY)) {
- severity = currentValue();
- } else {
- // ignore
- }
- next();
- }
-
- range = substituteVersionAndQualifier(range);
- VersionRange versionRange = new VersionRange(range);
- return MetadataFactory.createUpdateDescriptor(name, versionRange, Integer.valueOf(severity), description);
- }
-
- private void parseProvides(String prefix, List<IProvidedCapability> provides) {
- while (current != null && current.startsWith(prefix)) {
- int dotIndex = current.indexOf('.', prefix.length());
- if (dotIndex == -1)
- throw new IllegalStateException("bad token: " + current); //$NON-NLS-1$
-
- parseProvided(current.substring(0, dotIndex + 1), provides);
- }
- }
-
- private void parseProvided(String prefix, List<IProvidedCapability> provides) {
- String namespace = null;
- String name = null;
- Version capabilityVersion = null;
- while (current != null && current.startsWith(prefix)) {
- String token = current.substring(prefix.length());
- if (token.equals(NAME)) {
- name = currentValue();
- } else if (token.equals(NAMESPACE)) {
- namespace = currentValue();
- } else if (token.equals(VERSION)) {
- capabilityVersion = Version.parseVersion(substituteVersionAndQualifier(currentValue()));
- } else {
- // we ignore elements we do not understand
- }
- next();
- }
-
- IProvidedCapability capability = MetadataFactory.createProvidedCapability(namespace, name, capabilityVersion);
- provides.add(capability);
- }
-
- private void parseRequires(String prefix, List<IRequirement> requires) {
- while (current != null && current.startsWith(prefix)) {
- int dotIndex = current.indexOf('.', prefix.length());
- if (dotIndex == -1)
- throw new IllegalStateException("bad token: " + current); //$NON-NLS-1$
-
- parseRequired(current.substring(0, dotIndex + 1), requires);
- }
- }
-
- private void parseRequired(String prefix, List<IRequirement> requires) {
-
- String namespace = null;
- String name = null;
- VersionRange range = null;
- String filter = null;
- boolean optional = false;
- boolean multiple = false;
- boolean greedy = true;
-
- while (current != null && current.startsWith(prefix)) {
- String token = current.substring(prefix.length());
- if (token.equals(GREEDY)) {
- greedy = Boolean.valueOf(currentValue()).booleanValue();
- } else if (token.equals(OPTIONAL)) {
- optional = Boolean.valueOf(currentValue()).booleanValue();
- } else if (token.equals(MULTIPLE)) {
- multiple = Boolean.valueOf(currentValue()).booleanValue();
- } else if (token.equals(FILTER)) {
- filter = currentValue();
- } else if (token.equals(NAME)) {
- name = currentValue();
- } else if (token.equals(NAMESPACE)) {
- namespace = currentValue();
- } else if (token.equals(RANGE)) {
- range = new VersionRange(substituteVersionAndQualifier(currentValue()));
- } else {
- // we ignore elements we do not understand
- }
- next();
- }
- IRequirement capability = MetadataFactory.createRequirement(namespace, name, range, filter, optional, multiple, greedy);
- requires.add(capability);
- }
-
- private void parseInstructions(String prefix, Map<String, ITouchpointInstruction> instructions) {
- while (current != null && current.startsWith(prefix)) {
- int dotIndex = current.indexOf('.', prefix.length());
- if (dotIndex != -1)
- throw new IllegalStateException("bad token: " + current); //$NON-NLS-1$
-
- parseInstruction(current, instructions);
- }
- }
-
- private void parseInstruction(String prefix, Map<String, ITouchpointInstruction> instructions) {
- String phase = current.substring(current.lastIndexOf('.') + 1);
- String body = currentValue();
- next();
-
- prefix += '.';
- String importAttribute = null;
- if (current != null && current.startsWith(prefix)) {
- if (current.substring(prefix.length()).equals(IMPORT)) {
- importAttribute = currentValue();
- } else {
- // we ignore elements we do not understand
- }
- next();
- }
- ITouchpointInstruction instruction = MetadataFactory.createTouchpointInstruction(body, importAttribute);
- instructions.put(phase, instruction);
- }
-
- private void parseUnits(String prefix, List<InstallableUnitDescription> ius) {
- while (current != null && current.startsWith(prefix)) {
- int dotIndex = current.indexOf('.', prefix.length());
- if (dotIndex == -1)
- throw new IllegalStateException("bad token: " + current + " = " + currentValue()); //$NON-NLS-1$ //$NON-NLS-2$
-
- parseUnit(current.substring(0, dotIndex + 1), ius);
- }
- }
-
- private void parseUnit(String prefix, List<InstallableUnitDescription> units) {
- String unitId = null;
- Version unitVersion = null;
- boolean unitSingleton = false;
- String unitFilter = null;
- String unitCopyright = null;
- String unitCopyrightLocation = null;
- String unitTouchpointId = null;
- Version unitTouchpointVersion = null;
-
- String unitUpdateId = null;
- VersionRange unitUpdateRange = null;
- int unitUpdateSeverity = 0;
- String unitUpdateDescription = null;
-
- List<IArtifactKey> unitArtifacts = new ArrayList<IArtifactKey>();
- Map<String, String> unitProperties = new HashMap<String, String>();
- List<IRequirement> unitHostRequirements = new ArrayList<IRequirement>();
- List<IProvidedCapability> unitProvides = new ArrayList<IProvidedCapability>();
- List<IRequirement> unitRequires = new ArrayList<IRequirement>();
- List<IRequirement> unitMetaRequirements = new ArrayList<IRequirement>();
- List<ILicense> unitLicenses = new ArrayList<ILicense>();
- Map<String, ITouchpointInstruction> unitInstructions = new HashMap<String, ITouchpointInstruction>();
- // updatedescriptor ??
-
- while (current != null && current.startsWith(prefix)) {
- String token = current.substring(prefix.length());
- if (token.equals(ID)) {
- unitId = currentValue();
- next();
- } else if (token.equals(VERSION)) {
- unitVersion = Version.parseVersion(substituteVersionAndQualifier(currentValue()));
- next();
- } else if (token.equals(SINGLETON)) {
- unitSingleton = Boolean.valueOf(currentValue()).booleanValue();
- next();
- } else if (token.equals(FILTER)) {
- unitFilter = currentValue();
- next();
- } else if (token.equals(COPYRIGHT)) {
- unitCopyright = currentValue();
- next();
- } else if (token.equals(COPYRIGHT_LOCATION)) {
- unitCopyrightLocation = currentValue();
- next();
- } else if (token.equals(TOUCHPOINT_ID)) {
- unitTouchpointId = currentValue();
- next();
- } else if (token.equals(TOUCHPOINT_VERSION)) {
- unitTouchpointVersion = Version.parseVersion(substituteVersionAndQualifier(currentValue()));
- next();
- } else if (token.equals(UPDATE_ID)) {
- unitUpdateId = currentValue();
- next();
- } else if (token.equals(UPDATE_RANGE)) {
- unitUpdateRange = new VersionRange(substituteVersionAndQualifier(currentValue()));
- next();
- } else if (token.equals(UPDATE_SEVERITY)) {
- unitUpdateSeverity = Integer.parseInt(currentValue());
- next();
- } else if (token.equals(UPDATE_DESCRIPTION)) {
- unitUpdateDescription = currentValue();
- next();
- } else if (token.startsWith(HOST_REQUIREMENTS_PREFIX))
- parseRequires(prefix + HOST_REQUIREMENTS_PREFIX, unitHostRequirements);
- else if (token.startsWith(ARTIFACTS_PREFIX))
- parseArtifacts(prefix + ARTIFACTS_PREFIX, unitArtifacts);
- else if (token.startsWith(LICENSES_PREFIX))
- parseLicenses(prefix + LICENSES_PREFIX, unitLicenses);
- else if (token.startsWith(PROPERTIES_PREFIX))
- parseProperties(prefix + PROPERTIES_PREFIX, unitProperties);
- else if (token.startsWith(PROVIDES_PREFIX))
- parseProvides(prefix + PROVIDES_PREFIX, unitProvides);
- else if (token.startsWith(REQUIRES_PREFIX))
- parseRequires(prefix + REQUIRES_PREFIX, unitRequires);
- else if (token.startsWith(META_REQUIREMENTS_PREFIX))
- parseRequires(prefix + META_REQUIREMENTS_PREFIX, unitMetaRequirements);
- else if (token.startsWith(INSTRUCTIONS_PREFIX))
- parseInstructions(prefix + INSTRUCTIONS_PREFIX, unitInstructions);
- else {
- // we ignore elements we do not understand
- next();
- }
- }
-
- InstallableUnitDescription description = unitHostRequirements.isEmpty() ? new InstallableUnitDescription() : new InstallableUnitFragmentDescription();
- description.setId(unitId);
- description.setVersion(unitVersion);
- description.setSingleton(unitSingleton);
- description.setFilter(unitFilter);
- if (unitCopyright != null || unitCopyrightLocation != null) {
- try {
- URI uri = unitCopyrightLocation != null ? new URI(unitCopyrightLocation) : null;
- description.setCopyright(MetadataFactory.createCopyright(uri, unitCopyright));
- } catch (URISyntaxException e) {
- throw new IllegalStateException("bad copyright URI at token: " + current + ", " + currentValue()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- if (unitTouchpointId != null)
- description.setTouchpointType(MetadataFactory.createTouchpointType(unitTouchpointId, unitTouchpointVersion));
-
- if (unitUpdateId != null)
- description.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(unitUpdateId, unitUpdateRange, unitUpdateSeverity, unitUpdateDescription));
-
- if (!unitLicenses.isEmpty())
- description.setLicenses(unitLicenses.toArray(new ILicense[unitLicenses.size()]));
-
- if (!unitArtifacts.isEmpty())
- description.setArtifacts(unitArtifacts.toArray(new IArtifactKey[unitArtifacts.size()]));
-
- if (!unitHostRequirements.isEmpty())
- ((InstallableUnitFragmentDescription) description).setHost(unitHostRequirements.toArray(new IRequirement[unitHostRequirements.size()]));
-
- if (!unitProperties.isEmpty()) {
- for (Entry<String, String> entry : unitProperties.entrySet()) {
- description.setProperty(entry.getKey(), entry.getValue());
- }
- }
-
- if (!unitProvides.isEmpty())
- description.setCapabilities(unitProvides.toArray(new IProvidedCapability[unitProvides.size()]));
-
- if (!unitRequires.isEmpty())
- description.setRequirements(unitRequires.toArray(new IRequirement[unitRequires.size()]));
-
- if (!unitMetaRequirements.isEmpty())
- description.setMetaRequirements(unitMetaRequirements.toArray(new IRequirement[unitMetaRequirements.size()]));
-
- if (!unitInstructions.isEmpty())
- description.addTouchpointData(MetadataFactory.createTouchpointData(unitInstructions));
-
- adviceOtherIUs.add(description);
- }
-
- private void parseLicenses(String prefix, List<ILicense> licenses) {
- while (current != null && current.startsWith(prefix)) {
- int dotIndex = current.indexOf('.', prefix.length());
- if (dotIndex != -1)
- throw new IllegalStateException("bad token: " + current + " = " + currentValue()); //$NON-NLS-1$ //$NON-NLS-2$
-
- parseLicense(current, licenses);
- }
- }
-
- private void parseLicense(String prefix, List<ILicense> licenses) {
- String body = currentValue();
- next();
-
- prefix += '.';
- String location = null;
- if (current != null && current.startsWith(prefix)) {
- if (current.substring(prefix.length()).equals(LOCATION)) {
- location = currentValue();
- } else {
- // we ignore elements we do not understand
- }
- next();
- }
-
- try {
- URI uri = location != null ? new URI(location) : null;
- ILicense license = MetadataFactory.createLicense(uri, body);
- licenses.add(license);
- } catch (URISyntaxException e) {
- throw new IllegalStateException("bad license URI at token: " + current + ", " + currentValue()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- private void parseArtifacts(String prefix, List<IArtifactKey> artifacts) {
- while (current != null && current.startsWith(prefix)) {
- int dotIndex = current.indexOf('.', prefix.length());
- if (dotIndex == -1)
- throw new IllegalStateException("bad token: " + current + " = " + currentValue()); //$NON-NLS-1$ //$NON-NLS-2$
-
- parseArtifact(current.substring(0, dotIndex + 1), artifacts);
- }
- }
-
- private void parseArtifact(String prefix, List<IArtifactKey> artifacts) {
- String artifactClassifier = null;
- String artifactId = null;
- Version artifactVersion = null;
- while (current != null && current.startsWith(prefix)) {
- String token = current.substring(prefix.length());
- if (token.equals(CLASSIFIER)) {
- artifactClassifier = currentValue();
- } else if (token.equals(ID)) {
- artifactId = currentValue();
- } else if (token.equals(VERSION)) {
- artifactVersion = Version.parseVersion(substituteVersionAndQualifier(currentValue()));
- } else {
- // we ignore elements we do not understand
- }
-
- next();
- }
- IArtifactKey artifactKey = new ArtifactKey(artifactClassifier, artifactId, artifactVersion);
- artifacts.add(artifactKey);
- }
-
- private String substituteVersionAndQualifier(String version) {
- if (version.indexOf(VERSION_SUBSTITUTION) != -1) {
- version = replace(version, VERSION_SUBSTITUTION, hostVersion.toString());
- }
-
- if (version.indexOf(QUALIFIER_SUBSTITUTION) != -1) {
- try {
- String qualifier = PublisherHelper.toOSGiVersion(hostVersion).getQualifier();
- if (qualifier == null)
- qualifier = ""; //$NON-NLS-1$
- if (qualifier.length() == 0) {
- // Note: this works only for OSGi versions and version ranges
- // where the qualifier if present must be at the end of a version string
- version = replace(version, "." + QUALIFIER_SUBSTITUTION, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- version = replace(version, QUALIFIER_SUBSTITUTION, qualifier);
- } catch (UnsupportedOperationException e) {
- // Version cannot be converted to OSGi
- }
- }
- return version;
- }
-
- // originally from org.eclipse.core.internal.net.StringUtil
- public static String replace(String source, String from, String to) {
- if (from.length() == 0)
- return source;
- StringBuffer buffer = new StringBuffer();
- int current = 0;
- int pos = 0;
- while (pos != -1) {
- pos = source.indexOf(from, current);
- if (pos == -1) {
- buffer.append(source.substring(current));
- } else {
- buffer.append(source.substring(current, pos));
- buffer.append(to);
- current = pos + from.length();
- }
- }
- return buffer.toString();
- }
-
- public Map<String, String> getProperties() {
- if (adviceProperties.isEmpty())
- return null;
- return adviceProperties;
- }
-
- public IRequirement[] getRequiredCapabilities() {
- if (adviceRequires.isEmpty())
- return null;
-
- return adviceRequires.toArray(new IRequirement[adviceRequires.size()]);
- }
-
- public IProvidedCapability[] getProvidedCapabilities() {
- if (adviceProvides.isEmpty())
- return null;
-
- return adviceProvides.toArray(new IProvidedCapability[adviceProvides.size()]);
- }
-
- public IUpdateDescriptor getUpdateDescriptor() {
- return adviceUpdateDescriptor;
- }
-
- public Map<String, ITouchpointInstruction> getTouchpointInstructions() {
- if (adviceInstructions.isEmpty())
- return null;
-
- return adviceInstructions;
- }
-
- public InstallableUnitDescription[] getAdditionalInstallableUnitDescriptions() {
- if (adviceOtherIUs.isEmpty())
- return null;
-
- return adviceOtherIUs.toArray(new InstallableUnitDescription[adviceOtherIUs.size()]);
- }
-
- public IRequirement[] getMetaRequiredCapabilities() {
- if (adviceMetaRequires.isEmpty())
- return null;
-
- return adviceMetaRequires.toArray(new IRequirement[adviceMetaRequires.size()]);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ApplicationLauncherAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ApplicationLauncherAction.java
deleted file mode 100644
index 3c5497a5a..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ApplicationLauncherAction.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import org.eclipse.equinox.p2.metadata.MetadataFactory;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-
-import org.eclipse.equinox.p2.query.QueryUtil;
-
-import java.io.File;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.ExecutablesDescriptor;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.publisher.actions.VersionAdvice;
-
-/**
- * Create IUs and CUs that represent the entire launcher for an application. This includes
- * the executable, the launcher fragments as well as the CUs required to install and configure
- * these elements.
- */
-public class ApplicationLauncherAction extends AbstractPublisherAction {
-
- private String flavor;
- private String[] configSpecs;
- private File location;
- private String executableName;
- private Version version;
- private String id;
-
- /**
- * Returns the id of the top level IU published by this action for the given id and flavor.
- * @param id the id of the application being published
- * @param flavor the flavor being published
- * @return the if for ius published by this action
- */
- public static String computeIUId(String id, String flavor) {
- return flavor + id + ".application"; //$NON-NLS-1$
- }
-
- public ApplicationLauncherAction(String id, Version version, String flavor, String executableName, File location, String[] configSpecs) {
- this.flavor = flavor;
- this.configSpecs = configSpecs;
- this.id = id;
- this.version = version;
- this.executableName = executableName;
- this.location = location;
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- // Create the basic actions and run them putting the IUs in a temporary result
- Collection<IPublisherAction> actions = createActions(publisherInfo);
- createAdvice(publisherInfo, results);
- IPublisherResult innerResult = new PublisherResult();
- MultiStatus finalStatus = new MultiStatus(ApplicationLauncherAction.class.getName(), 0, "publishing result", null); //$NON-NLS-1$
- for (IPublisherAction action : actions) {
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- finalStatus.merge(action.perform(publisherInfo, innerResult, monitor));
- }
- if (!finalStatus.isOK())
- return finalStatus;
- // merge the IUs into the final result as non-roots and create a parent IU that captures them all
- results.merge(innerResult, IPublisherResult.MERGE_ALL_NON_ROOT);
- publishApplicationLauncherIU(innerResult.getIUs(null, IPublisherResult.ROOT), results);
- return Status.OK_STATUS;
- }
-
- /**
- * Create advice needed by the actions related to and following this action
- */
- private void createAdvice(IPublisherInfo publisherInfo, IPublisherResult results) {
- createLauncherAdvice(publisherInfo, results);
- }
-
- /**
- * Create and register advice that will tell people what versions of the launcher bundle and
- * fragments are in use in this particular result.
- */
- private void createLauncherAdvice(IPublisherInfo publisherInfo, IPublisherResult results) {
- Collection<IInstallableUnit> ius = getIUs(results.getIUs(null, null), EquinoxLauncherCUAction.ORG_ECLIPSE_EQUINOX_LAUNCHER);
- VersionAdvice advice = new VersionAdvice();
- boolean found = false;
- for (IInstallableUnit iu : ius) {
- // skip over source bundles and fragments
- // TODO should we use the source property here rather than magic name matching?
- if (iu.getId().endsWith(".source") || QueryUtil.isFragment(iu)) //$NON-NLS-1$
- continue;
- advice.setVersion(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), iu.getVersion());
- found = true;
- }
- if (found)
- publisherInfo.addAdvice(advice);
- }
-
- private Collection<IInstallableUnit> getIUs(Collection<IInstallableUnit> ius, String prefix) {
- Set<IInstallableUnit> result = new HashSet<IInstallableUnit>();
- for (IInstallableUnit tmp : ius) {
- if (tmp.getId().startsWith(prefix))
- result.add(tmp);
- }
- return result;
- }
-
- private void publishApplicationLauncherIU(Collection<? extends IVersionedId> children, IPublisherResult result) {
- InstallableUnitDescription descriptor = createParentIU(children, computeIUId(id, flavor), version);
- descriptor.setSingleton(true);
- IInstallableUnit rootIU = MetadataFactory.createInstallableUnit(descriptor);
- if (rootIU == null)
- return;
- result.addIU(rootIU, IPublisherResult.ROOT);
- }
-
- private Collection<IPublisherAction> createActions(IPublisherInfo publisherInfo) {
- Collection<IPublisherAction> actions = new ArrayList<IPublisherAction>();
- actions.add(new EquinoxLauncherCUAction(flavor, configSpecs));
- actions.addAll(createExecutablesActions(configSpecs));
- return actions;
- }
-
- protected Collection<IPublisherAction> createExecutablesActions(String[] configs) {
- Collection<IPublisherAction> actions = new ArrayList<IPublisherAction>(configs.length);
- for (int i = 0; i < configs.length; i++) {
- ExecutablesDescriptor executables = computeExecutables(configs[i]);
- IPublisherAction action = new EquinoxExecutableAction(executables, configs[i], id, version, flavor);
- actions.add(action);
- }
- return actions;
- }
-
- protected ExecutablesDescriptor computeExecutables(String configSpec) {
- // See if we know about an executables feature then use it as the source
- ExecutablesDescriptor result = ExecutablesDescriptor.createExecutablesFromFeature(location, configSpec);
- if (result != null)
- return result;
- // otherwise, assume that we are running against an Eclipse install and do the default thing
- String os = AbstractPublisherAction.parseConfigSpec(configSpec)[1];
- return ExecutablesDescriptor.createDescriptor(os, executableName, location);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundleShapeAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundleShapeAdvice.java
deleted file mode 100644
index 510da514e..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundleShapeAdvice.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.publisher.AbstractAdvice;
-
-public class BundleShapeAdvice extends AbstractAdvice implements IBundleShapeAdvice {
-
- private String shape;
- private Version version;
- private String id;
-
- public BundleShapeAdvice(String id, Version version, String shape) {
- this.id = id;
- this.version = version;
- this.shape = shape;
- }
-
- protected String getId() {
- return id;
- }
-
- protected Version getVersion() {
- return version;
- }
-
- public String getShape() {
- return shape;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
deleted file mode 100644
index af9a9b82b..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
+++ /dev/null
@@ -1,822 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.*;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.p2.publisher.Activator;
-import org.eclipse.equinox.internal.p2.publisher.Messages;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.GeneratorBundleInfo;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.publisher.actions.*;
-import org.eclipse.equinox.p2.query.IQueryResult;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
-import org.eclipse.equinox.spi.p2.publisher.LocalizationHelper;
-import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
-import org.eclipse.osgi.service.pluginconversion.PluginConversionException;
-import org.eclipse.osgi.service.pluginconversion.PluginConverter;
-import org.eclipse.osgi.service.resolver.*;
-import org.eclipse.osgi.util.ManifestElement;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * Publish IUs for all of the bundles in a given set of locations or described by a set of
- * bundle descriptions. The locations can be actual locations of the bundles or folders
- * of bundles.
- *
- * This action consults the following types of advice:
- * </ul>
- * <li>{@link IAdditionalInstallableUnitAdvice }</li>
- * <li>{@link IBundleShapeAdvice}</li>
- * <li>{@link ICapabilityAdvice}</li>
- * <li>{@link IPropertyAdvice}</li>
- * <li>{@link ITouchpointAdvice}</li>
- * </ul>
- */
-public class BundlesAction extends AbstractPublisherAction {
-
- // TODO reconsider the references to these specific ids in the action. The action should be generic
- protected static final String ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR = "org.eclipse.equinox.simpleconfigurator"; //$NON-NLS-1$
- protected static final String ORG_ECLIPSE_UPDATE_CONFIGURATOR = "org.eclipse.update.configurator"; //$NON-NLS-1$
- /**
- * A capability name in the {@link PublisherHelper#NAMESPACE_ECLIPSE_TYPE} namespace
- * representing and OSGi bundle resource
- * @see IProvidedCapability#getName()
- */
- public static final String TYPE_ECLIPSE_BUNDLE = "bundle"; //$NON-NLS-1$
-
- /**
- * A capability name in the {@link PublisherHelper#NAMESPACE_ECLIPSE_TYPE} namespace
- * representing a source bundle
- * @see IProvidedCapability#getName()
- */
- public static final String TYPE_ECLIPSE_SOURCE = "source"; //$NON-NLS-1$
-
- public static final String OSGI_BUNDLE_CLASSIFIER = "osgi.bundle"; //$NON-NLS-1$
- private static final String CAPABILITY_NS_OSGI_BUNDLE = "osgi.bundle"; //$NON-NLS-1$
- private static final String CAPABILITY_NS_OSGI_FRAGMENT = "osgi.fragment"; //$NON-NLS-1$
-
- public static final IProvidedCapability BUNDLE_CAPABILITY = MetadataFactory.createProvidedCapability(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_BUNDLE, Version.createOSGi(1, 0, 0));
- public static final IProvidedCapability SOURCE_BUNDLE_CAPABILITY = MetadataFactory.createProvidedCapability(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_SOURCE, Version.createOSGi(1, 0, 0));
-
- static final String DEFAULT_BUNDLE_LOCALIZATION = "OSGI-INF/l10n/bundle"; //$NON-NLS-1$
-
- private static final String[] BUNDLE_IU_PROPERTY_MAP = {Constants.BUNDLE_NAME, IInstallableUnit.PROP_NAME, Constants.BUNDLE_DESCRIPTION, IInstallableUnit.PROP_DESCRIPTION, Constants.BUNDLE_VENDOR, IInstallableUnit.PROP_PROVIDER, Constants.BUNDLE_CONTACTADDRESS, IInstallableUnit.PROP_CONTACT, Constants.BUNDLE_DOCURL, IInstallableUnit.PROP_DOC_URL, Constants.BUNDLE_UPDATELOCATION, IInstallableUnit.PROP_BUNDLE_LOCALIZATION, Constants.BUNDLE_LOCALIZATION, IInstallableUnit.PROP_BUNDLE_LOCALIZATION};
- public static final int BUNDLE_LOCALIZATION_INDEX = PublisherHelper.BUNDLE_LOCALIZED_PROPERTIES.length - 1;
- public static final String DIR = "dir"; //$NON-NLS-1$
- public static final String JAR = "jar"; //$NON-NLS-1$
- private static final String FEATURE_FILENAME_DESCRIPTOR = "feature.xml"; //$NON-NLS-1$
- private static final String PLUGIN_FILENAME_DESCRIPTOR = "plugin.xml"; //$NON-NLS-1$
- private static final String FRAGMENT_FILENAME_DESCRIPTOR = "fragment.xml"; //$NON-NLS-1$
- public static String BUNDLE_SHAPE = "Eclipse-BundleShape"; //$NON-NLS-1$
-
- private File[] locations;
- private BundleDescription[] bundles;
-
- public static IArtifactKey createBundleArtifactKey(String bsn, String version) {
- return new ArtifactKey(OSGI_BUNDLE_CLASSIFIER, bsn, Version.parseVersion(version));
- }
-
- public static IInstallableUnit createBundleConfigurationUnit(String hostId, Version cuVersion, boolean isBundleFragment, GeneratorBundleInfo configInfo, String configurationFlavor, IMatchExpression<IInstallableUnit> filter) {
- if (configInfo == null)
- return null;
-
- InstallableUnitFragmentDescription cu = new InstallableUnitFragmentDescription();
- String configUnitId = configurationFlavor + hostId;
- cu.setId(configUnitId);
- cu.setVersion(cuVersion);
-
- //Indicate the IU to which this CU apply
- Version hostVersion = Version.parseVersion(configInfo.getVersion());
- VersionRange range = hostVersion == Version.emptyVersion ? VersionRange.emptyRange : new VersionRange(hostVersion, true, Version.MAX_VERSION, true);
- cu.setHost(new IRequirement[] { //
- MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, hostId, range, null, false, false, true), //
- MetadataFactory.createRequirement(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_BUNDLE, new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), false), null, false, false, false)});
-
- //Adds capabilities for fragment, self, and describing the flavor supported
- cu.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
- cu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(configUnitId, cuVersion), MetadataFactory.createProvidedCapability(PublisherHelper.NAMESPACE_FLAVOR, configurationFlavor, Version.createOSGi(1, 0, 0))});
-
- Map<String, String> touchpointData = new HashMap<String, String>();
- touchpointData.put("install", "installBundle(bundle:${artifact})"); //$NON-NLS-1$ //$NON-NLS-2$
- touchpointData.put("uninstall", "uninstallBundle(bundle:${artifact})"); //$NON-NLS-1$ //$NON-NLS-2$
- touchpointData.put("configure", createConfigScript(configInfo, isBundleFragment)); //$NON-NLS-1$
- touchpointData.put("unconfigure", createUnconfigScript(configInfo, isBundleFragment)); //$NON-NLS-1$
- cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
- cu.setFilter(filter);
- return MetadataFactory.createInstallableUnit(cu);
- }
-
- public static IInstallableUnit createBundleIU(BundleDescription bd, IArtifactKey key, IPublisherInfo info) {
- @SuppressWarnings("unchecked")
- Map<String, String> manifest = (Map<String, String>) bd.getUserObject();
- Map<Locale, Map<String, String>> manifestLocalizations = null;
- if (manifest != null && bd.getLocation() != null)
- manifestLocalizations = getManifestLocalizations(manifest, new File(bd.getLocation()));
- InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
- iu.setSingleton(bd.isSingleton());
- iu.setId(bd.getSymbolicName());
- iu.setVersion(PublisherHelper.fromOSGiVersion(bd.getVersion()));
- iu.setFilter(bd.getPlatformFilter());
- iu.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(bd.getSymbolicName(), computeUpdateRange(bd.getVersion()), IUpdateDescriptor.NORMAL, null));
- iu.setArtifacts(new IArtifactKey[] {key});
- iu.setTouchpointType(PublisherHelper.TOUCHPOINT_OSGI);
-
- boolean isFragment = bd.getHost() != null;
- // boolean requiresAFragment = isFragment ? false : requireAFragment(bd, manifest);
-
- //Process the required bundles
- BundleSpecification requiredBundles[] = bd.getRequiredBundles();
- ArrayList<IRequirement> reqsDeps = new ArrayList<IRequirement>();
- // if (requiresAFragment)
- // reqsDeps.add(MetadataFactory.createRequiredCapability(CAPABILITY_TYPE_OSGI_FRAGMENTS, bd.getSymbolicName(), VersionRange.emptyRange, null, false, false));
- if (isFragment)
- reqsDeps.add(MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, bd.getHost().getName(), PublisherHelper.fromOSGiVersionRange(bd.getHost().getVersionRange()), null, false, false));
- for (int j = 0; j < requiredBundles.length; j++)
- reqsDeps.add(MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, requiredBundles[j].getName(), PublisherHelper.fromOSGiVersionRange(requiredBundles[j].getVersionRange()), null, requiredBundles[j].isOptional(), false));
-
- // Process the import packages
- ImportPackageSpecification osgiImports[] = bd.getImportPackages();
- for (int i = 0; i < osgiImports.length; i++) {
- // TODO we need to sort out how we want to handle wild-carded dynamic imports - for now we ignore them
- ImportPackageSpecification importSpec = osgiImports[i];
- String importPackageName = importSpec.getName();
- if (importPackageName.indexOf('*') != -1)
- continue;
- VersionRange versionRange = PublisherHelper.fromOSGiVersionRange(importSpec.getVersionRange());
- //TODO this needs to be refined to take into account all the attribute handled by imports
- reqsDeps.add(MetadataFactory.createRequirement(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, importPackageName, versionRange, null, isOptional(importSpec), false));
- }
- iu.setRequirements(reqsDeps.toArray(new IRequirement[reqsDeps.size()]));
-
- // Create set of provided capabilities
- ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>();
- providedCapabilities.add(PublisherHelper.createSelfCapability(bd.getSymbolicName(), PublisherHelper.fromOSGiVersion(bd.getVersion())));
- providedCapabilities.add(MetadataFactory.createProvidedCapability(CAPABILITY_NS_OSGI_BUNDLE, bd.getSymbolicName(), PublisherHelper.fromOSGiVersion(bd.getVersion())));
-
- // Process the export package
- ExportPackageDescription exports[] = bd.getExportPackages();
- for (int i = 0; i < exports.length; i++) {
- //TODO make sure that we support all the refinement on the exports
- providedCapabilities.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, exports[i].getName(), PublisherHelper.fromOSGiVersion(exports[i].getVersion())));
- }
- // Here we add a bundle capability to identify bundles
- if (manifest != null && manifest.containsKey("Eclipse-SourceBundle")) //$NON-NLS-1$
- providedCapabilities.add(SOURCE_BUNDLE_CAPABILITY);
- else
- providedCapabilities.add(BUNDLE_CAPABILITY);
- if (isFragment)
- providedCapabilities.add(MetadataFactory.createProvidedCapability(CAPABILITY_NS_OSGI_FRAGMENT, bd.getHost().getName(), PublisherHelper.fromOSGiVersion(bd.getVersion())));
-
- if (manifestLocalizations != null) {
- for (Entry<Locale, Map<String, String>> locEntry : manifestLocalizations.entrySet()) {
- Locale locale = locEntry.getKey();
- Map<String, String> translatedStrings = locEntry.getValue();
- for (Entry<String, String> entry : translatedStrings.entrySet()) {
- iu.setProperty(locale.toString() + '.' + entry.getKey(), entry.getValue());
- }
- providedCapabilities.add(PublisherHelper.makeTranslationCapability(bd.getSymbolicName(), locale));
- }
- }
- iu.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]));
- processUpdateDescriptorAdvice(iu, info);
- processCapabilityAdvice(iu, info);
-
- // Set certain properties from the manifest header attributes as IU properties.
- // The values of these attributes may be localized (strings starting with '%')
- // with the translated values appearing in the localization IU fragments
- // associated with the bundle IU.
- if (manifest != null) {
- int i = 0;
- while (i < BUNDLE_IU_PROPERTY_MAP.length) {
- if (manifest.containsKey(BUNDLE_IU_PROPERTY_MAP[i])) {
- String value = manifest.get(BUNDLE_IU_PROPERTY_MAP[i]);
- if (value != null && value.length() > 0) {
- iu.setProperty(BUNDLE_IU_PROPERTY_MAP[i + 1], value);
- }
- }
- i += 2;
- }
- }
-
- // Define the immutable metadata for this IU. In this case immutable means
- // that this is something that will not impact the configuration.
- Map<String, String> touchpointData = new HashMap<String, String>();
- touchpointData.put("manifest", toManifestString(manifest)); //$NON-NLS-1$
- if (isDir(bd, info))
- touchpointData.put("zipped", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- processTouchpointAdvice(iu, touchpointData, info);
-
- processInstallableUnitPropertiesAdvice(iu, info);
- return MetadataFactory.createInstallableUnit(iu);
- }
-
- static VersionRange computeUpdateRange(org.osgi.framework.Version base) {
- VersionRange updateRange = null;
- if (!base.equals(org.osgi.framework.Version.emptyVersion)) {
- updateRange = new VersionRange(Version.emptyVersion, true, PublisherHelper.fromOSGiVersion(base), false);
- } else {
- updateRange = VersionRange.emptyRange;
- }
- return updateRange;
- }
-
- private IInstallableUnitFragment createHostLocalizationFragment(IInstallableUnit bundleIU, BundleDescription bd, String hostId, String[] hostBundleManifestValues) {
- Map<Locale, Map<String, String>> hostLocalizations = getHostLocalizations(new File(bd.getLocation()), hostBundleManifestValues);
- if (hostLocalizations == null || hostLocalizations.isEmpty())
- return null;
- return createLocalizationFragmentOfHost(bd, hostId, hostBundleManifestValues, hostLocalizations);
- }
-
- /*
- * @param hostId
- * @param bd
- * @param locale
- * @param localizedStrings
- * @return installableUnitFragment
- */
- private static IInstallableUnitFragment createLocalizationFragmentOfHost(BundleDescription bd, String hostId, String[] hostManifestValues, Map<Locale, Map<String, String>> hostLocalizations) {
- InstallableUnitFragmentDescription fragment = new MetadataFactory.InstallableUnitFragmentDescription();
- String fragmentId = makeHostLocalizationFragmentId(bd.getSymbolicName());
- fragment.setId(fragmentId);
- fragment.setVersion(PublisherHelper.fromOSGiVersion(bd.getVersion())); // TODO: is this a meaningful version?
-
- HostSpecification hostSpec = bd.getHost();
- IRequirement[] hostReqs = new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, hostSpec.getName(), PublisherHelper.fromOSGiVersionRange(hostSpec.getVersionRange()), null, false, false, false)};
- fragment.setHost(hostReqs);
-
- fragment.setSingleton(true);
- fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
-
- // Create a provided capability for each locale and add the translated properties.
- ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>(hostLocalizations.keySet().size());
- providedCapabilities.add(PublisherHelper.createSelfCapability(fragmentId, fragment.getVersion()));
- for (Entry<Locale, Map<String, String>> localeEntry : hostLocalizations.entrySet()) {
- Locale locale = localeEntry.getKey();
- Map<String, String> translatedStrings = localeEntry.getValue();
- for (Entry<String, String> entry : translatedStrings.entrySet()) {
- fragment.setProperty(locale.toString() + '.' + entry.getKey(), entry.getValue());
- }
- providedCapabilities.add(PublisherHelper.makeTranslationCapability(hostId, locale));
- }
- fragment.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]));
-
- return MetadataFactory.createInstallableUnitFragment(fragment);
- }
-
- /**
- * @param id
- * @return the id for the iu fragment containing localized properties
- * for the fragment with the given id.
- */
- private static String makeHostLocalizationFragmentId(String id) {
- return id + ".translated_host_properties"; //$NON-NLS-1$
- }
-
- private static String createConfigScript(GeneratorBundleInfo configInfo, boolean isBundleFragment) {
- if (configInfo == null)
- return ""; //$NON-NLS-1$
-
- String configScript = "";//$NON-NLS-1$
- if (!isBundleFragment && configInfo.getStartLevel() != BundleInfo.NO_LEVEL) {
- configScript += "setStartLevel(startLevel:" + configInfo.getStartLevel() + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (!isBundleFragment && configInfo.isMarkedAsStarted()) {
- configScript += "markStarted(started: true);"; //$NON-NLS-1$
- }
-
- if (configInfo.getSpecialConfigCommands() != null) {
- configScript += configInfo.getSpecialConfigCommands();
- }
-
- return configScript;
- }
-
- private static String createDefaultBundleConfigScript(GeneratorBundleInfo configInfo) {
- return createConfigScript(configInfo, false);
- }
-
- public static IInstallableUnit createDefaultBundleConfigurationUnit(GeneratorBundleInfo configInfo, GeneratorBundleInfo unconfigInfo, String configurationFlavor) {
- InstallableUnitFragmentDescription cu = new InstallableUnitFragmentDescription();
- String configUnitId = PublisherHelper.createDefaultConfigUnitId(OSGI_BUNDLE_CLASSIFIER, configurationFlavor);
- cu.setId(configUnitId);
- Version configUnitVersion = Version.createOSGi(1, 0, 0);
- cu.setVersion(configUnitVersion);
-
- // Add capabilities for fragment, self, and describing the flavor supported
- cu.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
- cu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(configUnitId, configUnitVersion), MetadataFactory.createProvidedCapability(PublisherHelper.NAMESPACE_FLAVOR, configurationFlavor, Version.createOSGi(1, 0, 0))});
-
- // Create a required capability on bundles
- IRequirement[] reqs = new IRequirement[] {MetadataFactory.createRequirement(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_BUNDLE, VersionRange.emptyRange, null, false, true, false)};
- cu.setHost(reqs);
- Map<String, String> touchpointData = new HashMap<String, String>();
-
- touchpointData.put("install", "installBundle(bundle:${artifact})"); //$NON-NLS-1$ //$NON-NLS-2$
- touchpointData.put("uninstall", "uninstallBundle(bundle:${artifact})"); //$NON-NLS-1$ //$NON-NLS-2$
- touchpointData.put("configure", createDefaultBundleConfigScript(configInfo)); //$NON-NLS-1$
- touchpointData.put("unconfigure", createDefaultBundleUnconfigScript(unconfigInfo)); //$NON-NLS-1$
-
- cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
- return MetadataFactory.createInstallableUnit(cu);
- }
-
- private static String createDefaultBundleUnconfigScript(GeneratorBundleInfo unconfigInfo) {
- return createUnconfigScript(unconfigInfo, false);
- }
-
- private static String createUnconfigScript(GeneratorBundleInfo unconfigInfo, boolean isBundleFragment) {
- if (unconfigInfo == null)
- return ""; //$NON-NLS-1$
- String unconfigScript = "";//$NON-NLS-1$
- if (!isBundleFragment && unconfigInfo.getStartLevel() != BundleInfo.NO_LEVEL) {
- unconfigScript += "setStartLevel(startLevel:" + BundleInfo.NO_LEVEL + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (!isBundleFragment && unconfigInfo.isMarkedAsStarted()) {
- unconfigScript += "markStarted(started: false);"; //$NON-NLS-1$
- }
-
- if (unconfigInfo.getSpecialUnconfigCommands() != null) {
- unconfigScript += unconfigInfo.getSpecialUnconfigCommands();
- }
- return unconfigScript;
- }
-
- private static boolean isOptional(ImportPackageSpecification importedPackage) {
- if (importedPackage.getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_DYNAMIC) || importedPackage.getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_OPTIONAL))
- return true;
- return false;
- }
-
- private static String toManifestString(Map<String, String> p) {
- if (p == null)
- return null;
- StringBuffer result = new StringBuffer();
- // See https://bugs.eclipse.org/329386. We are trying to reduce the size of the manifest data in
- // the eclipse touchpoint. We've removed the code that requires it but in order for old clients
- // to still be able to use recent repositories, we're going to keep around the manifest properties
- // they need.
- final String[] interestingKeys = new String[] {Constants.BUNDLE_SYMBOLICNAME, Constants.BUNDLE_VERSION, Constants.FRAGMENT_HOST};
- for (String key : interestingKeys) {
- String value = p.get(key);
- if (value != null)
- result.append(key).append(": ").append(value).append('\n'); //$NON-NLS-1$
- }
- return result.length() == 0 ? null : result.toString();
- }
-
- // Return a map from locale to property set for the manifest localizations
- // from the given bundle directory and given bundle localization path/name
- // manifest property value.
- private static Map<Locale, Map<String, String>> getManifestLocalizations(Map<String, String> manifest, File bundleLocation) {
- Map<Locale, Map<String, String>> localizations;
- Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
- String[] bundleManifestValues = getManifestCachedValues(manifest);
- String bundleLocalization = bundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; // Bundle localization is the last one in the list
-
- if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
- bundleLocation.isFile()) {
- localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
- //localizations = getJarManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
- } else {
- localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
- // localizations = getDirManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
- }
-
- return localizations;
- }
-
- public static String[] getExternalizedStrings(IInstallableUnit iu) {
- String[] result = new String[PublisherHelper.BUNDLE_LOCALIZED_PROPERTIES.length];
- int j = 0;
- for (int i = 1; i < BUNDLE_IU_PROPERTY_MAP.length - 1; i += 2) {
- if (iu.getProperty(BUNDLE_IU_PROPERTY_MAP[i]) != null && iu.getProperty(BUNDLE_IU_PROPERTY_MAP[i]).length() > 0 && iu.getProperty(BUNDLE_IU_PROPERTY_MAP[i]).charAt(0) == '%')
- result[j++] = iu.getProperty(BUNDLE_IU_PROPERTY_MAP[i]).substring(1);
- else
- j++;
- }
- // The last string is the location
- result[BUNDLE_LOCALIZATION_INDEX] = iu.getProperty(IInstallableUnit.PROP_BUNDLE_LOCALIZATION);
-
- return result;
- }
-
- public static String[] getManifestCachedValues(Map<String, String> manifest) {
- String[] cachedValues = new String[PublisherHelper.BUNDLE_LOCALIZED_PROPERTIES.length];
- for (int j = 0; j < PublisherHelper.BUNDLE_LOCALIZED_PROPERTIES.length; j++) {
- String value = manifest.get(PublisherHelper.BUNDLE_LOCALIZED_PROPERTIES[j]);
- if (PublisherHelper.BUNDLE_LOCALIZED_PROPERTIES[j].equals(Constants.BUNDLE_LOCALIZATION)) {
- if (value == null)
- value = DEFAULT_BUNDLE_LOCALIZATION;
- cachedValues[j] = value;
- } else if (value != null && value.length() > 1 && value.charAt(0) == '%') {
- cachedValues[j] = value.substring(1);
- }
- }
- return cachedValues;
- }
-
- // Return a map from locale to property set for the manifest localizations
- // from the given bundle directory and given bundle localization path/name
- // manifest property value.
- public static Map<Locale, Map<String, String>> getHostLocalizations(File bundleLocation, String[] hostBundleManifestValues) {
- Map<Locale, Map<String, String>> localizations;
- Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
- String hostBundleLocalization = hostBundleManifestValues[BUNDLE_LOCALIZATION_INDEX];
- if (hostBundleLocalization == null)
- return null;
-
- if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
- bundleLocation.isFile()) {
- localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
- //localizations = getJarManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
- } else {
- localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
- // localizations = getDirManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues);
- }
-
- return localizations;
- }
-
- private static PluginConverter acquirePluginConverter() {
- return (PluginConverter) ServiceHelper.getService(Activator.getContext(), PluginConverter.class.getName());
- }
-
- private static Dictionary<String, String> convertPluginManifest(File bundleLocation, boolean logConversionException) {
- PluginConverter converter;
- try {
- converter = acquirePluginConverter();
- if (converter == null) {
- String message = NLS.bind(Messages.exception_noPluginConverter, bundleLocation);
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message));
- return null;
- }
- return converter.convertManifest(bundleLocation, false, null, true, null);
- } catch (PluginConversionException convertException) {
- // only log the exception if we had a plugin.xml or fragment.xml and we failed conversion
- if (bundleLocation.getName().equals(FEATURE_FILENAME_DESCRIPTOR))
- return null;
- if (!new File(bundleLocation, PLUGIN_FILENAME_DESCRIPTOR).exists() && !new File(bundleLocation, FRAGMENT_FILENAME_DESCRIPTOR).exists())
- return null;
- if (logConversionException) {
- IStatus status = new Status(IStatus.WARNING, Activator.ID, 0, NLS.bind(Messages.exception_errorConverting, bundleLocation.getAbsolutePath()), convertException);
- LogHelper.log(status);
- }
- return null;
- }
- }
-
- public static BundleDescription createBundleDescription(Dictionary<String, String> enhancedManifest, File bundleLocation) {
- try {
- BundleDescription descriptor = StateObjectFactory.defaultFactory.createBundleDescription(null, enhancedManifest, bundleLocation == null ? null : bundleLocation.getAbsolutePath(), 1); //TODO Do we need to have a real bundle id
- descriptor.setUserObject(enhancedManifest);
- return descriptor;
- } catch (BundleException e) {
- String message = NLS.bind(Messages.exception_stateAddition, bundleLocation == null ? null : bundleLocation.getAbsoluteFile());
- IStatus status = new Status(IStatus.WARNING, Activator.ID, message, e);
- LogHelper.log(status);
- return null;
- }
- }
-
- public static BundleDescription createBundleDescription(File bundleLocation) {
- Dictionary<String, String> manifest = loadManifest(bundleLocation);
- if (manifest == null)
- return null;
- return createBundleDescription(manifest, bundleLocation);
- }
-
- public static Dictionary<String, String> loadManifest(File bundleLocation) {
- Dictionary<String, String> manifest = basicLoadManifest(bundleLocation);
- if (manifest == null)
- return null;
- // if the bundle itself does not define its shape, infer the shape from the current form
- if (manifest.get(BUNDLE_SHAPE) == null)
- manifest.put(BUNDLE_SHAPE, bundleLocation.isDirectory() ? DIR : JAR);
- return manifest;
- }
-
- public static Dictionary<String, String> basicLoadManifest(File bundleLocation) {
- InputStream manifestStream = null;
- ZipFile jarFile = null;
- try {
- if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && bundleLocation.isFile()) { //$NON-NLS-1$
- jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
- ZipEntry manifestEntry = jarFile.getEntry(JarFile.MANIFEST_NAME);
- if (manifestEntry != null) {
- manifestStream = jarFile.getInputStream(manifestEntry);
- }
- } else {
- File manifestFile = new File(bundleLocation, JarFile.MANIFEST_NAME);
- if (manifestFile.exists())
- manifestStream = new BufferedInputStream(new FileInputStream(manifestFile));
- }
- } catch (IOException e) {
- String message = NLS.bind(Messages.exception_errorLoadingManifest, bundleLocation);
- LogHelper.log(new Status(IStatus.WARNING, Activator.ID, message, e));
- }
- Dictionary<String, String> manifest = null;
- try {
- if (manifestStream != null) {
- try {
- Map<String, String> manifestMap = ManifestElement.parseBundleManifest(manifestStream, null);
- // TODO temporary hack. We are reading a Map but everyone wants a Dictionary so convert.
- // real answer is to have people expect a Map but that is a wider change.
- manifest = new Hashtable<String, String>(manifestMap);
- } catch (IOException e) {
- String message = NLS.bind(Messages.exception_errorReadingManifest, bundleLocation, e.getMessage());
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, e));
- return null;
- } catch (BundleException e) {
- String message = NLS.bind(Messages.exception_errorReadingManifest, bundleLocation, e.getMessage());
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, e));
- return null;
- }
- } else {
- manifest = convertPluginManifest(bundleLocation, true);
- }
- } finally {
- try {
- if (jarFile != null)
- jarFile.close();
- } catch (IOException e2) {
- //Ignore
- }
- }
-
- if (manifest == null)
- return null;
-
- //Deal with the pre-3.0 plug-in shape who have a default jar manifest.mf
- if (manifest.get(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME) == null)
- manifest = convertPluginManifest(bundleLocation, true);
- return manifest;
-
- }
-
- public BundlesAction(File[] locations) {
- this.locations = locations;
- }
-
- public BundlesAction(BundleDescription[] bundles) {
- this.bundles = bundles;
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- if (bundles == null && locations == null)
- throw new IllegalStateException(Messages.exception_noBundlesOrLocations);
-
- setPublisherInfo(publisherInfo);
-
- try {
- if (bundles == null)
- bundles = getBundleDescriptions(expandLocations(locations), monitor);
- generateBundleIUs(bundles, publisherInfo, results, monitor);
- bundles = null;
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- }
-
- protected void publishArtifact(IArtifactDescriptor descriptor, File base, File[] inclusions, IPublisherInfo publisherInfo) {
- IArtifactRepository destination = publisherInfo.getArtifactRepository();
- if (descriptor == null || destination == null)
- return;
-
- // publish the given files
- publishArtifact(descriptor, inclusions, null, publisherInfo, createRootPrefixComputer(base));
- }
-
- protected void publishArtifact(IArtifactDescriptor descriptor, File jarFile, IPublisherInfo publisherInfo) {
- // no files to publish so this is done.
- if (jarFile == null || publisherInfo == null)
- return;
-
- // if the destination already contains the descriptor, there is nothing to do.
- IArtifactRepository destination = publisherInfo.getArtifactRepository();
- if (destination == null || destination.contains(descriptor))
- return;
-
- super.publishArtifact(descriptor, jarFile, publisherInfo);
-
- // if we are assimilating pack200 files then add the packed descriptor
- // into the repo assuming it does not already exist.
- boolean reuse = "true".equals(destination.getProperties().get(AbstractPublisherApplication.PUBLISH_PACK_FILES_AS_SIBLINGS)); //$NON-NLS-1$
- if (reuse && (publisherInfo.getArtifactOptions() & IPublisherInfo.A_PUBLISH) > 0) {
- File packFile = new Path(jarFile.getAbsolutePath()).addFileExtension("pack.gz").toFile(); //$NON-NLS-1$
- if (packFile.exists()) {
- IArtifactDescriptor ad200 = createPack200ArtifactDescriptor(descriptor.getArtifactKey(), packFile, descriptor.getProperty(IArtifactDescriptor.ARTIFACT_SIZE));
- publishArtifact(ad200, packFile, publisherInfo);
- }
- }
- }
-
- private File[] expandLocations(File[] list) {
- ArrayList<File> result = new ArrayList<File>();
- expandLocations(list, result);
- return result.toArray(new File[result.size()]);
- }
-
- private void expandLocations(File[] list, ArrayList<File> result) {
- if (list == null)
- return;
- for (int i = 0; i < list.length; i++) {
- File location = list[i];
- if (location.isDirectory()) {
- // if the location is itself a bundle, just add it. Otherwise r down
- if (new File(location, JarFile.MANIFEST_NAME).exists())
- result.add(location);
- else if (new File(location, "plugin.xml").exists() || new File(location, "fragment.xml").exists()) //$NON-NLS-1$ //$NON-NLS-2$
- result.add(location); //old style bundle without manifest
- else
- expandLocations(location.listFiles(), result);
- } else {
- result.add(location);
- }
- }
- }
-
- //TODO remove this method
- protected void generateBundleIUs(BundleDescription[] bundleDescriptions, IPublisherResult result, IProgressMonitor monitor) {
- generateBundleIUs(bundleDescriptions, null, result, monitor);
- }
-
- protected void generateBundleIUs(BundleDescription[] bundleDescriptions, IPublisherInfo info, IPublisherResult result, IProgressMonitor monitor) {
-
- // This assumes that hosts are processed before fragments because for each fragment the host
- // is queried for the strings that should be translated.
- for (int i = 0; i < bundleDescriptions.length; i++) {
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- BundleDescription bd = bundleDescriptions[i];
- if (bd != null && bd.getSymbolicName() != null && bd.getVersion() != null) {
- //First check to see if there is already an IU around for this
- IInstallableUnit bundleIU = queryForIU(result, bundleDescriptions[i].getSymbolicName(), PublisherHelper.fromOSGiVersion(bd.getVersion()));
- IArtifactKey key = createBundleArtifactKey(bd.getSymbolicName(), bd.getVersion().toString());
- if (bundleIU == null) {
- createAdviceFileAdvice(bundleDescriptions[i], info);
- // Create the bundle IU according to any shape advice we have
- bundleIU = createBundleIU(bd, key, info);
- }
-
- File location = new File(bd.getLocation());
- IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(info, key, location);
- processArtifactPropertiesAdvice(bundleIU, ad, info);
-
- // Publish according to the shape on disk
- File bundleLocation = new File(bd.getLocation());
- if (bundleLocation.isDirectory())
- publishArtifact(ad, bundleLocation, bundleLocation.listFiles(), info);
- else
- publishArtifact(ad, bundleLocation, info);
-
- IInstallableUnit fragment = null;
- if (isFragment(bd)) {
- // TODO: Need a test case for multiple hosts
- String hostId = bd.getHost().getName();
- VersionRange hostVersionRange = PublisherHelper.fromOSGiVersionRange(bd.getHost().getVersionRange());
- IQueryResult<IInstallableUnit> hosts = queryForIUs(result, hostId, hostVersionRange);
-
- for (Iterator<IInstallableUnit> itor = hosts.iterator(); itor.hasNext();) {
- IInstallableUnit host = itor.next();
- String fragmentId = makeHostLocalizationFragmentId(bd.getSymbolicName());
- fragment = queryForIU(result, fragmentId, PublisherHelper.fromOSGiVersion(bd.getVersion()));
- if (fragment == null) {
- String[] externalizedStrings = getExternalizedStrings(host);
- fragment = createHostLocalizationFragment(bundleIU, bd, hostId, externalizedStrings);
- }
- }
-
- }
-
- result.addIU(bundleIU, IPublisherResult.ROOT);
- if (fragment != null)
- result.addIU(fragment, IPublisherResult.NON_ROOT);
-
- InstallableUnitDescription[] others = processAdditionalInstallableUnitsAdvice(bundleIU, info);
- for (int iuIndex = 0; others != null && iuIndex < others.length; iuIndex++) {
- result.addIU(MetadataFactory.createInstallableUnit(others[iuIndex]), IPublisherResult.ROOT);
- }
- }
- }
- }
-
- /**
- * Adds advice for any p2.inf file found in this bundle.
- */
- private void createAdviceFileAdvice(BundleDescription bundleDescription, IPublisherInfo publisherInfo) {
- String location = bundleDescription.getLocation();
- if (location == null)
- return;
-
- AdviceFileAdvice advice = new AdviceFileAdvice(bundleDescription.getSymbolicName(), PublisherHelper.fromOSGiVersion(bundleDescription.getVersion()), new Path(location), AdviceFileAdvice.BUNDLE_ADVICE_FILE);
- if (advice.containsAdvice())
- publisherInfo.addAdvice(advice);
-
- }
-
- private static boolean isDir(BundleDescription bundle, IPublisherInfo info) {
- Collection<IBundleShapeAdvice> advice = info.getAdvice(null, true, bundle.getSymbolicName(), PublisherHelper.fromOSGiVersion(bundle.getVersion()), IBundleShapeAdvice.class);
- // if the advice has a shape, use it
- if (advice != null && !advice.isEmpty()) {
- // we know there is some advice but if there is more than one, take the first.
- String shape = advice.iterator().next().getShape();
- if (shape != null)
- return shape.equals(IBundleShapeAdvice.DIR);
- }
- // otherwise go with whatever we figured out from the manifest or the shape on disk
- @SuppressWarnings("unchecked")
- Map<String, String> manifest = (Map<String, String>) bundle.getUserObject();
- String format = manifest.get(BUNDLE_SHAPE);
- return DIR.equals(format);
- }
-
- private boolean isFragment(BundleDescription bd) {
- return (bd.getHost() != null ? true : false);
- }
-
- // TODO reconsider the special cases here for the configurators. Perhaps these should be in their own actions.
- protected BundleDescription[] getBundleDescriptions(File[] bundleLocations, IProgressMonitor monitor) {
- if (bundleLocations == null)
- return new BundleDescription[0];
- boolean addSimpleConfigurator = false;
- boolean scIn = false;
- for (int i = 0; i < bundleLocations.length; i++) {
- if (!addSimpleConfigurator)
- addSimpleConfigurator = bundleLocations[i].toString().indexOf(ORG_ECLIPSE_UPDATE_CONFIGURATOR) > 0;
- if (!scIn) {
- scIn = bundleLocations[i].toString().indexOf(ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR) > 0;
- if (scIn)
- break;
- }
- }
- if (scIn)
- addSimpleConfigurator = false;
- BundleDescription[] result = new BundleDescription[bundleLocations.length + (addSimpleConfigurator ? 1 : 0)];
- for (int i = 0; i < bundleLocations.length; i++) {
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- result[i] = createBundleDescription(bundleLocations[i]);
- }
- if (addSimpleConfigurator) {
- // Add simple configurator to the list of bundles
- try {
- Bundle simpleConfigBundle = getBundle(ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR);
- if (simpleConfigBundle == null)
- LogHelper.log(new Status(IStatus.INFO, Activator.ID, Messages.message_noSimpleconfigurator));
- else {
- File location = FileLocator.getBundleFile(simpleConfigBundle);
- result[result.length - 1] = createBundleDescription(location);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return result;
- }
-
- // This method is based on core.runtime's InternalPlatform.getBundle(...) with a difference just in how we get PackageAdmin
- private static Bundle getBundle(String symbolicName) {
- PackageAdmin packageAdmin = ServiceHelper.getService(Activator.getContext(), PackageAdmin.class);
- if (packageAdmin == null)
- return null;
- Bundle[] matchingBundles = packageAdmin.getBundles(symbolicName, null);
- if (matchingBundles == null)
- return null;
- //Return the first bundle that is not installed or uninstalled
- for (int i = 0; i < matchingBundles.length; i++) {
- if ((matchingBundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
- return matchingBundles[i];
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigAdvice.java
deleted file mode 100644
index a095a5556..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigAdvice.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.util.Map;
-import org.eclipse.equinox.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
-import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData;
-import org.eclipse.equinox.p2.publisher.AbstractAdvice;
-
-public class ConfigAdvice extends AbstractAdvice implements IConfigAdvice {
-
- private ConfigData data;
- private String configSpec;
-
- public ConfigAdvice(ConfigData data, String configSpec) {
- this.data = data;
- this.configSpec = configSpec;
- }
-
- public BundleInfo[] getBundles() {
- return data.getBundles();
- }
-
- protected String getConfigSpec() {
- return configSpec;
- }
-
- public Map<String, String> getProperties() {
- return CollectionUtils.toMap(data.getProperties());
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java
deleted file mode 100644
index 3d77fdebf..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ConfigCUsAction.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import java.util.*;
-import java.util.Map.Entry;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.p2.metadata.TouchpointInstruction;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.GeneratorBundleInfo;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
-import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-/**
- * Publish CUs for all the configuration data in the current result.
- * This adds config-specific CUs to capture start levels etc found in the config.ini
- * etc for is os, ws, arch combination seen so far.
- */
-public class ConfigCUsAction extends AbstractPublisherAction {
-
- protected static final String ORG_ECLIPSE_UPDATE_CONFIGURATOR = "org.eclipse.update.configurator"; //$NON-NLS-1$
- protected static final String DEFAULT_START_LEVEL = "osgi.bundles.defaultStartLevel"; //$NON-NLS-1$
- private static Collection<String> PROPERTIES_TO_SKIP;
- private static HashSet<String> PROGRAM_ARGS_TO_SKIP;
- protected Version version;
- protected String id;
- protected String flavor;
- IPublisherResult outerResults = null;
-
- // TODO consider moving this filtering to the LaunchingAdvice and ConfigAdvice so
- // it is not hardcoded in the action.
- static {
- PROPERTIES_TO_SKIP = new HashSet<String>();
- PROPERTIES_TO_SKIP.add("osgi.frameworkClassPath"); //$NON-NLS-1$
- PROPERTIES_TO_SKIP.add("osgi.framework"); //$NON-NLS-1$
- PROPERTIES_TO_SKIP.add("osgi.bundles"); //$NON-NLS-1$
- PROPERTIES_TO_SKIP.add("eof"); //$NON-NLS-1$
- PROPERTIES_TO_SKIP.add("eclipse.p2.profile"); //$NON-NLS-1$
- PROPERTIES_TO_SKIP.add("eclipse.p2.data.area"); //$NON-NLS-1$
- PROPERTIES_TO_SKIP.add("org.eclipse.update.reconcile"); //$NON-NLS-1$
- PROPERTIES_TO_SKIP.add("org.eclipse.equinox.simpleconfigurator.configUrl"); //$NON-NLS-1$
-
- PROGRAM_ARGS_TO_SKIP = new HashSet<String>();
- PROGRAM_ARGS_TO_SKIP.add("--launcher.library"); //$NON-NLS-1$
- PROGRAM_ARGS_TO_SKIP.add("-startup"); //$NON-NLS-1$
- PROGRAM_ARGS_TO_SKIP.add("-configuration"); //$NON-NLS-1$
- }
-
- public static String getAbstractCUCapabilityNamespace(String id, String type, String flavor, String configSpec) {
- return flavor + id;
- }
-
- public static String getAbstractCUCapabilityId(String id, String type, String flavor, String configSpec) {
- return id + "." + type; //$NON-NLS-1$
- }
-
- /**
- * Returns the id of the top level IU published by this action for the given id and flavor.
- * @param id the id of the application being published
- * @param flavor the flavor being published
- * @return the if for ius published by this action
- */
- public static String computeIUId(String id, String flavor) {
- return flavor + id + ".configuration"; //$NON-NLS-1$
- }
-
- public ConfigCUsAction(IPublisherInfo info, String flavor, String id, Version version) {
- this.flavor = flavor;
- this.id = id;
- this.version = version;
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- IPublisherResult innerResult = new PublisherResult();
- this.outerResults = results;
- this.info = publisherInfo;
- // we have N platforms, generate a CU for each
- // TODO try and find common properties across platforms
- String[] configSpecs = publisherInfo.getConfigurations();
- for (int i = 0; i < configSpecs.length; i++) {
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- String configSpec = configSpecs[i];
- Collection<IConfigAdvice> configAdvice = publisherInfo.getAdvice(configSpec, false, id, version, IConfigAdvice.class);
- BundleInfo[] bundles = fillInBundles(configAdvice, results);
- publishBundleCUs(publisherInfo, bundles, configSpec, innerResult);
- publishConfigIUs(configAdvice, innerResult, configSpec);
- Collection<IExecutableAdvice> launchingAdvice = publisherInfo.getAdvice(configSpec, false, id, version, IExecutableAdvice.class);
- publishIniIUs(launchingAdvice, innerResult, configSpec);
- }
- // merge the IUs into the final result as non-roots and create a parent IU that captures them all
- results.merge(innerResult, IPublisherResult.MERGE_ALL_NON_ROOT);
- publishTopLevelConfigurationIU(innerResult.getIUs(null, IPublisherResult.ROOT), results);
- return Status.OK_STATUS;
- }
-
- private void publishTopLevelConfigurationIU(Collection<? extends IVersionedId> children, IPublisherResult result) {
- InstallableUnitDescription descriptor = createParentIU(children, computeIUId(id, flavor), version);
- descriptor.setSingleton(true);
- IInstallableUnit rootIU = MetadataFactory.createInstallableUnit(descriptor);
- if (rootIU == null)
- return;
- result.addIU(rootIU, IPublisherResult.ROOT);
- }
-
- // there seem to be cases where the bundle infos are not filled in with symbolic name and version.
- // fill in the missing data.
- private BundleInfo[] fillInBundles(Collection<IConfigAdvice> configAdvice, IPublisherResult results) {
- ArrayList<BundleInfo> result = new ArrayList<BundleInfo>();
- for (IConfigAdvice advice : configAdvice) {
-
- int defaultStart = BundleInfo.NO_LEVEL;
- Map<String, String> adviceProperties = advice.getProperties();
- if (adviceProperties.containsKey(DEFAULT_START_LEVEL)) {
- try {
- defaultStart = Integer.parseInt(adviceProperties.get(DEFAULT_START_LEVEL));
- } catch (NumberFormatException e) {
- //don't know default
- }
- }
-
- BundleInfo[] bundles = advice.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- BundleInfo bundleInfo = bundles[i];
-
- if (bundleInfo.getStartLevel() != BundleInfo.NO_LEVEL && bundleInfo.getStartLevel() == defaultStart) {
- bundleInfo.setStartLevel(BundleInfo.NO_LEVEL);
- }
-
- // prime the result with the current info. This will be replaced if there is more info...
- if ((bundleInfo.getSymbolicName() != null && bundleInfo.getVersion() != null) || bundleInfo.getLocation() == null)
- result.add(bundles[i]);
- else {
- try {
- File location = new File(bundleInfo.getLocation());
- Dictionary<String, String> manifest = BundlesAction.loadManifest(location);
- if (manifest == null)
- continue;
- GeneratorBundleInfo newInfo = new GeneratorBundleInfo(bundleInfo);
- ManifestElement[] element = ManifestElement.parseHeader("dummy-bsn", manifest.get(Constants.BUNDLE_SYMBOLICNAME)); //$NON-NLS-1$
- newInfo.setSymbolicName(element[0].getValue());
- newInfo.setVersion(manifest.get(Constants.BUNDLE_VERSION));
- result.add(newInfo);
- } catch (BundleException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- return result.toArray(new BundleInfo[result.size()]);
- }
-
- /**
- * Publish the IUs that capture the eclipse.ini information such as vmargs and program args, etc
- */
- private void publishIniIUs(Collection<IExecutableAdvice> launchingAdvice, IPublisherResult results, String configSpec) {
- if (launchingAdvice.isEmpty())
- return;
-
- String configureData = ""; //$NON-NLS-1$
- String unconfigureData = ""; //$NON-NLS-1$
- if (!launchingAdvice.isEmpty()) {
- String[] dataStrings = getLauncherConfigStrings(launchingAdvice);
- configureData += dataStrings[0];
- unconfigureData += dataStrings[1];
- }
- // if there is nothing to configure or unconfigure, then don't even bother generating this IU
- if (configureData.length() == 0 && unconfigureData.length() == 0)
- return;
-
- Map<String, String> touchpointData = new HashMap<String, String>();
- touchpointData.put("configure", configureData); //$NON-NLS-1$
- touchpointData.put("unconfigure", unconfigureData); //$NON-NLS-1$
- IInstallableUnit cu = createCU(id, version, "ini", flavor, configSpec, touchpointData); //$NON-NLS-1$
- results.addIU(cu, IPublisherResult.ROOT);
- }
-
- /**
- * Publish the IUs that capture the config.ini information such as properties etc
- */
- private void publishConfigIUs(Collection<IConfigAdvice> configAdvice, IPublisherResult results, String configSpec) {
- if (configAdvice.isEmpty())
- return;
-
- String configureData = ""; //$NON-NLS-1$
- String unconfigureData = ""; //$NON-NLS-1$
- if (!configAdvice.isEmpty()) {
- String[] dataStrings = getConfigurationStrings(configAdvice);
- configureData += dataStrings[0];
- unconfigureData += dataStrings[1];
- }
- // if there is nothing to configure or unconfigure, then don't even bother generating this IU
- if (configureData.length() == 0 && unconfigureData.length() == 0)
- return;
-
- Map<String, String> touchpointData = new HashMap<String, String>();
- touchpointData.put("configure", configureData); //$NON-NLS-1$
- touchpointData.put("unconfigure", unconfigureData); //$NON-NLS-1$
- IInstallableUnit cu = createCU(id, version, "config", flavor, configSpec, touchpointData); //$NON-NLS-1$
- results.addIU(cu, IPublisherResult.ROOT);
- }
-
- /**
- * Create a CU whose id is flavor+id.type.configspec with the given version.
- * The resultant IU has the self capability and an abstract capabilty in the flavor+id namespace
- * with the name id.type and the given version. This allows others to create an abstract
- * dependency on having one of these things around but not having to list out the configs.
- */
- private IInstallableUnit createCU(String cuId, Version cuVersion, String cuType, String cuFlavor, String configSpec, Map<String, String> touchpointData) {
- InstallableUnitDescription cu = new InstallableUnitDescription();
- String resultId = createCUIdString(cuId, cuType, cuFlavor, configSpec);
- cu.setId(resultId);
- cu.setVersion(cuVersion);
- cu.setFilter(createFilterSpec(configSpec));
- IProvidedCapability selfCapability = PublisherHelper.createSelfCapability(resultId, cuVersion);
- String namespace = getAbstractCUCapabilityNamespace(cuId, cuType, cuFlavor, configSpec);
- String abstractId = getAbstractCUCapabilityId(cuId, cuType, cuFlavor, configSpec);
- IProvidedCapability abstractCapability = MetadataFactory.createProvidedCapability(namespace, abstractId, cuVersion);
- cu.setCapabilities(new IProvidedCapability[] {selfCapability, abstractCapability});
- cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
- cu.setTouchpointType(PublisherHelper.TOUCHPOINT_OSGI);
- return MetadataFactory.createInstallableUnit(cu);
- }
-
- protected String[] getConfigurationStrings(Collection<IConfigAdvice> configAdvice) {
- String configurationData = ""; //$NON-NLS-1$
- String unconfigurationData = ""; //$NON-NLS-1$
- Set<String> properties = new HashSet<String>();
- for (IConfigAdvice advice : configAdvice) {
- for (Entry<String, String> aProperty : advice.getProperties().entrySet()) {
- String key = aProperty.getKey();
- if (shouldPublishProperty(key) && !properties.contains(key)) {
- properties.add(key);
- Map<String, String> parameters = new LinkedHashMap<String, String>();
- parameters.put("propName", key); //$NON-NLS-1$
- parameters.put("propValue", aProperty.getValue()); //$NON-NLS-1$
- configurationData += TouchpointInstruction.encodeAction("setProgramProperty", parameters); //$NON-NLS-1$
- parameters.put("propValue", ""); //$NON-NLS-1$//$NON-NLS-2$
- unconfigurationData += TouchpointInstruction.encodeAction("setProgramProperty", parameters); //$NON-NLS-1$
- }
- }
- }
- return new String[] {configurationData, unconfigurationData};
- }
-
- private boolean shouldPublishProperty(String key) {
- return !PROPERTIES_TO_SKIP.contains(key);
- }
-
- private boolean shouldPublishJvmArg(String key) {
- return true;
- }
-
- private boolean shouldPublishProgramArg(String key) {
- return !PROGRAM_ARGS_TO_SKIP.contains(key);
- }
-
- protected String[] getLauncherConfigStrings(Collection<IExecutableAdvice> launchingAdvice) {
- String configurationData = ""; //$NON-NLS-1$
- String unconfigurationData = ""; //$NON-NLS-1$
-
- Map<String, String> touchpointParameters = new LinkedHashMap<String, String>();
- Set<String> jvmSet = new HashSet<String>();
- Set<String> programSet = new HashSet<String>();
- for (IExecutableAdvice advice : launchingAdvice) {
- String[] jvmArgs = advice.getVMArguments();
- for (int i = 0; i < jvmArgs.length; i++)
- if (shouldPublishJvmArg(jvmArgs[i]) && !jvmSet.contains(jvmArgs[i])) {
- jvmSet.add(jvmArgs[i]);
- touchpointParameters.clear();
- touchpointParameters.put("jvmArg", jvmArgs[i]); //$NON-NLS-1$
- configurationData += TouchpointInstruction.encodeAction("addJvmArg", touchpointParameters); //$NON-NLS-1$
- unconfigurationData += TouchpointInstruction.encodeAction("removeJvmArg", touchpointParameters); //$NON-NLS-1$
- }
- String[] programArgs = advice.getProgramArguments();
- for (int i = 0; i < programArgs.length; i++)
- if (shouldPublishProgramArg(programArgs[i]) && !programSet.contains(programArgs[i])) {
- if (programArgs[i].startsWith("-")) //$NON-NLS-1$
- programSet.add(programArgs[i]);
- touchpointParameters.clear();
- touchpointParameters.put("programArg", programArgs[i]); //$NON-NLS-1$
- configurationData += TouchpointInstruction.encodeAction("addProgramArg", touchpointParameters); //$NON-NLS-1$
- unconfigurationData += TouchpointInstruction.encodeAction("removeProgramArg", touchpointParameters); //$NON-NLS-1$
- } else if (i + 1 < programArgs.length && !programArgs[i + 1].startsWith("-")) { //$NON-NLS-1$
- // if we are not publishing then skip over the following arg as it is assumed to be a parameter
- // to this command line arg.
- i++;
- }
- }
- return new String[] {configurationData, unconfigurationData};
- }
-
- /**
- * Publish the CUs related to the given set of bundles. This generally covers the start-level and
- * and whether or not the bundle is to be started.
- */
- protected void publishBundleCUs(IPublisherInfo publisherInfo, BundleInfo[] bundles, String configSpec, IPublisherResult result) {
- if (bundles == null)
- return;
-
- String cuIdPrefix = ""; //$NON-NLS-1$
- IMatchExpression<IInstallableUnit> filter = null;
- if (configSpec != null) {
- cuIdPrefix = createIdString(configSpec);
- filter = createFilterSpec(configSpec);
- }
-
- for (int i = 0; i < bundles.length; i++) {
- GeneratorBundleInfo bundle = createGeneratorBundleInfo(bundles[i], result);
- if (bundle == null)
- continue;
-
- IInstallableUnit iu = bundle.getIU();
-
- // If there is no host, or the filters don't match, skip this one.
- if (iu == null || !filterMatches(iu.getFilter(), configSpec))
- continue;
-
- // TODO need to factor this out into its own action
- if (bundle.getSymbolicName().equals(ORG_ECLIPSE_UPDATE_CONFIGURATOR)) {
- bundle.setStartLevel(BundleInfo.NO_LEVEL);
- bundle.setMarkedAsStarted(false);
- bundle.setSpecialConfigCommands("setProgramProperty(propName:org.eclipse.update.reconcile, propValue:false);"); //$NON-NLS-1$
- bundle.setSpecialUnconfigCommands("setProgramProperty(propName:org.eclipse.update.reconcile, propValue:);"); //$NON-NLS-1$
- } else if (bundle.getStartLevel() == BundleInfo.NO_LEVEL && !bundle.isMarkedAsStarted()) {
- // this bundle does not require any particular configuration, the plug-in default IU will handle installing it
- continue;
- }
-
- IInstallableUnit cu = null;
- if (this.version != null && !this.version.equals(Version.emptyVersion))
- cu = BundlesAction.createBundleConfigurationUnit(bundle.getSymbolicName(), this.version, false, bundle, flavor + cuIdPrefix, filter);
- else
- cu = BundlesAction.createBundleConfigurationUnit(bundle.getSymbolicName(), Version.parseVersion(bundle.getVersion()), false, bundle, flavor + cuIdPrefix, filter);
-
- if (cu != null) {
- // Product Query will run against the repo, make sure these CUs are in before then
- // TODO review the aggressive addition to the metadata repo. perhaps the query can query the result as well.
- // IMetadataRepository metadataRepository = info.getMetadataRepository();
- // if (metadataRepository != null) {
- // metadataRepository.addInstallableUnits(new IInstallableUnit[] {cu});
- // }
- result.addIU(cu, IPublisherResult.ROOT);
- }
- }
- }
-
- protected GeneratorBundleInfo createGeneratorBundleInfo(BundleInfo bundleInfo, IPublisherResult result) {
- String name = bundleInfo.getSymbolicName();
-
- //query for a matching IU
- IInstallableUnit iu = queryForIU(outerResults, name, Version.create(bundleInfo.getVersion()));
- if (iu != null) {
- if (iu.getVersion() == null)
- bundleInfo.setVersion("0.0.0"); //$NON-NLS-1$
- else
- bundleInfo.setVersion(iu.getVersion().toString());
- GeneratorBundleInfo newInfo = new GeneratorBundleInfo(bundleInfo);
- newInfo.setIU(iu);
- return newInfo;
- }
-
- if (bundleInfo.getLocation() != null || bundleInfo.getVersion() != null)
- return new GeneratorBundleInfo(bundleInfo);
- //harder: try id_version
- int i = name.indexOf('_');
- while (i > -1) {
- try {
- Version bundleVersion = Version.parseVersion(name.substring(i));
- bundleInfo.setSymbolicName(name.substring(0, i));
- bundleInfo.setVersion(bundleVersion.toString());
- return new GeneratorBundleInfo(bundleInfo);
- } catch (IllegalArgumentException e) {
- // the '_' found was probably part of the symbolic id
- i = name.indexOf('_', i);
- }
- }
-
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/DefaultCUsAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/DefaultCUsAction.java
deleted file mode 100644
index 30734f329..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/DefaultCUsAction.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.GeneratorBundleInfo;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
-
-/**
- * Publish IUs that install/configure the standard things like bundles, features and source bundles
- */
-public class DefaultCUsAction extends AbstractPublisherAction {
-
- private String flavor;
- private int startLevel;
- private boolean start;
-
- public DefaultCUsAction(IPublisherInfo info, String flavor, int startLevel, boolean start) {
- this.flavor = flavor;
- this.startLevel = startLevel;
- this.start = start;
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- setPublisherInfo(publisherInfo);
- generateDefaultConfigIU(results);
- return Status.OK_STATUS;
- }
-
- protected void generateDefaultConfigIU(IPublisherResult result) {
- // TODO this is a bit of a hack. We need to have the default IU fragment generated with code that configures
- // and unconfigures. The Generator should be decoupled from any particular provider but it is not clear
- // that we should add the create* methods to IGeneratorInfo...
- // MockBundleDescription bd1 = new MockBundleDescription("defaultConfigure");
- // MockBundleDescription bd2 = new MockBundleDescription("defaultUnconfigure");
- result.addIU(BundlesAction.createDefaultBundleConfigurationUnit(createDefaultConfigurationBundleInfo(), createDefaultUnconfigurationBundleInfo(), flavor), IPublisherResult.ROOT);
- result.addIU(PublisherHelper.createDefaultFeatureConfigurationUnit(flavor), IPublisherResult.ROOT);
- result.addIU(PublisherHelper.createDefaultConfigurationUnitForSourceBundles(flavor), IPublisherResult.ROOT);
- }
-
- protected GeneratorBundleInfo createDefaultConfigurationBundleInfo() {
- GeneratorBundleInfo result = new GeneratorBundleInfo();
- result.setSymbolicName("defaultConfigure"); //$NON-NLS-1$
- result.setVersion("1.0.0"); //$NON-NLS-1$
- result.setStartLevel(startLevel);
- result.setMarkedAsStarted(start);
- // These should just be in the install section now
- // result.setSpecialConfigCommands("installBundle(bundle:${artifact});");
- return result;
- }
-
- protected GeneratorBundleInfo createDefaultUnconfigurationBundleInfo() {
- GeneratorBundleInfo result = new GeneratorBundleInfo();
- result.setSymbolicName("defaultUnconfigure"); //$NON-NLS-1$
- result.setVersion("1.0.0"); //$NON-NLS-1$
- // These should just be in the uninstall section now
- // result.setSpecialConfigCommands("uninstallBundle(bundle:${artifact});");
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EclipseInstallAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EclipseInstallAction.java
deleted file mode 100644
index 184714a01..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EclipseInstallAction.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.ExecutablesDescriptor;
-import org.eclipse.equinox.p2.metadata.IVersionedId;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.publisher.actions.*;
-
-public class EclipseInstallAction extends AbstractPublisherAction {
- protected String source;
- protected String id;
- protected Version version;
- protected String name;
- protected String executableName;
- protected String flavor;
- protected IVersionedId[] topLevel;
- protected String[] nonRootFiles;
- protected boolean start = false;
-
- protected EclipseInstallAction() {
- //hidden
- }
-
- public EclipseInstallAction(String source, String id, Version version, String name, String executableName, String flavor, IVersionedId[] topLevel, String[] nonRootFiles, boolean start) {
- this.source = source;
- this.id = id;
- this.version = version;
- this.name = name == null ? id : name;
- this.executableName = executableName == null ? "eclipse" : executableName; //$NON-NLS-1$
- this.flavor = flavor;
- this.topLevel = topLevel;
- this.nonRootFiles = nonRootFiles;
- this.start = start;
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- monitor = SubMonitor.convert(monitor);
- this.info = publisherInfo;
- IPublisherAction[] actions = createActions();
- MultiStatus finalStatus = new MultiStatus(EclipseInstallAction.class.getName(), 0, "publishing result", null); //$NON-NLS-1$
- for (int i = 0; i < actions.length; i++) {
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- finalStatus.merge(actions[i].perform(publisherInfo, results, monitor));
- }
- if (!finalStatus.isOK())
- return finalStatus;
- return Status.OK_STATUS;
- }
-
- protected IPublisherAction[] createActions() {
- createAdvice();
- ArrayList<IPublisherAction> actions = new ArrayList<IPublisherAction>();
- // create an action that just publishes the raw bundles and features
- IPublisherAction action = new MergeResultsAction(new IPublisherAction[] {createFeaturesAction(), createBundlesAction()}, IPublisherResult.MERGE_ALL_ROOT);
- actions.add(action);
- actions.add(createApplicationExecutableAction(info.getConfigurations()));
- actions.add(createRootFilesAction());
- actions.addAll(createAccumulateConfigDataActions(info.getConfigurations()));
- actions.add(createJREAction());
- actions.add(createConfigCUsAction());
- actions.add(createDefaultCUsAction());
- actions.add(createRootIUAction());
- return actions.toArray(new IPublisherAction[actions.size()]);
- }
-
- private void createAdvice() {
- createRootFilesAdvice();
- createRootAdvice();
- }
-
- protected void createRootAdvice() {
- if (topLevel != null)
- info.addAdvice(new RootIUAdvice(getTopLevel()));
- info.addAdvice(new RootIUResultFilterAdvice(null));
- }
-
- protected IPublisherAction createDefaultCUsAction() {
- return new DefaultCUsAction(info, flavor, 4, start);
- }
-
- protected IPublisherAction createRootIUAction() {
- return new RootIUAction(id, version, name);
- }
-
- protected Collection<IVersionedId> getTopLevel() {
- return Arrays.asList(topLevel);
- }
-
- protected IPublisherAction createJREAction() {
- return new JREAction((File) null);
- }
-
- protected IPublisherAction createApplicationExecutableAction(String[] configSpecs) {
- return new ApplicationLauncherAction(id, version, flavor, executableName, getExecutablesLocation(), configSpecs);
- }
-
- protected Collection<IPublisherAction> createAccumulateConfigDataActions(String[] configs) {
- File configuration = new File(source, "configuration/config.ini"); //$NON-NLS-1$
- if (!configuration.exists())
- configuration = null;
-
- Collection<IPublisherAction> result = new ArrayList<IPublisherAction>(configs.length);
- for (int i = 0; i < configs.length; i++) {
- String configSpec = configs[i];
- String os = AbstractPublisherAction.parseConfigSpec(configSpec)[1];
- File executable = ExecutablesDescriptor.findExecutable(os, computeExecutableLocation(configSpec), "eclipse"); //$NON-NLS-1$
- if (!executable.exists())
- executable = null;
- IPublisherAction action = new AccumulateConfigDataAction(info, configSpec, configuration, executable);
- result.add(action);
- }
-
- return result;
- }
-
- protected IPublisherAction createConfigCUsAction() {
- return new ConfigCUsAction(info, flavor, id, version);
- }
-
- protected IPublisherAction createFeaturesAction() {
- return new FeaturesAction(new File[] {new File(source, "features")}); //$NON-NLS-1$
- }
-
- protected Collection<IPublisherAction> createExecutablesActions(String[] configSpecs) {
- Collection<IPublisherAction> result = new ArrayList<IPublisherAction>(configSpecs.length);
- for (int i = 0; i < configSpecs.length; i++) {
- ExecutablesDescriptor executables = computeExecutables(configSpecs[i]);
- IPublisherAction action = new EquinoxExecutableAction(executables, configSpecs[i], id, version, flavor);
- result.add(action);
- }
- return result;
- }
-
- protected IPublisherAction createRootFilesAction() {
- return new RootFilesAction(info, id, version, flavor);
- }
-
- protected void createRootFilesAdvice() {
- File[] baseExclusions = computeRootFileExclusions();
- if (baseExclusions != null)
- info.addAdvice(new RootFilesAdvice(null, null, baseExclusions, null));
- String[] configs = info.getConfigurations();
- for (int i = 0; i < configs.length; i++)
- info.addAdvice(computeRootFileAdvice(configs[i]));
- }
-
- protected IPublisherAdvice computeRootFileAdvice(String configSpec) {
- File root = computeRootFileRoot(configSpec);
- File[] inclusions = computeRootFileInclusions(configSpec);
- File[] exclusions = computeRootFileExclusions(configSpec);
- return new RootFilesAdvice(root, inclusions, exclusions, configSpec);
- }
-
- protected File[] computeRootFileExclusions(String configSpec) {
- ExecutablesDescriptor executables = computeExecutables(configSpec);
- File[] files = executables.getFiles();
- File[] result = new File[files.length + 1];
- System.arraycopy(files, 0, result, 0, files.length);
- result[files.length] = executables.getIniLocation();
- return result;
- }
-
- protected File[] computeRootFileExclusions() {
- if (nonRootFiles == null || nonRootFiles.length == 0)
- return null;
- ArrayList<File> result = new ArrayList<File>();
- for (int i = 0; i < nonRootFiles.length; i++) {
- String filename = nonRootFiles[i];
- File file = new File(filename);
- if (file.isAbsolute())
- result.add(file);
- else
- result.add(new File(source, filename));
- }
- return result.toArray(new File[result.size()]);
- }
-
- protected ExecutablesDescriptor computeExecutables(String configSpec) {
- String os = AbstractPublisherAction.parseConfigSpec(configSpec)[1];
- // TODO here we should not assume that the executable is called "eclipse"
- return ExecutablesDescriptor.createDescriptor(os, "eclipse", computeExecutableLocation(configSpec)); //$NON-NLS-1$
- }
-
- protected File computeRootFileRoot(String configSpec) {
- return new File(source);
- }
-
- protected File[] computeRootFileInclusions(String configSpec) {
- return new File[] {new File(source)};
- }
-
- protected File computeExecutableLocation(String configSpec) {
- return new File(source);
- }
-
- protected File getExecutablesLocation() {
- return new File(source);
- }
-
- protected IPublisherAction createBundlesAction() {
- // TODO need to add in the simple configorator and reconciler bundle descriptions.
- // TODO bundles action needs to take bundleDescriptions directly rather than just files.
- return new BundlesAction(new File[] {new File(source, "plugins")}); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java
deleted file mode 100644
index 7f9a4db2c..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxExecutableAction.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.BrandingIron;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.ExecutablesDescriptor;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
-import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
-import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
-import org.eclipse.osgi.service.environment.Constants;
-
-/**
- * Given the description of an executable, this action publishes optionally
- * non-destructively brands the executable, publishes the resultant artifacts
- * and publishes the required IUs to identify the branded executable, configure
- * the executable and set it up as the launcher for a profile.
- * <p>
- * This action works on one platform configuration only.
- * <p>
- * This action consults the following types of advice:
- * </ul>
- * <li>{@link IBrandingAdvice}</li>
- * </ul>
- */
-public class EquinoxExecutableAction extends AbstractPublisherAction {
- private static String TYPE = "executable"; //$NON-NLS-1$
-
- protected String configSpec;
- protected String idBase;
- protected Version version;
- protected ExecutablesDescriptor executables;
- protected String flavor;
-
- protected EquinoxExecutableAction() {
- //hidden
- }
-
- public EquinoxExecutableAction(ExecutablesDescriptor executables, String configSpec, String idBase, Version version, String flavor) {
- this.executables = executables;
- this.configSpec = configSpec;
- this.idBase = idBase == null ? "org.eclipse" : idBase; //$NON-NLS-1$
- this.version = version;
- this.flavor = flavor;
- }
-
- public IStatus perform(IPublisherInfo publisherinfo, IPublisherResult result, IProgressMonitor monitor) {
- setPublisherInfo(publisherinfo);
- ExecutablesDescriptor brandedExecutables = brandExecutables(executables);
- try {
- if (publishExecutableIU(brandedExecutables, result))
- publishExecutableCU(brandedExecutables, result);
- publishExecutableSetter(brandedExecutables, result);
- } finally {
- if (brandedExecutables.isTemporary())
- FileUtils.deleteAll(brandedExecutables.getLocation());
- }
- return Status.OK_STATUS;
- }
-
- /**
- * Publishes the IUs that cause the executable to be actually set as the launcher for
- * the profile
- */
- private void publishExecutableSetter(ExecutablesDescriptor brandedExecutables, IPublisherResult result) {
- InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
- String executableName = brandedExecutables.getExecutableName();
- String id = getExecutableId() + '.' + executableName;
- iud.setId(id);
- iud.setVersion(version);
- iud.setTouchpointType(PublisherHelper.TOUCHPOINT_OSGI);
- iud.setCapabilities(new IProvidedCapability[] {createSelfCapability(id, version)});
- iud.setFilter(createFilterSpec(configSpec));
- Map<String, String> touchpointData = new HashMap<String, String>();
- touchpointData.put("configure", "setLauncherName(name:" + executableName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- touchpointData.put("unconfigure", "setLauncherName()"); //$NON-NLS-1$ //$NON-NLS-2$
- iud.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
- result.addIU(MetadataFactory.createInstallableUnit(iud), IPublisherResult.ROOT);
- }
-
- /**
- * Publishes IUs and CUs for the files that make up the launcher for a given
- * ws/os/arch combination.
- */
- protected boolean publishExecutableIU(ExecutablesDescriptor execDescriptor, IPublisherResult result) {
- String[] config = parseConfigSpec(configSpec);
- if (execDescriptor.getFiles().length == 0 && (config.length == 0 || CONFIG_ANY.equalsIgnoreCase(config[0]))) {
- return false; //no cu required
- }
- boolean publishCU = true;
-
- // Create the IU for the executable
- InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
- String id = getExecutableId();
- iu.setId(id);
- iu.setVersion(version);
- IMatchExpression<IInstallableUnit> filter = createFilterSpec(configSpec);
- iu.setFilter(filter);
- iu.setSingleton(true);
- iu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
- String namespace = ConfigCUsAction.getAbstractCUCapabilityNamespace(idBase, TYPE, flavor, configSpec);
- String capabilityId = ConfigCUsAction.getAbstractCUCapabilityId(idBase, TYPE, flavor, configSpec);
- IProvidedCapability executableCapability = MetadataFactory.createProvidedCapability(namespace, capabilityId, version);
- IProvidedCapability selfCapability = createSelfCapability(id, version);
- iu.setCapabilities(new IProvidedCapability[] {selfCapability, executableCapability});
-
- //Create the artifact descriptor. we have several files so no path on disk
- if (execDescriptor.getFiles().length == 0) {
- publishCU = false;
- } else {
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey(id, version);
- iu.setArtifacts(new IArtifactKey[] {key});
- IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(info, key, null);
- publishArtifact(descriptor, execDescriptor.getFiles(), null, info, createRootPrefixComputer(execDescriptor.getLocation()));
- if (execDescriptor.isTemporary())
- FileUtils.deleteAll(execDescriptor.getLocation());
- }
- // setup a requirement between the executable and the launcher fragment that has the shared library
- if (config.length > 0 && !CONFIG_ANY.equalsIgnoreCase(config[0])) {
- String ws = config[0];
- String os = config[1];
- String arch = config[2];
- String launcherFragment = EquinoxLauncherCUAction.ORG_ECLIPSE_EQUINOX_LAUNCHER + '.' + ws + '.' + os;
- if (!(Constants.OS_MACOSX.equals(os) && !Constants.ARCH_X86_64.equals(arch)))
- launcherFragment += '.' + arch;
- iu.setRequirements(new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, launcherFragment, VersionRange.emptyRange, filter, false, false)});
- }
- result.addIU(MetadataFactory.createInstallableUnit(iu), IPublisherResult.ROOT);
- return publishCU;
- }
-
- private String getExecutableId() {
- return createCUIdString(idBase, TYPE, "", configSpec); //$NON-NLS-1$
- }
-
- // Create the CU that installs (e.g., unzips) the executable
- private void publishExecutableCU(ExecutablesDescriptor execDescriptor, IPublisherResult result) {
- InstallableUnitFragmentDescription cu = new InstallableUnitFragmentDescription();
- String id = createCUIdString(idBase, TYPE, flavor, configSpec);
- cu.setId(id);
- cu.setVersion(version);
- cu.setFilter(createFilterSpec(configSpec));
- String executableId = getExecutableId();
- cu.setHost(new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, executableId, new VersionRange(version, true, version, true), null, false, false)});
- cu.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
- //TODO bug 218890, would like the fragment to provide the launcher capability as well, but can't right now.
- cu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(id, version)});
- cu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
- String[] config = parseConfigSpec(configSpec);
- String os = config[1];
- Map<String, String> touchpointData = computeInstallActions(execDescriptor, os);
- cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
- IInstallableUnit unit = MetadataFactory.createInstallableUnit(cu);
- result.addIU(unit, IPublisherResult.ROOT);
- }
-
- private Map<String, String> computeInstallActions(ExecutablesDescriptor execDescriptor, String os) {
- Map<String, String> touchpointData = new HashMap<String, String>();
- String configurationData = "unzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
- if (Constants.OS_MACOSX.equals(os)) {
- String execName = execDescriptor.getExecutableName();
- configurationData += " chmod(targetDir:${installFolder}/" + execName + ".app/Contents/MacOS/, targetFile:" + execName + ", permissions:755);"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if (!Constants.OS_WIN32.equals(os)) {
- // We are on linux/unix. by default set all of the files to be executable.
- File[] fileList = execDescriptor.getFiles();
- for (int i = 0; i < fileList.length; i++)
- configurationData += " chmod(targetDir:${installFolder}, targetFile:" + fileList[i].getName() + ", permissions:755);"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- touchpointData.put("install", configurationData); //$NON-NLS-1$
- String unConfigurationData = "cleanupzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
- touchpointData.put("uninstall", unConfigurationData); //$NON-NLS-1$
- return touchpointData;
- }
-
- /**
- * Brands a copy of the given executable descriptor with the information in the
- * current product definition. The files described in the descriptor are also copied
- * to a temporary location to avoid destructive modification.
- *
- * @param descriptor the executable descriptor to brand.
- * @return the new descriptor
- */
- protected ExecutablesDescriptor brandExecutables(ExecutablesDescriptor descriptor) {
- ExecutablesDescriptor result = new ExecutablesDescriptor(descriptor);
- result.makeTemporaryCopy();
- IBrandingAdvice advice = getBrandingAdvice();
- if (advice == null)
- partialBrandExecutables(result);
- else
- fullBrandExecutables(result, advice);
- return result;
- }
-
- private IBrandingAdvice getBrandingAdvice() {
- // there is expected to only be one branding advice for a given configspec so
- // just return the first one we find.
- Collection<IBrandingAdvice> advice = info.getAdvice(configSpec, true, null, null, IBrandingAdvice.class);
- for (Iterator<IBrandingAdvice> i = advice.iterator(); i.hasNext();)
- return i.next();
- return null;
- }
-
- protected void fullBrandExecutables(ExecutablesDescriptor descriptor, IBrandingAdvice advice) {
- BrandingIron iron = new BrandingIron();
- iron.setIcons(advice.getIcons());
- String name = advice.getExecutableName();
- if (name == null)
- name = "eclipse"; //$NON-NLS-1$
- iron.setName(name);
- iron.setOS(advice.getOS());
- iron.setRoot(descriptor.getLocation().getAbsolutePath());
- try {
- iron.brand();
- descriptor.setExecutableName(name, true);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- protected void partialBrandExecutables(ExecutablesDescriptor descriptor) {
- File[] list = descriptor.getFiles();
- for (int i = 0; i < list.length; i++)
- mungeExecutableFileName(list[i], descriptor);
- descriptor.setExecutableName("eclipse", true); //$NON-NLS-1$
- }
-
- // TODO This method is a temporary hack to rename the launcher.exe files
- // to eclipse.exe (or "launcher" to "eclipse"). Eventually we will either hand-craft
- // metadata/artifacts for launchers, or alter the delta pack to contain eclipse-branded
- // launchers.
- private void mungeExecutableFileName(File file, ExecutablesDescriptor descriptor) {
- if (file.getName().equals("launcher")) { //$NON-NLS-1$
- File newFile = new File(file.getParentFile(), "eclipse"); //$NON-NLS-1$
- file.renameTo(newFile);
- descriptor.replace(file, newFile);
- } else if (file.getName().equals("launcher.exe")) { //$NON-NLS-1$
- File newFile = new File(file.getParentFile(), "eclipse.exe"); //$NON-NLS-1$
- file.renameTo(newFile);
- descriptor.replace(file, newFile);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java
deleted file mode 100644
index abcafe7ef..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/EquinoxLauncherCUAction.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.util.Collection;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.frameworkadmin.utils.Utils;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.GeneratorBundleInfo;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.publisher.actions.IVersionAdvice;
-import org.eclipse.osgi.service.environment.Constants;
-
-/**
- * Create CUs for all Equinox launcher related IUs for the given set of configurations
- * such that the launcher is configured as the startup code and the fragments
- * are configured as the launcher.library.
- * <p>
- * This action expects to have find the versions of the launcher and launcher fragments
- * via IVersionAdvice in the supplied info object.
- * </p>
- */
-public class EquinoxLauncherCUAction extends AbstractPublisherAction {
-
- public static final String ORG_ECLIPSE_EQUINOX_LAUNCHER = "org.eclipse.equinox.launcher"; //$NON-NLS-1$
-
- private String flavor;
- private String[] configSpecs;
-
- public EquinoxLauncherCUAction(String flavor, String[] configSpecs) {
- this.flavor = flavor;
- this.configSpecs = configSpecs;
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- setPublisherInfo(publisherInfo);
- publishCU(ORG_ECLIPSE_EQUINOX_LAUNCHER, null, results);
- publishLauncherFragmentCUs(results);
- return Status.OK_STATUS;
- }
-
- /**
- * For each of the configurations we are publishing, create a launcher fragment
- * CU if there is version advice for the fragment.
- */
- private void publishLauncherFragmentCUs(IPublisherResult results) {
- String id = null;
- for (int i = 0; i < configSpecs.length; i++) {
- String configSpec = configSpecs[i];
- String[] specs = Utils.getTokens(configSpec, "."); //$NON-NLS-1$
- if (specs.length > 0 && !AbstractPublisherAction.CONFIG_ANY.equalsIgnoreCase(specs[0])) {
- if (specs.length > 2 && Constants.OS_MACOSX.equals(specs[1]) && !Constants.ARCH_X86_64.equals(specs[2])) {
- //launcher fragment for mac only has arch for x86_64
- id = ORG_ECLIPSE_EQUINOX_LAUNCHER + '.' + specs[0] + '.' + specs[1];
- } else {
- id = ORG_ECLIPSE_EQUINOX_LAUNCHER + '.' + configSpec;
- }
- publishCU(id, configSpec, results);
- }
- }
- }
-
- /**
- * Publish a CU for the IU of the given id in the given config spec. If the IU is the
- * launcher bundle iu then set it up as the startup JAR. If it is a launcher fragment then
- * configure it in as the launcher.library for this configuration.
- */
- private void publishCU(String id, String configSpec, IPublisherResult results) {
- Collection<IVersionAdvice> advice = info.getAdvice(configSpec, true, id, null, IVersionAdvice.class);
- for (IVersionAdvice versionSpec : advice) {
- Version version = versionSpec.getVersion(IInstallableUnit.NAMESPACE_IU_ID, id);
- if (version == null)
- continue;
- GeneratorBundleInfo bundle = new GeneratorBundleInfo();
- bundle.setSymbolicName(id);
- bundle.setVersion(version.toString());
- if (id.equals(ORG_ECLIPSE_EQUINOX_LAUNCHER)) {
- bundle.setSpecialConfigCommands("addProgramArg(programArg:-startup);addProgramArg(programArg:@artifact);"); //$NON-NLS-1$
- bundle.setSpecialUnconfigCommands("removeProgramArg(programArg:-startup);removeProgramArg(programArg:@artifact);"); //$NON-NLS-1$
- } else {
- bundle.setSpecialConfigCommands("addProgramArg(programArg:--launcher.library);addProgramArg(programArg:@artifact);"); //$NON-NLS-1$
- bundle.setSpecialUnconfigCommands("removeProgramArg(programArg:--launcher.library);removeProgramArg(programArg:@artifact);"); //$NON-NLS-1$
- }
- IMatchExpression<IInstallableUnit> filter = configSpec == null ? null : createFilterSpec(configSpec);
- IInstallableUnit cu = BundlesAction.createBundleConfigurationUnit(id, version, false, bundle, flavor, filter);
- if (cu != null)
- results.addIU(cu, IPublisherResult.ROOT);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/Feature.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/Feature.java
deleted file mode 100644
index b57f0eafa..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/Feature.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.util.*;
-
-/**
- *
- * Feature information
- */
-public class Feature {
-
- private final String id;
- private String version;
- private String label;
- private String image;
- private String pluginId;
- private boolean primary = false;
- private boolean exclusive = false;
- private String application;
- private String colocationAffinity;
-
- private URLEntry description;
- private URLEntry license;
- private URLEntry copyright;
-
- private String installHandler;
- private String installHandlerURL;
- private String installHandlerLibrary;
-
- private URLEntry updateSite;
- private ArrayList<URLEntry> discoverySites;
-
- private ArrayList<FeatureEntry> entries;
- private String providerName;
- private String os;
- private String ws;
- private String arch;
- private String nl;
-
- private String location;
-
- private Map<Locale, Map<String, String>> localizations;
-
- public Feature(String id, String version) {
- if (id == null)
- throw new IllegalArgumentException();
- this.id = id;
- this.version = version;
- }
-
- public void addDiscoverySite(String siteLabel, String url) {
- if (siteLabel == null && url == null)
- return;
-
- if (this.discoverySites == null)
- this.discoverySites = new ArrayList<URLEntry>();
-
- URLEntry entry = new URLEntry(url, siteLabel);
- this.discoverySites.add(entry);
- }
-
- public void addEntry(FeatureEntry plugin) {
- if (entries == null)
- entries = new ArrayList<FeatureEntry>();
- entries.add(plugin);
- }
-
- public String getApplication() {
- return application;
- }
-
- public String getArch() {
- return arch;
- }
-
- public String getColocationAffinity() {
- return colocationAffinity;
- }
-
- public String getCopyright() {
- if (copyright != null)
- return copyright.getAnnotation();
- return null;
- }
-
- public String getCopyrightURL() {
- if (copyright != null)
- return copyright.getURL();
- return null;
- }
-
- public String getDescription() {
- if (description != null)
- return description.getAnnotation();
- return null;
- }
-
- public String getDescriptionURL() {
- if (description != null)
- return description.getURL();
- return null;
- }
-
- public URLEntry[] getDiscoverySites() {
- if (discoverySites == null)
- return new URLEntry[0];
- return discoverySites.toArray(new URLEntry[discoverySites.size()]);
- }
-
- public FeatureEntry[] getEntries() {
- if (entries == null)
- return new FeatureEntry[0];
- return entries.toArray(new FeatureEntry[entries.size()]);
- }
-
- public String getId() {
- return id;
- }
-
- public String getImage() {
- return image;
- }
-
- public String getInstallHandler() {
- return installHandler;
- }
-
- public String getInstallHandlerLibrary() {
- return installHandlerLibrary;
- }
-
- public String getInstallHandlerURL() {
- return installHandlerURL;
- }
-
- public String getLabel() {
- return label;
- }
-
- public String getLicense() {
- if (license != null)
- return license.getAnnotation();
- return null;
- }
-
- public String getLicenseURL() {
- if (license != null)
- return license.getURL();
- return null;
- }
-
- public Map<Locale, Map<String, String>> getLocalizations() {
- return this.localizations;
- }
-
- public String getLocation() {
- return this.location;
- }
-
- public String getNL() {
- return nl;
- }
-
- public String getOS() {
- return os;
- }
-
- public String getPlugin() {
- return pluginId;
- }
-
- public String getProviderName() {
- return providerName;
- }
-
- public URLEntry getUpdateSite() {
- return updateSite;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getWS() {
- return ws;
- }
-
- public boolean isExclusive() {
- return exclusive;
- }
-
- public boolean isPrimary() {
- return primary;
- }
-
- public void setApplication(String application) {
- this.application = application;
- }
-
- public void setColocationAffinity(String colocationAffinity) {
- this.colocationAffinity = colocationAffinity;
- }
-
- public void setCopyright(String copyright) {
- if (this.copyright == null)
- this.copyright = new URLEntry();
- this.copyright.setAnnotation(copyright);
- }
-
- public void setCopyrightURL(String copyrightURL) {
- if (this.copyright == null)
- this.copyright = new URLEntry();
- this.copyright.setURL(copyrightURL);
- }
-
- public void setDescription(String description) {
- if (this.description == null)
- this.description = new URLEntry();
- this.description.setAnnotation(description);
- }
-
- public void setDescriptionURL(String descriptionURL) {
- if (this.description == null)
- this.description = new URLEntry();
- this.description.setURL(descriptionURL);
- }
-
- public void setEnvironment(String os, String ws, String arch, String nl) {
- this.os = os;
- this.ws = ws;
- this.arch = arch;
- this.nl = nl;
- }
-
- public void setExclusive(boolean exclusive) {
- this.exclusive = exclusive;
- }
-
- public void setImage(String image) {
- this.image = image;
- }
-
- public void setInstallHandler(String installHandler) {
- this.installHandler = installHandler;
- }
-
- public void setInstallHandlerLibrary(String installHandlerLibrary) {
- this.installHandlerLibrary = installHandlerLibrary;
- }
-
- public void setInstallHandlerURL(String installHandlerURL) {
- this.installHandlerURL = installHandlerURL;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public void setLicense(String license) {
- if (this.license == null)
- this.license = new URLEntry();
- this.license.setAnnotation(license);
- }
-
- public void setLicenseURL(String licenseURL) {
- if (this.license == null)
- this.license = new URLEntry();
- this.license.setURL(licenseURL);
- }
-
- public void setLocalizations(Map<Locale, Map<String, String>> localizations) {
- this.localizations = localizations;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
-
- public void setPlugin(String pluginId) {
- this.pluginId = pluginId;
- }
-
- public void setPrimary(boolean primary) {
- this.primary = primary;
- }
-
- public void setProviderName(String value) {
- providerName = value;
- }
-
- public void setUpdateSiteLabel(String updateSiteLabel) {
- if (this.updateSite == null)
- this.updateSite = new URLEntry();
- this.updateSite.setAnnotation(updateSiteLabel);
- }
-
- public void setUpdateSiteURL(String updateSiteURL) {
- if (this.updateSite == null)
- this.updateSite = new URLEntry();
- this.updateSite.setURL(updateSiteURL);
- }
-
- public void setURL(String value) {
- //
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- /**
- * For debugging purposes only.
- */
- public String toString() {
- return "Feature " + id + " version: " + version; //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeatureEntry.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeatureEntry.java
deleted file mode 100644
index 53c865604..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeatureEntry.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import org.eclipse.equinox.p2.metadata.Version;
-
-/**
- */
-public class FeatureEntry {
- private final String id;
- private String version;
- private String url;
- private String os;
- private String ws;
- private String arch;
- private String nl;
- private String match;
- private final boolean isPlugin;
- private boolean isFragment = false;
- private boolean isRequires = false;
- private boolean unpack = true;
- private boolean optional = false;
- private boolean isPatch = false;
- private String filter;
-
- public static FeatureEntry createRequires(String id, String version, String match, String filter, boolean isPlugin) {
- FeatureEntry result = new FeatureEntry(id, version, isPlugin);
- result.match = match;
- result.isRequires = true;
- // for requires we don't care what the form is so leave it as false (JAR'd)
- result.unpack = false;
- if (filter != null)
- result.setFilter(filter);
- return result;
- }
-
- public FeatureEntry(String id, String version, boolean isPlugin) {
- this.id = id;
- this.version = Version.parseVersion(version).toString();
- this.isPlugin = isPlugin;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final FeatureEntry other = (FeatureEntry) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (version == null) {
- if (other.version != null)
- return false;
- } else if (!version.equals(other.version))
- return false;
-
- if (isPlugin() != other.isPlugin())
- return false;
- if (isRequires() != other.isRequires())
- return false;
- return true;
- }
-
- public String getArch() {
- return arch;
- }
-
- public String getFilter() {
- return filter;
- }
-
- public String getId() {
- return id;
- }
-
- public String getMatch() {
- return match;
- }
-
- public String getNL() {
- return nl;
- }
-
- public String getOS() {
- return os;
- }
-
- public String getURL() {
- return url;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getWS() {
- return ws;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((version == null) ? 0 : version.hashCode());
- return result;
- }
-
- public boolean isFragment() {
- return isFragment;
- }
-
- public boolean isOptional() {
- return optional;
- }
-
- public boolean isPlugin() {
- return isPlugin;
- }
-
- public boolean isRequires() {
- return isRequires;
- }
-
- public boolean isUnpack() {
- return unpack;
- }
-
- public void setEnvironment(String os, String ws, String arch, String nl) {
- this.os = os;
- this.ws = ws;
- this.arch = arch;
- this.nl = nl;
- }
-
- public void setFilter(String filter) {
- this.filter = filter;
-
- }
-
- public void setFragment(boolean value) {
- isFragment = value;
- }
-
- public void setOptional(boolean value) {
- optional = value;
- }
-
- public void setUnpack(boolean value) {
- unpack = value;
- }
-
- public void setURL(String value) {
- url = value;
- }
-
- public void setVersion(String value) {
- version = Version.parseVersion(value).toString();
- }
-
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append(isRequires ? "Requires: " : ""); //$NON-NLS-1$ //$NON-NLS-2$
- result.append(isPlugin ? "Plugin: " : "Feature: "); //$NON-NLS-1$ //$NON-NLS-2$
- result.append(id != null ? id.toString() : ""); //$NON-NLS-1$
- result.append(version != null ? " " + version.toString() : ""); //$NON-NLS-1$ //$NON-NLS-2$
- return result.toString();
- }
-
- public boolean isPatch() {
- return isPatch;
- }
-
- public void setPatch(boolean patch) {
- this.isPatch = patch;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
deleted file mode 100644
index 8467d1a5c..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
+++ /dev/null
@@ -1,659 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import java.util.Map.Entry;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.core.helpers.*;
-import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer;
-import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.p2.publisher.*;
-import org.eclipse.equinox.internal.p2.publisher.Messages;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitPatchDescription;
-import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.publisher.actions.IFeatureRootAdvice;
-import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.IRepositoryReference;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
-import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
-import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
-import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Publish IUs for all of the features in the given set of locations. The locations can
- * be actual locations of the features or folders of features.
- */
-public class FeaturesAction extends AbstractPublisherAction {
- public static final String INSTALL_FEATURES_FILTER = "(org.eclipse.update.install.features=true)"; //$NON-NLS-1$
- private static final String UPDATE_FEATURE_APPLICATION_PROP = "org.eclipse.update.feature.application"; //$NON-NLS-1$
- private static final String UPDATE_FEATURE_PLUGIN_PROP = "org.eclipse.update.feature.plugin"; //$NON-NLS-1$
- private static final String UPDATE_FEATURE_EXCLUSIVE_PROP = "org.eclipse.update.feature.exclusive"; //$NON-NLS-1$
- private static final String UPDATE_FEATURE_PRIMARY_PROP = "org.eclipse.update.feature.primary"; //$NON-NLS-1$
-
- protected Feature[] features;
- private File[] locations;
-
- public static IArtifactKey createFeatureArtifactKey(String id, String version) {
- return new ArtifactKey(PublisherHelper.ECLIPSE_FEATURE_CLASSIFIER, id, Version.parseVersion(version));
- }
-
- public static IInstallableUnit createFeatureJarIU(Feature feature, IPublisherInfo info) {
- InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
- String id = getTransformedId(feature.getId(), /*isPlugin*/false, /*isGroup*/false);
- iu.setId(id);
- Version version = Version.parseVersion(feature.getVersion());
- iu.setVersion(version);
-
- // set properties for other feature attributes
- iu.setProperty(IInstallableUnit.PROP_NAME, feature.getLabel());
- if (feature.getDescription() != null)
- iu.setProperty(IInstallableUnit.PROP_DESCRIPTION, feature.getDescription());
- if (feature.getDescriptionURL() != null)
- iu.setProperty(IInstallableUnit.PROP_DESCRIPTION_URL, feature.getDescriptionURL());
- if (feature.getProviderName() != null)
- iu.setProperty(IInstallableUnit.PROP_PROVIDER, feature.getProviderName());
- if (feature.getLicense() != null)
- iu.setLicenses(new ILicense[] {MetadataFactory.createLicense(toURIOrNull(feature.getLicenseURL()), feature.getLicense())});
- if (feature.getCopyright() != null)
- iu.setCopyright(MetadataFactory.createCopyright(toURIOrNull(feature.getCopyrightURL()), feature.getCopyright()));
- if (feature.getApplication() != null)
- iu.setProperty(UPDATE_FEATURE_APPLICATION_PROP, feature.getApplication());
- if (feature.getPlugin() != null)
- iu.setProperty(UPDATE_FEATURE_PLUGIN_PROP, feature.getPlugin());
- if (feature.isExclusive())
- iu.setProperty(UPDATE_FEATURE_EXCLUSIVE_PROP, Boolean.TRUE.toString());
- if (feature.isPrimary())
- iu.setProperty(UPDATE_FEATURE_PRIMARY_PROP, Boolean.TRUE.toString());
-
- // The required capabilities are not specified at this level because we don't want the feature jar to be attractive to install.
- iu.setTouchpointType(PublisherHelper.TOUCHPOINT_OSGI);
- iu.setFilter(INSTALL_FEATURES_FILTER);
- iu.setSingleton(true);
-
- if (feature.getInstallHandler() != null && feature.getInstallHandler().trim().length() > 0) {
- String installHandlerProperty = "handler=" + feature.getInstallHandler(); //$NON-NLS-1$
-
- if (feature.getInstallHandlerLibrary() != null)
- installHandlerProperty += ", library=" + feature.getInstallHandlerLibrary(); //$NON-NLS-1$
-
- if (feature.getInstallHandlerURL() != null)
- installHandlerProperty += ", url=" + feature.getInstallHandlerURL(); //$NON-NLS-1$
-
- iu.setProperty(PublisherHelper.ECLIPSE_INSTALL_HANDLER_PROP, installHandlerProperty);
- }
-
- ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>();
- providedCapabilities.add(PublisherHelper.createSelfCapability(id, version));
- providedCapabilities.add(PublisherHelper.FEATURE_CAPABILITY);
- providedCapabilities.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_UPDATE_FEATURE, feature.getId(), version));
-
- iu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(id, version), PublisherHelper.FEATURE_CAPABILITY, MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_UPDATE_FEATURE, feature.getId(), version)});
- iu.setArtifacts(new IArtifactKey[] {createFeatureArtifactKey(feature.getId(), version.toString())});
-
- Map<String, String> touchpointData = new HashMap<String, String>();
- touchpointData.put("zipped", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- iu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
-
- Map<Locale, Map<String, String>> localizations = feature.getLocalizations();
- if (localizations != null) {
- for (Entry<Locale, Map<String, String>> locEntry : localizations.entrySet()) {
- Locale locale = locEntry.getKey();
- Map<String, String> translatedStrings = locEntry.getValue();
- for (Entry<String, String> entry : translatedStrings.entrySet()) {
- iu.setProperty(locale.toString() + '.' + entry.getKey(), entry.getValue());
- }
- providedCapabilities.add(PublisherHelper.makeTranslationCapability(id, locale));
- }
- }
-
- processInstallableUnitPropertiesAdvice(iu, info);
- return MetadataFactory.createInstallableUnit(iu);
- }
-
- private static String getTransformedId(String original, boolean isPlugin, boolean isGroup) {
- return (isPlugin ? original : original + (isGroup ? ".feature.group" : ".feature.jar")); //$NON-NLS-1$//$NON-NLS-2$
- }
-
- /**
- * Returns a URI corresponding to the given URL in string form, or null
- * if a well formed URI could not be created.
- */
- private static URI toURIOrNull(String url) {
- if (url == null)
- return null;
- try {
- return URIUtil.fromString(url);
- } catch (URISyntaxException e) {
- return null;
- }
- }
-
- public FeaturesAction(Feature[] features) {
- this.features = features;
- }
-
- public FeaturesAction(File[] locations) {
- this.locations = locations;
- }
-
- /**
- * Looks for advice in a p2.inf file inside the feature location.
- */
- private void createAdviceFileAdvice(Feature feature, IPublisherInfo publisherInfo) {
- //assume p2.inf is co-located with feature.xml
- String location = feature.getLocation();
- if (location != null) {
- String groupId = getTransformedId(feature.getId(), /*isPlugin*/false, /*isGroup*/true);
- AdviceFileAdvice advice = new AdviceFileAdvice(groupId, Version.parseVersion(feature.getVersion()), new Path(location), new Path("p2.inf")); //$NON-NLS-1$
- if (advice.containsAdvice())
- publisherInfo.addAdvice(advice);
- }
- }
-
- /**
- * Gather any advice we can from the given feature. In particular, it may have
- * information about the shape of the bundles it includes. The discovered advice is
- * added to the given result.
- * @param feature the feature to process
- * @param publisherInfo the publishing info to update
- */
- private void createBundleShapeAdvice(Feature feature, IPublisherInfo publisherInfo) {
- FeatureEntry entries[] = feature.getEntries();
- for (int i = 0; i < entries.length; i++) {
- FeatureEntry entry = entries[i];
- if (entry.isUnpack() && entry.isPlugin() && !entry.isRequires())
- publisherInfo.addAdvice(new BundleShapeAdvice(entry.getId(), Version.parseVersion(entry.getVersion()), IBundleShapeAdvice.DIR));
- }
- }
-
- protected IInstallableUnit createFeatureRootFileIU(String featureId, String featureVersion, File location, FileSetDescriptor descriptor) {
- InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
- iu.setSingleton(true);
- String id = featureId + '_' + descriptor.getKey();
- iu.setId(id);
- Version version = Version.parseVersion(featureVersion);
- iu.setVersion(version);
- iu.setCapabilities(new IProvidedCapability[] {PublisherHelper.createSelfCapability(id, version)});
- iu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
- String configSpec = descriptor.getConfigSpec();
- if (configSpec != null && configSpec.length() > 0)
- iu.setFilter(createFilterSpec(configSpec));
-
- Map<String, String> touchpointData = new HashMap<String, String>(2);
- String configurationData = "unzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
- touchpointData.put("install", configurationData); //$NON-NLS-1$
- String unConfigurationData = "cleanupzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
- touchpointData.put("uninstall", unConfigurationData); //$NON-NLS-1$
- iu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
-
- // prime the IU with an artifact key that will correspond to the zipped up root files.
- IArtifactKey key = new ArtifactKey(PublisherHelper.BINARY_ARTIFACT_CLASSIFIER, iu.getId(), iu.getVersion());
- iu.setArtifacts(new IArtifactKey[] {key});
- setupLinks(iu, descriptor);
- setupPermissions(iu, descriptor);
-
- IInstallableUnit iuResult = MetadataFactory.createInstallableUnit(iu);
- // need to return both the iu and any files.
- return iuResult;
- }
-
- protected IInstallableUnit createGroupIU(Feature feature, List<IInstallableUnit> childIUs, IPublisherInfo publisherInfo) {
- if (isPatch(feature))
- return createPatchIU(feature, childIUs, publisherInfo);
- InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
- String id = getGroupId(feature.getId());
- iu.setId(id);
- Version version = PublisherHelper.fromOSGiVersion(new org.osgi.framework.Version(feature.getVersion()));
- iu.setVersion(version);
-
- iu.setProperty(IInstallableUnit.PROP_NAME, feature.getLabel());
- if (feature.getDescription() != null)
- iu.setProperty(IInstallableUnit.PROP_DESCRIPTION, feature.getDescription());
- if (feature.getDescriptionURL() != null)
- iu.setProperty(IInstallableUnit.PROP_DESCRIPTION_URL, feature.getDescriptionURL());
- if (feature.getProviderName() != null)
- iu.setProperty(IInstallableUnit.PROP_PROVIDER, feature.getProviderName());
- if (feature.getLicense() != null)
- iu.setLicenses(new ILicense[] {MetadataFactory.createLicense(toURIOrNull(feature.getLicenseURL()), feature.getLicense())});
- if (feature.getCopyright() != null)
- iu.setCopyright(MetadataFactory.createCopyright(toURIOrNull(feature.getCopyrightURL()), feature.getCopyright()));
- iu.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(id, BundlesAction.computeUpdateRange(new org.osgi.framework.Version(feature.getVersion())), IUpdateDescriptor.NORMAL, null));
-
- FeatureEntry entries[] = feature.getEntries();
- List<IRequirement> required = new ArrayList<IRequirement>(entries.length + (childIUs == null ? 0 : childIUs.size()));
- for (int i = 0; i < entries.length; i++) {
- VersionRange range = getVersionRange(entries[i]);
- String requiredId = getTransformedId(entries[i].getId(), entries[i].isPlugin(), /*isGroup*/true);
- required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, requiredId, range, getFilter(entries[i]), entries[i].isOptional(), false));
- }
-
- // link in all the children (if any) as requirements.
- // TODO consider if these should be linked as exact version numbers. Should be ok but may be brittle.
- if (childIUs != null) {
- for (int i = 0; i < childIUs.size(); i++) {
- IInstallableUnit child = childIUs.get(i);
- IMatchExpression<IInstallableUnit> filter = child.getFilter();
- required.add(MetadataFactory.createRequirement(PublisherHelper.IU_NAMESPACE, child.getId(), new VersionRange(child.getVersion(), true, child.getVersion(), true), filter, false, false));
- }
- }
- iu.setRequirements(required.toArray(new IRequirement[required.size()]));
- iu.setTouchpointType(ITouchpointType.NONE);
- iu.setProperty(InstallableUnitDescription.PROP_TYPE_GROUP, Boolean.TRUE.toString());
- processTouchpointAdvice(iu, null, publisherInfo);
- processInstallableUnitPropertiesAdvice(iu, publisherInfo);
-
- //Create a fake entry to reuse the logic to create the filters
- FeatureEntry entry = new FeatureEntry("fake", "0.0.0", false); //$NON-NLS-1$ //$NON-NLS-2$
- entry.setEnvironment(feature.getOS(), feature.getWS(), feature.getArch(), feature.getNL());
- iu.setFilter(getFilter(entry));
-
- // Create set of provided capabilities
- ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>();
- providedCapabilities.add(createSelfCapability(id, version));
-
- Map<Locale, Map<String, String>> localizations = feature.getLocalizations();
- if (localizations != null) {
- for (Entry<Locale, Map<String, String>> locEntry : localizations.entrySet()) {
- Locale locale = locEntry.getKey();
- Map<String, String> translatedStrings = locEntry.getValue();
- for (Entry<String, String> e : translatedStrings.entrySet()) {
- iu.setProperty(locale.toString() + '.' + e.getKey(), e.getValue());
- }
- providedCapabilities.add(PublisherHelper.makeTranslationCapability(id, locale));
- }
- }
-
- iu.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]));
- processUpdateDescriptorAdvice(iu, info);
- processCapabilityAdvice(iu, publisherInfo);
- return MetadataFactory.createInstallableUnit(iu);
- }
-
- protected String getGroupId(String featureId) {
- return getTransformedId(featureId, /*isPlugin*/false, /*isGroup*/true);
- }
-
- private IInstallableUnit createPatchIU(Feature feature, List<IInstallableUnit> childIUs, IPublisherInfo publisherInfo) {
- InstallableUnitPatchDescription iu = new MetadataFactory.InstallableUnitPatchDescription();
- String id = getTransformedId(feature.getId(), /*isPlugin*/false, /*isGroup*/true);
- iu.setId(id);
- Version version = Version.parseVersion(feature.getVersion());
- iu.setVersion(version);
- iu.setProperty(IInstallableUnit.PROP_NAME, feature.getLabel());
- if (feature.getDescription() != null)
- iu.setProperty(IInstallableUnit.PROP_DESCRIPTION, feature.getDescription());
- if (feature.getDescriptionURL() != null)
- iu.setProperty(IInstallableUnit.PROP_DESCRIPTION_URL, feature.getDescriptionURL());
- if (feature.getProviderName() != null)
- iu.setProperty(IInstallableUnit.PROP_PROVIDER, feature.getProviderName());
- if (feature.getLicense() != null)
- iu.setLicenses(new ILicense[] {MetadataFactory.createLicense(toURIOrNull(feature.getLicenseURL()), feature.getLicense())});
- if (feature.getCopyright() != null)
- iu.setCopyright(MetadataFactory.createCopyright(toURIOrNull(feature.getCopyrightURL()), feature.getCopyright()));
- iu.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(id, BundlesAction.computeUpdateRange(new org.osgi.framework.Version(feature.getVersion())), IUpdateDescriptor.NORMAL, null));
-
- FeatureEntry entries[] = feature.getEntries();
- ArrayList<IRequirement> applicabilityScope = new ArrayList<IRequirement>();
- ArrayList<IRequirement> patchRequirements = new ArrayList<IRequirement>();
- ArrayList<IRequirementChange> requirementChanges = new ArrayList<IRequirementChange>();
- for (int i = 0; i < entries.length; i++) {
- VersionRange range = getVersionRange(entries[i]);
- IRequirement req = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, getTransformedId(entries[i].getId(), entries[i].isPlugin(), /*isGroup*/true), range, getFilter(entries[i]), entries[i].isOptional(), false);
- if (entries[i].isRequires()) {
- applicabilityScope.add(req);
- if (applicabilityScope.size() == 1) {
- iu.setLifeCycle(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, getTransformedId(entries[i].getId(), entries[i].isPlugin(), /*isGroup*/true), range, null, false, false, false));
- }
- continue;
- }
- if (entries[i].isPlugin()) {
- IRequirement from = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, getTransformedId(entries[i].getId(), entries[i].isPlugin(), /*isGroup*/true), VersionRange.emptyRange, getFilter(entries[i]), entries[i].isOptional(), false);
- requirementChanges.add(MetadataFactory.createRequirementChange(from, req));
- continue;
- }
- patchRequirements.add(req);
- }
-
- //Always add a requirement on the IU containing the feature jar
- if (childIUs != null) {
- for (int i = 0; i < childIUs.size(); i++) {
- IInstallableUnit child = childIUs.get(i);
- patchRequirements.add(MetadataFactory.createRequirement(PublisherHelper.IU_NAMESPACE, child.getId(), new VersionRange(child.getVersion(), true, child.getVersion(), true), child.getFilter(), false, false));
- }
- }
- iu.setRequirements(patchRequirements.toArray(new IRequirement[patchRequirements.size()]));
- iu.setApplicabilityScope(new IRequirement[][] {applicabilityScope.toArray(new IRequirement[applicabilityScope.size()])});
- iu.setRequirementChanges(requirementChanges.toArray(new IRequirementChange[requirementChanges.size()]));
-
- iu.setTouchpointType(ITouchpointType.NONE);
- processTouchpointAdvice(iu, null, publisherInfo);
- processInstallableUnitPropertiesAdvice(iu, publisherInfo);
- iu.setProperty(InstallableUnitDescription.PROP_TYPE_GROUP, Boolean.TRUE.toString());
- iu.setProperty(InstallableUnitDescription.PROP_TYPE_PATCH, Boolean.TRUE.toString());
- // TODO: shouldn't the filter for the group be constructed from os, ws, arch, nl
- // of the feature?
- // iu.setFilter(filter);
-
- // Create set of provided capabilities
- ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>();
- providedCapabilities.add(createSelfCapability(id, version));
-
- Map<Locale, Map<String, String>> localizations = feature.getLocalizations();
- if (localizations != null) {
- for (Entry<Locale, Map<String, String>> locEntry : localizations.entrySet()) {
- Locale locale = locEntry.getKey();
- Map<String, String> translatedStrings = locEntry.getValue();
- for (Entry<String, String> e : translatedStrings.entrySet()) {
- iu.setProperty(locale.toString() + '.' + e.getKey(), e.getValue());
- }
- providedCapabilities.add(PublisherHelper.makeTranslationCapability(id, locale));
- }
- }
-
- iu.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]));
- processUpdateDescriptorAdvice(iu, info);
- processCapabilityAdvice(iu, publisherInfo);
- return MetadataFactory.createInstallableUnitPatch(iu);
- }
-
- private File[] expandLocations(File[] list) {
- ArrayList<File> result = new ArrayList<File>();
- expandLocations(list, result);
- return result.toArray(new File[result.size()]);
- }
-
- private void expandLocations(File[] list, ArrayList<File> result) {
- if (list == null)
- return;
- for (int i = 0; i < list.length; i++) {
- File location = list[i];
- if (location.isDirectory()) {
- // if the location is itself a feature, just add it. Otherwise r down
- if (new File(location, "feature.xml").exists()) //$NON-NLS-1$
- result.add(location);
- else
- expandLocations(location.listFiles(), result);
- } else {
- result.add(location);
- }
- }
- }
-
- protected void generateFeatureIUs(Feature[] featureList, IPublisherResult result) {
- // Build Feature IUs, and add them to any corresponding categories
- for (int i = 0; i < featureList.length; i++) {
- Feature feature = featureList[i];
- //first gather any advice that might help us
- createBundleShapeAdvice(feature, info);
- createAdviceFileAdvice(feature, info);
-
- ArrayList<IInstallableUnit> childIUs = new ArrayList<IInstallableUnit>();
-
- IInstallableUnit featureJarIU = queryForIU(result, getTransformedId(feature.getId(), false, false), Version.parseVersion(feature.getVersion()));
- if (featureJarIU == null)
- featureJarIU = generateFeatureJarIU(feature, info);
-
- if (featureJarIU != null) {
- publishFeatureArtifacts(feature, featureJarIU, info);
- result.addIU(featureJarIU, IPublisherResult.NON_ROOT);
- childIUs.add(featureJarIU);
- }
-
- IInstallableUnit groupIU = queryForIU(result, getGroupId(feature.getId()), Version.parseVersion(feature.getVersion()));
- if (groupIU == null) {
- childIUs.addAll(generateRootFileIUs(feature, result, info));
- groupIU = createGroupIU(feature, childIUs, info);
- }
- if (groupIU != null) {
- result.addIU(groupIU, IPublisherResult.ROOT);
- InstallableUnitDescription[] others = processAdditionalInstallableUnitsAdvice(groupIU, info);
- for (int iuIndex = 0; others != null && iuIndex < others.length; iuIndex++) {
- result.addIU(MetadataFactory.createInstallableUnit(others[iuIndex]), IPublisherResult.ROOT);
- }
- }
- generateSiteReferences(feature, result, info);
- }
- }
-
- protected IInstallableUnit generateFeatureJarIU(Feature feature, IPublisherInfo publisherInfo) {
- return createFeatureJarIU(feature, publisherInfo);
- }
-
- protected ArrayList<IInstallableUnit> generateRootFileIUs(Feature feature, IPublisherResult result, IPublisherInfo publisherInfo) {
- ArrayList<IInstallableUnit> ius = new ArrayList<IInstallableUnit>();
-
- Collection<IFeatureRootAdvice> collection = publisherInfo.getAdvice(null, false, feature.getId(), Version.parseVersion(feature.getVersion()), IFeatureRootAdvice.class);
- if (collection.size() == 0)
- return ius;
-
- IFeatureRootAdvice advice = collection.iterator().next();
- String[] configs = advice.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- String config = configs[i];
-
- FileSetDescriptor descriptor = advice.getDescriptor(config);
- if (descriptor != null && descriptor.size() > 0) {
- IInstallableUnit iu = createFeatureRootFileIU(feature.getId(), feature.getVersion(), null, descriptor);
-
- File[] files = descriptor.getFiles();
- IArtifactKey artifactKey = iu.getArtifacts().iterator().next();
- ArtifactDescriptor artifactDescriptor = new ArtifactDescriptor(artifactKey);
- IPathComputer computer = advice.getRootFileComputer(config);
- if (computer == null)
- computer = FileUtils.createDynamicPathComputer(1);
- publishArtifact(artifactDescriptor, files, null, publisherInfo, computer);
-
- result.addIU(iu, IPublisherResult.NON_ROOT);
- ius.add(iu);
- }
- }
-
- return ius;
- }
-
- /**
- * Generates and publishes a reference to an update site location
- * @param location The update site location
- * @param nickname The update site label
- * @param featureId the identifier of the feature where the error occurred, or null
- * @param collector The list into which the references are added
- */
- private void generateSiteReference(String location, String nickname, String featureId, List<IRepositoryReference> collector) {
- if (location == null) {
- String message = featureId == null ? NLS.bind(Messages.exception_invalidSiteReference, location) : NLS.bind(Messages.exception_invalidSiteReferenceInFeature, location, featureId);
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message));
- return;
- }
-
- try {
- URI associateLocation = new URI(location);
- collector.add(new RepositoryReference(associateLocation, nickname, IRepository.TYPE_METADATA, IRepository.NONE));
- collector.add(new RepositoryReference(associateLocation, nickname, IRepository.TYPE_ARTIFACT, IRepository.NONE));
- } catch (URISyntaxException e) {
- String message = featureId == null ? NLS.bind(Messages.exception_invalidSiteReference, location) : NLS.bind(Messages.exception_invalidSiteReferenceInFeature, location, featureId);
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message));
- }
- }
-
- protected void generateSiteReferences(Feature feature, IPublisherResult result, IPublisherInfo publisherInfo) {
- if (publisherInfo.getMetadataRepository() == null)
- return;
-
- //publish feature site references
- URLEntry updateURL = feature.getUpdateSite();
- //don't enable feature update sites by default since this results in too many
- //extra sites being loaded and searched (Bug 234177)
- List<IRepositoryReference> collector = new ArrayList<IRepositoryReference>();
- if (updateURL != null)
- generateSiteReference(updateURL.getURL(), updateURL.getAnnotation(), feature.getId(), collector);
- URLEntry[] discoverySites = feature.getDiscoverySites();
- for (int i = 0; i < discoverySites.length; i++)
- generateSiteReference(discoverySites[i].getURL(), discoverySites[i].getAnnotation(), feature.getId(), collector);
- if (!collector.isEmpty())
- publisherInfo.getMetadataRepository().addReferences(collector);
- }
-
- protected Feature[] getFeatures(File[] featureLocations) {
- ArrayList<Feature> result = new ArrayList<Feature>(featureLocations.length);
- for (int i = 0; i < featureLocations.length; i++) {
- Feature feature = new FeatureParser().parse(featureLocations[i]);
- if (feature != null) {
- feature.setLocation(featureLocations[i].getAbsolutePath());
- result.add(feature);
- }
- }
- return result.toArray(new Feature[result.size()]);
- }
-
- private IMatchExpression<IInstallableUnit> getFilter(FeatureEntry entry) {
- StringBuffer result = new StringBuffer();
- result.append("(&"); //$NON-NLS-1$
- if (entry.getFilter() != null)
- result.append(entry.getFilter());
- expandFilter(entry.getOS(), "osgi.os", result); //$NON-NLS-1$
- expandFilter(entry.getWS(), "osgi.ws", result); //$NON-NLS-1$
- expandFilter(entry.getArch(), "osgi.arch", result);//$NON-NLS-1$
- expandFilter(entry.getNL(), "osgi.nl", result); //$NON-NLS-1$
- if (result.length() == 2)
- return null;
- result.append(')');
- return InstallableUnit.parseFilter(result.toString());
- }
-
- private void expandFilter(String filter, String osgiFilterValue, StringBuffer result) {
- if (filter != null && filter.length() != 0) {
- StringTokenizer token = new StringTokenizer(filter, ","); //$NON-NLS-1$
- if (token.countTokens() == 1)
- result.append('(' + osgiFilterValue + '=' + filter + ')');
- else {
- result.append("(|"); //$NON-NLS-1$
- while (token.hasMoreElements()) {
- result.append('(' + osgiFilterValue + '=' + token.nextToken() + ')');
- }
- result.append(')');
- }
- }
- }
-
- protected VersionRange getVersionRange(FeatureEntry entry) {
- String versionSpec = entry.getVersion();
- if (versionSpec == null)
- return VersionRange.emptyRange;
- Version version = Version.parseVersion(versionSpec);
- if (version.equals(Version.emptyVersion))
- return VersionRange.emptyRange;
- if (!entry.isRequires())
- return new VersionRange(version, true, version, true);
- String match = entry.getMatch();
- if (match == null)
- // TODO should really be returning VersionRange.emptyRange here...
- return null;
- if (match.equals("perfect")) //$NON-NLS-1$
- return new VersionRange(version, true, version, true);
-
- org.osgi.framework.Version osgiVersion = PublisherHelper.toOSGiVersion(version);
- if (match.equals("equivalent")) { //$NON-NLS-1$
- Version upper = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor() + 1, 0);
- return new VersionRange(version, true, upper, false);
- }
- if (match.equals("compatible")) { //$NON-NLS-1$
- Version upper = Version.createOSGi(osgiVersion.getMajor() + 1, 0, 0);
- return new VersionRange(version, true, upper, false);
- }
- if (match.equals("greaterOrEqual")) //$NON-NLS-1$
- return new VersionRange(version, true, new VersionRange(null).getMaximum(), true);
- return null;
- }
-
- private boolean isPatch(Feature feature) {
- FeatureEntry[] entries = feature.getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].isPatch())
- return true;
- }
- return false;
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- if (features == null && locations == null)
- throw new IllegalStateException(Messages.exception_noFeaturesOrLocations);
- this.info = publisherInfo;
- if (features == null)
- features = getFeatures(expandLocations(locations));
- generateFeatureIUs(features, results);
- return Status.OK_STATUS;
- }
-
- protected void publishFeatureArtifacts(Feature feature, IInstallableUnit featureIU, IPublisherInfo publisherInfo) {
- // add all the artifacts associated with the feature
- // TODO this is a little strange. If there are several artifacts, how do we know which files go with
- // which artifacts when we publish them? For now it would be surprising to have more than one
- // artifact per feature IU.
- Collection<IArtifactKey> artifacts = featureIU.getArtifacts();
- for (IArtifactKey artifactKey : artifacts) {
- File file = new File(feature.getLocation());
- ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, artifactKey, file);
- processArtifactPropertiesAdvice(featureIU, ad, publisherInfo);
- ad.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, IArtifactDescriptor.TYPE_ZIP);
- // if the artifact is a dir then zip it up.
- if (file.isDirectory())
- publishArtifact(ad, new File[] {file}, null, publisherInfo, createRootPrefixComputer(file));
- else
- publishArtifact(ad, file, publisherInfo);
- }
- }
-
- private void setupLinks(InstallableUnitDescription iu, FileSetDescriptor descriptor) {
- String[] links = getArrayFromString(descriptor.getLinks(), ","); //$NON-NLS-1$
- StringBuffer linkActions = new StringBuffer();
-
- int i = 0;
- while (i < links.length) {
- //format is [target,name]*
- String target = links[i++];
- if (i < links.length) {
- String name = links[i++];
- linkActions.append("ln(linkTarget:" + target); //$NON-NLS-1$
- linkActions.append(",targetDir:${installFolder},linkName:" + name); //$NON-NLS-1$
- linkActions.append(");"); //$NON-NLS-1$
- }
-
- }
-
- if (linkActions.length() > 0) {
- Map<String, String> touchpointData = new HashMap<String, String>();
- //we do ln during configure to avoid complicating branding which uses the install phase
- touchpointData.put("configure", linkActions.toString()); //$NON-NLS-1$
- iu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
- }
- }
-
- private void setupPermissions(InstallableUnitDescription iu, FileSetDescriptor descriptor) {
- Map<String, String> touchpointData = new HashMap<String, String>();
- String[][] permsList = descriptor.getPermissions();
- for (int i = 0; i < permsList.length; i++) {
- String[] permSpec = permsList[i];
- String configurationData = " chmod(targetDir:${installFolder}, targetFile:" + permSpec[1] + ", permissions:" + permSpec[0] + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- touchpointData.put("install", configurationData); //$NON-NLS-1$
- iu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAndBundlesPublisherApplication.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAndBundlesPublisherApplication.java
deleted file mode 100644
index 516cb99b8..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAndBundlesPublisherApplication.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.publisher.actions.RootIUAction;
-import org.eclipse.equinox.p2.publisher.actions.RootIUResultFilterAdvice;
-
-/**
- * <p>
- * This application generates meta-data and artifact repositories from a set of features and bundles.
- * If -source <localdir> parameter is given, it specifies the directory under which to find the features
- * and bundles (in the standard "features" and "plugins" sub-directories).
- * </p><p>
- * Optionally, the -features <csv of file locations> and -bundles <csv of file locations> arguments can
- * be specified. If given, these override the defaults derived from a supplied -source parameter.
- * </p>
- */
-public class FeaturesAndBundlesPublisherApplication extends AbstractPublisherApplication {
-
- protected File[] features = null;
- protected File[] bundles = null;
-
- protected String rootIU = null;
- protected String rootVersion = null;
-
- public FeaturesAndBundlesPublisherApplication() {
- // nothing to do
- }
-
- protected void processParameter(String arg, String parameter, PublisherInfo pinfo) throws URISyntaxException {
- super.processParameter(arg, parameter, pinfo);
-
- if (arg.equalsIgnoreCase("-features")) //$NON-NLS-1$
- features = createFiles(parameter);
-
- if (arg.equalsIgnoreCase("-bundles")) //$NON-NLS-1$
- bundles = createFiles(parameter);
-
- if (arg.equalsIgnoreCase("-iu")) //$NON-NLS-1$
- rootIU = parameter;
-
- if (arg.equalsIgnoreCase("-version")) //$NON-NLS-1$
- rootVersion = parameter;
- }
-
- private File[] createFiles(String parameter) {
- String[] filespecs = AbstractPublisherAction.getArrayFromString(parameter, ","); //$NON-NLS-1$
- File[] result = new File[filespecs.length];
- for (int i = 0; i < filespecs.length; i++)
- result[i] = new File(filespecs[i]);
- return result;
- }
-
- protected IPublisherAction[] createActions() {
- ArrayList<IPublisherAction> result = new ArrayList<IPublisherAction>();
- if (features == null)
- features = new File[] {new File(source, "features")}; //$NON-NLS-1$
- result.add(new FeaturesAction(features));
- if (bundles == null)
- bundles = new File[] {new File(source, "plugins")}; //$NON-NLS-1$
- result.add(new BundlesAction(bundles));
-
- if (rootIU != null) {
- result.add(new RootIUAction(rootIU, Version.parseVersion(rootVersion), rootIU));
- info.addAdvice(new RootIUResultFilterAdvice(null));
- }
-
- return result.toArray(new IPublisherAction[result.size()]);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IBrandingAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IBrandingAdvice.java
deleted file mode 100644
index 6f4952079..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IBrandingAdvice.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 EclipseSource and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * EclipseSource - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import org.eclipse.equinox.p2.publisher.IPublisherAdvice;
-
-/**
- * Advice for branding executables and other element while publishing.
- */
-public interface IBrandingAdvice extends IPublisherAdvice {
-
- /**
- * Returns the OS that this branding advice is relevant for.
- */
- public String getOS();
-
- /**
- * Returns the list of icon files to be used in branding an executable.
- * The nature of the returned values and the images they represent is
- * platform-specific.
- *
- * @return the list of icons used in branding an executable or <code>null</code> if none.
- */
- public String[] getIcons();
-
- /**
- * Returns the name of the launcher. This should be the OS-independent
- * name. That is, ".exe" etc. should not be included.
- *
- * @return the name of the branded launcher or <code>null</code> if none.
- */
- public String getExecutableName();
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IBundleShapeAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IBundleShapeAdvice.java
deleted file mode 100644
index 8ad1badd5..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IBundleShapeAdvice.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import org.eclipse.equinox.p2.publisher.IPublisherAdvice;
-
-public interface IBundleShapeAdvice extends IPublisherAdvice {
- public static final String DIR = BundlesAction.DIR;
- public static final String JAR = BundlesAction.JAR;
-
- public String getShape();
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IConfigAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IConfigAdvice.java
deleted file mode 100644
index 6c8eefd6a..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IConfigAdvice.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.util.Map;
-import org.eclipse.equinox.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.p2.publisher.IPublisherAdvice;
-
-public interface IConfigAdvice extends IPublisherAdvice {
-
- public BundleInfo[] getBundles();
-
- public Map<String, String> getProperties();
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IExecutableAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IExecutableAdvice.java
deleted file mode 100644
index 7d46675f3..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/IExecutableAdvice.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * EclipseSource - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import org.eclipse.equinox.p2.publisher.IPublisherAdvice;
-
-/**
- * Advice for executables while publishing.
- */
-public interface IExecutableAdvice extends IPublisherAdvice {
-
- /**
- * Returns the VM arguments for this executable.
- * @return The list of VM Arguments for this executable or empty array for none
- */
- public String[] getVMArguments();
-
- /**
- * Returns the program arguments for this executable.
- *
- * @return The list of program arguments for tihs executable or empty array for none
- */
- public String[] getProgramArguments();
-
- /**
- * Returns the name of the launcher. This should be the OS-independent
- * name. That is, ".exe" etc. should not be included.
- *
- * @return the name of the branded launcher or <code>null</code> if none.
- */
- public String getExecutableName();
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/InstallPublisherApplication.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/InstallPublisherApplication.java
deleted file mode 100644
index ae180c257..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/InstallPublisherApplication.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.publisher.*;
-
-public class InstallPublisherApplication extends AbstractPublisherApplication {
-
- protected String id;
- protected Version version = Version.parseVersion("1.0.0"); //$NON-NLS-1$
- protected String name;
- protected String executableName;
- protected String flavor;
- protected IVersionedId[] topLevel;
- protected boolean start;
- protected String[] rootExclusions;
-
- public InstallPublisherApplication() {
- //hidden
- }
-
- protected void processFlag(String arg, PublisherInfo publisherInfo) {
- super.processFlag(arg, publisherInfo);
-
- if (arg.equalsIgnoreCase("-startAll")) //$NON-NLS-1$
- start = true;
- }
-
- protected void initialize(PublisherInfo publisherInfo) throws ProvisionException {
- super.initialize(publisherInfo);
-
- if (publisherInfo.getConfigurations().length == 0)
- publisherInfo.setConfigurations(new String[] {""}); //$NON-NLS-1$
- }
-
- protected void processParameter(String arg, String parameter, PublisherInfo publisherInfo) throws URISyntaxException {
- super.processParameter(arg, parameter, publisherInfo);
-
- if (arg.equalsIgnoreCase("-id")) //$NON-NLS-1$
- id = parameter;
-
- if (arg.equalsIgnoreCase("-version")) //$NON-NLS-1$
- version = Version.parseVersion(parameter);
-
- if (arg.equalsIgnoreCase("-name")) //$NON-NLS-1$
- name = parameter;
-
- if (arg.equalsIgnoreCase("-executable")) //$NON-NLS-1$
- executableName = parameter;
-
- if (arg.equalsIgnoreCase("-flavor")) //$NON-NLS-1$
- flavor = parameter;
-
- if (arg.equalsIgnoreCase("-top")) //$NON-NLS-1$
- topLevel = createVersionedIdList(parameter);
-
- if (arg.equalsIgnoreCase("-rootExclusions")) //$NON-NLS-1$
- rootExclusions = AbstractPublisherAction.getArrayFromString(parameter, ","); //$NON-NLS-1$
- }
-
- private IVersionedId[] createVersionedIdList(String parameter) {
- String[] list = AbstractPublisherAction.getArrayFromString(parameter, ","); //$NON-NLS-1$
- IVersionedId[] result = new IVersionedId[list.length];
- for (int i = 0; i < result.length; i++)
- result[i] = VersionedId.parse(list[i]);
- return result;
- }
-
- protected IPublisherAction[] createActions() {
- ArrayList<IPublisherAction> result = new ArrayList<IPublisherAction>();
- result.add(createEclipseInstallAction());
- return result.toArray(new IPublisherAction[result.size()]);
- }
-
- private IPublisherAction createEclipseInstallAction() {
- String[] exclusions = getBaseExclusions();
- if (rootExclusions != null) {
- String[] result = new String[exclusions.length + rootExclusions.length];
- System.arraycopy(exclusions, 0, result, 0, exclusions.length);
- System.arraycopy(rootExclusions, 0, result, exclusions.length, rootExclusions.length);
- exclusions = result;
- }
- return new EclipseInstallAction(source, id, version, name, executableName, flavor, topLevel, exclusions, start);
- }
-
- protected String[] getBaseExclusions() {
- return new String[] {"plugins", "features", "configuration", "p2", "artifacts.xml"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/LaunchingAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/LaunchingAdvice.java
deleted file mode 100644
index 72647823e..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/LaunchingAdvice.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-
-import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
-import org.eclipse.equinox.p2.publisher.AbstractAdvice;
-
-public class LaunchingAdvice extends AbstractAdvice implements IExecutableAdvice {
-
- private LauncherData data;
- private String configSpec;
-
- public LaunchingAdvice(LauncherData data, String configSpec) {
- this.data = data;
- this.configSpec = configSpec;
- }
-
- protected String getConfigSpec() {
- return configSpec;
- }
-
- public String[] getProgramArguments() {
- return data.getProgramArgs();
- }
-
- public String[] getVMArguments() {
- return data.getJvmArgs();
- }
-
- public String getExecutableName() {
- return data.getLauncherName();
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java
deleted file mode 100644
index a5ad2675c..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.metadata.VersionedId;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.publisher.actions.*;
-
-public class ProductAction extends AbstractPublisherAction {
- protected String source;
- protected String id;
- protected Version version;
- protected String name;
- protected String executableName;
- protected String flavor;
- protected boolean start = false;
- //protected String productLocation;
- protected File executablesFeatureLocation;
- protected IProductDescriptor product;
- protected IPublisherResult publisherResults;
-
- public ProductAction(String source, IProductDescriptor product, String flavor, File executablesFeatureLocation) {
- super();
- this.source = source;
- this.flavor = flavor;
- this.executablesFeatureLocation = executablesFeatureLocation;
- this.product = product;
- //this.productLocation = productLocation;
- }
-
- protected IPublisherAction[] createActions(IPublisherResult results) {
- // generate the advice we can up front.
- createAdvice();
-
- // create all the actions needed to publish a product
- ArrayList<IPublisherAction> actions = new ArrayList<IPublisherAction>();
- // products include the executable so add actions to publish them
- if (getExecutablesLocation() != null && this.product.includeLaunchers())
- actions.add(createApplicationExecutableAction(info.getConfigurations()));
- // add the actions that just configure things.
- actions.add(createConfigCUsAction());
- actions.add(createJREAction());
- actions.add(createDefaultCUsAction());
- actions.add(createRootIUAction());
- return actions.toArray(new IPublisherAction[actions.size()]);
- }
-
- protected IPublisherAction createApplicationExecutableAction(String[] configSpecs) {
- return new ApplicationLauncherAction(id, version, flavor, executableName, getExecutablesLocation(), configSpecs);
- }
-
- protected IPublisherAction createDefaultCUsAction() {
- return new DefaultCUsAction(info, flavor, 4, false);
- }
-
- protected IPublisherAction createRootIUAction() {
- return new RootIUAction(id, version, name);
- }
-
- protected IPublisherAction createConfigCUsAction() {
- return new ConfigCUsAction(info, flavor, id, version);
- }
-
- protected IPublisherAction createJREAction() {
- //TODO set a proper execution environment
- return new JREAction((String) null);
- }
-
- public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
- monitor = SubMonitor.convert(monitor);
- this.info = publisherInfo;
- publisherResults = results;
- IPublisherAction[] actions = createActions(results);
- MultiStatus finalStatus = new MultiStatus(EclipseInstallAction.class.getName(), 0, "publishing result", null); //$NON-NLS-1$
- for (int i = 0; i < actions.length; i++) {
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- finalStatus.merge(actions[i].perform(publisherInfo, results, monitor));
- }
- if (!finalStatus.isOK())
- return finalStatus;
-
- return Status.OK_STATUS;
- }
-
- private void createAdvice() {
- executableName = product.getLauncherName();
- createProductAdvice();
- createAdviceFileAdvice();
- createRootAdvice();
- info.addAdvice(new RootIUResultFilterAdvice(null));
- }
-
- /**
- * Create advice for a p2.inf file co-located with the product file, if any.
- */
- private void createAdviceFileAdvice() {
- File productFileLocation = product.getLocation();
- if (productFileLocation == null)
- return;
-
- AdviceFileAdvice advice = new AdviceFileAdvice(product.getId(), Version.parseVersion(product.getVersion()), new Path(productFileLocation.getParent()), new Path("p2.inf")); //$NON-NLS-1$
- if (advice.containsAdvice())
- info.addAdvice(advice);
- }
-
- private void createRootAdvice() {
- Collection<IVersionedId> list;
- if (product.useFeatures())
- // TODO: We need a real namespace here
- list = versionElements(listElements(product.getFeatures(), ".feature.group"), IInstallableUnit.NAMESPACE_IU_ID); //$NON-NLS-1$
- else
- //TODO: We need a real namespace here
- list = versionElements(listElements(product.getBundles(true), null), IInstallableUnit.NAMESPACE_IU_ID);
- info.addAdvice(new RootIUAdvice(list));
- }
-
- private void createProductAdvice() {
- id = product.getId();
- version = Version.parseVersion(product.getVersion());
- name = product.getProductName();
- if (name == null || name.length() == 0) // If the name is not defined, use the ID
- name = product.getId();
-
- String[] configSpecs = info.getConfigurations();
- for (int i = 0; i < configSpecs.length; i++)
- info.addAdvice(new ProductFileAdvice(product, configSpecs[i]));
- }
-
- private Collection<IVersionedId> versionElements(Collection<IVersionedId> elements, String namespace) {
- Collection<IVersionAdvice> versionAdvice = info.getAdvice(null, true, null, null, IVersionAdvice.class);
- List<IVersionedId> result = new ArrayList<IVersionedId>();
- for (IVersionedId element : elements) {
- Version elementVersion = element.getVersion();
- if (elementVersion == null || Version.emptyVersion.equals(elementVersion)) {
- Iterator<IVersionAdvice> advice = versionAdvice.iterator();
- while (advice.hasNext()) {
- elementVersion = advice.next().getVersion(namespace, element.getId());
- break;
- }
- }
-
- // if advisedVersion is null, we get the highest version
- IInstallableUnit unit = queryForIU(publisherResults, element.getId(), elementVersion);
- if (unit != null) {
- result.add(unit);
- } else if (elementVersion != null) {
- //best effort
- result.add(new VersionedId(element.getId(), elementVersion));
- }
- //TODO we could still add a requirement on version 0.0.0 to get any version, but if the
- //bundle is platform specific we will have broken metadata due to a missing filter
- }
- return result;
- }
-
- private Collection<IVersionedId> listElements(List<IVersionedId> elements, String suffix) {
- if (suffix == null || suffix.length() == 0)
- return elements;
- ArrayList<IVersionedId> result = new ArrayList<IVersionedId>(elements.size());
- for (IVersionedId elementName : elements) {
- result.add(new VersionedId(elementName.getId() + suffix, elementName.getVersion()));
- }
- return result;
- }
-
- protected File getExecutablesLocation() {
- if (executablesFeatureLocation != null)
- return executablesFeatureLocation;
- if (source != null)
- return new File(source);
- return null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java
deleted file mode 100644
index e054e7fc5..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * EclipseSource - ongoing development
- * IBM Corporation - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import java.util.*;
-import org.eclipse.equinox.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.DataLoader;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor;
-import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData;
-import org.eclipse.equinox.p2.metadata.IVersionedId;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.publisher.AbstractAdvice;
-import org.eclipse.equinox.p2.publisher.AbstractPublisherAction;
-import org.eclipse.equinox.p2.publisher.actions.ILicenseAdvice;
-
-/**
- * Provide advice derived from the .product file. The product can give some info on
- * launching as well as the configuration (bundles, properties, ...)
- */
-public class ProductFileAdvice extends AbstractAdvice implements ILicenseAdvice, IExecutableAdvice, IConfigAdvice, IBrandingAdvice {
- private final static String OSGI_SPLASH_PATH = "osgi.splashPath"; //$NON-NLS-1$
- private final static String SPLASH_PREFIX = "platform:/base/plugins/"; //$NON-NLS-1$
- private IProductDescriptor product;
- private String configSpec;
- private String ws;
- private String os;
- private String arch;
- private ConfigData configData = null;
-
- protected String getId() {
- return product.getId();
- }
-
- protected Version getVersion() {
- return Version.parseVersion(product.getVersion());
- }
-
- /**
- * Constructs a new ProductFileAdvice for a given product file and a
- * particular configuration. Configurations are
- * specified as: ws.os.arch where:
- * ws is the windowing system
- * os is the operating system
- * arch is the architecture
- */
- public ProductFileAdvice(IProductDescriptor product, String configSpec) {
- this.product = product;
- this.configSpec = configSpec;
-
- String[] config = AbstractPublisherAction.parseConfigSpec(configSpec);
- ws = config[0];
- if (ws == null)
- ws = AbstractPublisherAction.CONFIG_ANY;
- os = config[1];
- if (os == null)
- os = AbstractPublisherAction.CONFIG_ANY;
- arch = config[2];
- if (arch == null)
- arch = AbstractPublisherAction.CONFIG_ANY;
-
- configData = getConfigData();
- }
-
- /**
- * Returns the program arguments for this product.
- */
- public String[] getProgramArguments() {
- String line = product.getProgramArguments(os);
- return AbstractPublisherAction.getArrayFromString(line, " "); //$NON-NLS-1$
- }
-
- /**
- * Returns the VM arguments for this product.
- */
- public String[] getVMArguments() {
- String line = product.getVMArguments(os);
- return AbstractPublisherAction.getArrayFromString(line, " "); //$NON-NLS-1$
- }
-
- /**
- * Returns the Bundles that constitute this product. These
- * bundles may be specified in the .product file, .product file configuration
- * area, config.ini file, or a combination of these three places.
- */
- public BundleInfo[] getBundles() {
- return configData.getBundles();
- }
-
- /**
- * Returns the properties associated with this product. These
- * properties may be defined in the .product file, the config.ini
- * file, or both.
- */
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<String, String>();
- CollectionUtils.putAll(configData.getProperties(), result);
- result.putAll(product.getConfigurationProperties());
- return result;
- }
-
- /**
- * Returns the name of the launcher. This should be the OS-independent
- * name. That is, ".exe" etc. should not be included.
- *
- * @return the name of the branded launcher or <code>null</code> if none.
- */
- public String getExecutableName() {
- return product.getLauncherName();
- }
-
- /**
- * Returns the product file parser that this advice is working on
- */
- public IProductDescriptor getProductFile() {
- return product;
- }
-
- /**
- * Returns the icons defined for this product
- */
- public String[] getIcons() {
- return product.getIcons(os);
- }
-
- /**
- * Returns the operating system that this advice is configured to work with.
- */
- public String getOS() {
- return this.os;
- }
-
- /**
- * Returns the license text for this product
- */
- public String getLicenseURL() {
- return product.getLicenseURL();
- }
-
- /**
- * Returns the license URL for this product
- */
- public String getLicenseText() {
- return product.getLicenseText();
- }
-
- private ConfigData getConfigData() {
- DataLoader loader = createDataLoader();
- ConfigData result;
- if (loader != null) {
- result = loader.getConfigData();
- } else
- result = generateConfigData();
-
- addProductFileBundles(result); // these are the bundles specified in the <plugins/> tag
- addProductFileConfigBundles(result); // these are the bundles specified in the <configurations> tag in the product file
-
- if (product.getProductId() != null)
- result.setProperty("eclipse.product", product.getProductId()); //$NON-NLS-1$
- if (product.getApplication() != null)
- result.setProperty("eclipse.application", product.getApplication()); //$NON-NLS-1$
- String location = getSplashLocation();
- if (location != null)
- result.setProperty(OSGI_SPLASH_PATH, SPLASH_PREFIX + location);
- return result;
- }
-
- private void addProductFileConfigBundles(ConfigData data) {
- Set<BundleInfo> versionBoundBundles = new HashSet<BundleInfo>();
- Map<String, List<BundleInfo>> unboundedBundles = new HashMap<String, List<BundleInfo>>();
-
- BundleInfo[] bundles = data.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- // For each bundle we know about, cache it. If the bundle doesn't have a version
- // add it to a list of bundles by name
- BundleInfo bundleInfo = bundles[i];
- if (bundleInfo.getVersion().equals(BundleInfo.EMPTY_VERSION)) {
- addUnboundedBundle(unboundedBundles, bundleInfo);
- } else {
- versionBoundBundles.add(bundleInfo);
- addUnboundedBundle(unboundedBundles, bundleInfo);
- }
- }
-
- List<BundleInfo> bundleInfos = product.getBundleInfos();
- for (BundleInfo bundleInfo : bundleInfos) {
- // For each bundle that has configuration information, if the bundle is in the
- // bundles bound by version, add the "configured" bundle instead
- // If the bundle is not bound to a version, then replace all bounded versions
- // with this one. Otherwise, just add this one (don't replace)
- if (versionBoundBundles.contains(bundleInfo)) {
- // If we found a version with the same name and version, replace it with the "configured" bundle
- data.removeBundle(bundleInfo);
- data.addBundle(bundleInfo);
- } else if (bundleInfo.getVersion().equals(BundleInfo.EMPTY_VERSION)) {
- // If we don't have a version number, look for all bundles that match by name
- List<BundleInfo> list = unboundedBundles.get(bundleInfo.getSymbolicName());
- if (list == null)
- data.addBundle(bundleInfo);
- else
- for (BundleInfo target : list) {
- target.setStartLevel(bundleInfo.getStartLevel());
- target.setMarkedAsStarted(bundleInfo.isMarkedAsStarted());
- }
- } else {
- // Otherwise we have a version, but we could not match it, so just add this one.
- data.addBundle(bundleInfo);
- }
-
- }
- }
-
- private void addUnboundedBundle(Map<String, List<BundleInfo>> data, BundleInfo bundleInfo) {
- if (!data.containsKey(bundleInfo.getSymbolicName()))
- data.put(bundleInfo.getSymbolicName(), new LinkedList<BundleInfo>());
- data.get(bundleInfo.getSymbolicName()).add(bundleInfo);
- }
-
- private void addProductFileBundles(ConfigData data) {
- List<IVersionedId> bundles = product.getBundles(true);
- Set<BundleInfo> set = new HashSet<BundleInfo>();
- set.addAll(Arrays.asList(data.getBundles()));
-
- for (IVersionedId vid : bundles) {
- BundleInfo bundleInfo = new BundleInfo();
- bundleInfo.setSymbolicName(vid.getId());
- bundleInfo.setVersion(vid.getVersion().toString());
- if (!set.contains(bundleInfo))
- data.addBundle(bundleInfo);
- }
- }
-
- private ConfigData generateConfigData() {
- ConfigData result = new ConfigData(null, null, null, null);
- if (product.useFeatures())
- return result;
-
- // Add all the bundles here. We replace / update them later
- // if we find configuration information
- List<IVersionedId> bundles = product.getBundles(true);
- for (IVersionedId vid : bundles) {
- BundleInfo bundleInfo = new BundleInfo();
- bundleInfo.setSymbolicName(vid.getId());
- bundleInfo.setVersion(vid.getVersion().toString());
- result.addBundle(bundleInfo);
- }
- return result;
- }
-
- private String getSplashLocation() {
- return product.getSplashLocation();
- }
-
- protected String getConfigSpec() {
- return configSpec;
- }
-
- protected boolean matchConfig(String spec, boolean includeDefault) {
- if (spec != null) {
- String targetWS = AbstractPublisherAction.parseConfigSpec(spec)[0];
- if (targetWS == null)
- targetWS = AbstractPublisherAction.CONFIG_ANY;
- if (!ws.equals(targetWS) && !ws.equals(AbstractPublisherAction.CONFIG_ANY) && !targetWS.equals(AbstractPublisherAction.CONFIG_ANY)) {
- return false;
- }
-
- String targetOS = AbstractPublisherAction.parseConfigSpec(spec)[1];
- if (targetOS == null)
- targetOS = AbstractPublisherAction.CONFIG_ANY;
- if (!os.equals(targetOS) && !os.equals(AbstractPublisherAction.CONFIG_ANY) && !targetOS.equals(AbstractPublisherAction.CONFIG_ANY)) {
- return false;
- }
-
- String targetArch = AbstractPublisherAction.parseConfigSpec(spec)[2];
- if (targetArch == null)
- targetArch = AbstractPublisherAction.CONFIG_ANY;
- if (!arch.equals(targetArch) && !arch.equals(AbstractPublisherAction.CONFIG_ANY) && !targetArch.equals(AbstractPublisherAction.CONFIG_ANY)) {
- return false;
- }
- }
- return true;
- }
-
- private DataLoader createDataLoader() {
- String location = product.getConfigIniPath(os);
- if (location == null)
- location = product.getConfigIniPath(null);
- if (location == null)
- return null;
-
- File configFile = new File(location);
- // We are assuming we are always relative from the product file
- // However PDE tooling puts us relative from the workspace, that "relative" path also looks like an absolute path on linux
- // Build may have copied the file to the correct place for us
- if (!configFile.isAbsolute() || !configFile.exists())
- configFile = new File(product.getLocation().getParentFile(), location);
-
- //We don't really have an executable location, get something reasonable based on the config.ini location
- File parent = configFile.getParentFile();
- if (parent.getName().equals("configuration") && parent.getParentFile() != null) //$NON-NLS-1$
- parent = parent.getParentFile();
- return new DataLoader(configFile, parent);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java
deleted file mode 100644
index eba846360..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- ******************************************************************************/
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import org.eclipse.equinox.internal.p2.publisher.Messages;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor;
-import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.publisher.*;
-import org.eclipse.equinox.p2.publisher.actions.VersionAdvice;
-import org.eclipse.osgi.util.NLS;
-
-public class ProductPublisherApplication extends AbstractPublisherApplication {
-
- private String product;
- private String executables;
- private String flavor;
-
- public ProductPublisherApplication() {
- //hidden
- }
-
- protected IPublisherAction[] createActions() {
- ArrayList<IPublisherAction> result = new ArrayList<IPublisherAction>();
- result.add(createProductAction());
- return result.toArray(new IPublisherAction[result.size()]);
- }
-
- private IPublisherAction createProductAction() {
- IProductDescriptor productDescriptor = null;
- try {
- productDescriptor = new ProductFile(product);
- } catch (Exception e) {
- throw new IllegalArgumentException(NLS.bind(Messages.exception_errorLoadingProductFile, product, e.toString()));
- }
- File executablesFeature = executables == null ? null : new File(executables);
- return new ProductAction(source, productDescriptor, flavor, executablesFeature);
- }
-
- protected void processParameter(String arg, String parameter, PublisherInfo publisherInfo) throws URISyntaxException {
- super.processParameter(arg, parameter, publisherInfo);
-
- if (arg.equalsIgnoreCase("-productFile")) //$NON-NLS-1$
- product = parameter;
- if (arg.equalsIgnoreCase("-executables")) //$NON-NLS-1$
- executables = parameter;
- if (arg.equalsIgnoreCase("-flavor")) //$NON-NLS-1$
- flavor = parameter;
- if (arg.equalsIgnoreCase("-pluginVersionsAdvice")) { //$NON-NLS-1$
- VersionAdvice versionAdvice = new VersionAdvice();
- versionAdvice.load(IInstallableUnit.NAMESPACE_IU_ID, parameter, null);
- info.addAdvice(versionAdvice);
- }
- if (arg.equalsIgnoreCase("-featureVersionsAdvice")) { //$NON-NLS-1$
- VersionAdvice versionAdvice = new VersionAdvice();
- versionAdvice.load(IInstallableUnit.NAMESPACE_IU_ID, parameter, ".feature.group"); //$NON-NLS-1$
- info.addAdvice(versionAdvice);
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/URLEntry.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/URLEntry.java
deleted file mode 100644
index b9566e8a8..000000000
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/URLEntry.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.publisher.eclipse;
-
-public class URLEntry {
- private String annotation;
- private String url;
-
- public URLEntry() {
- //empty
- }
-
- public URLEntry(String url, String annotation) {
- this.url = url;
- this.annotation = annotation;
- }
-
- public void setAnnotation(String annotation) {
- this.annotation = annotation;
- }
-
- public String getAnnotation() {
- return annotation;
- }
-
- public void setURL(String url) {
- this.url = url;
- }
-
- public String getURL() {
- return url;
- }
-}

Back to the top