Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan McCourt2014-02-21 18:53:21 +0000
committerGerrit Code Review @ Eclipse.org2014-02-21 21:12:55 +0000
commit64975349785ed9cb5983e35a1b290bf69f09a6cb (patch)
tree1ca2d5591535612745c0c82ac91a7e1dba6fca19 /bundles/org.eclipse.equinox.p2.publisher.eclipse
parenta15e015f2b06b2318319e13738559760f1a88687 (diff)
downloadrt.equinox.p2-64975349785ed9cb5983e35a1b290bf69f09a6cb.tar.gz
rt.equinox.p2-64975349785ed9cb5983e35a1b290bf69f09a6cb.tar.xz
rt.equinox.p2-64975349785ed9cb5983e35a1b290bf69f09a6cb.zip
Bug 428785 - [publisher] Allow for system properties to be specified for
an OS / Arch combination Change-Id: I867591c7060250f46e80911c0e6dcea02d3e6db7
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.publisher.eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java77
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java5
3 files changed, 86 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java
index b86b9ad11..d2fa18af3 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Code 9 and others. All rights reserved. This
+ * Copyright (c) 2008, 2014 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
@@ -8,6 +8,7 @@
* Code 9 - initial API and implementation
* EclipseSource - ongoing development
* SAP AG - ongoing development
+ * Rapicorp - additional features
******************************************************************************/
package org.eclipse.equinox.internal.p2.publisher.eclipse;
@@ -124,6 +125,14 @@ public interface IProductDescriptor {
public Map<String, String> getConfigurationProperties();
/**
+ * Returns the properties for this product file for a given OS and
+ * architecture combination. If the os and/or arch are not specified,
+ * then only those properties defined without os and/or arch filtering
+ * will be returned.
+ */
+ public Map<String, String> getConfigurationProperties(String os, String arch);
+
+ /**
* Returns a list of icons for this product for a given OS.
*/
public String[] getIcons(String os);
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java
index 6a1e5e7ba..ef80838fc 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2014 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
@@ -11,6 +11,7 @@
* EclipseSource - ongoing development
* Felix Riegger (SAP AG) - consolidation of publishers for PDE formats (bug 331974)
* SAP AG - ongoing development
+ * Rapicorp - additional features
*******************************************************************************/
package org.eclipse.equinox.internal.p2.publisher.eclipse;
@@ -52,6 +53,8 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
protected static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
private static final String ATTRIBUTE_UID = "uid"; //$NON-NLS-1$
private static final String ATTRIBUTE_CONTENT_TYPE = "type"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_OS = "os"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_ARCH = "arch"; //$NON-NLS-1$
private static final String PROPERTY_ECLIPSE_APPLICATION = "eclipse.application"; //$NON-NLS-1$
private static final String PROPERTY_ECLIPSE_PRODUCT = "eclipse.product"; //$NON-NLS-1$
@@ -179,6 +182,7 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
private final File location;
private List<BundleInfo> bundleInfos;
private Map<String, String> properties;
+ private HashMap<String, HashMap<String, String>> filteredProperties;
private boolean includeLaunchers = true;
private String licenseURL;
private String licenseText = null;
@@ -270,7 +274,52 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
* are located in the <configurations> block of the file
*/
public Map<String, String> getConfigurationProperties() {
+ return getConfigurationProperties(null, null);
+ }
+
+ /**
+ * Returns the properties found in .product file that are valid
+ * for the specified platform os and architecture. If there is no
+ * platform os and/or architecture specified, return only the properties
+ * that are not filtered by the unspecified os and/or arch.
+ * Properties are located in the <configurations> block of the file
+ */
+ public Map<String, String> getConfigurationProperties(String os, String arch) {
+ // add all generic properties
Map<String, String> result = properties != null ? properties : new HashMap<String, String>();
+ // add any properties filtered on os and/or arch
+ if (filteredProperties != null) {
+ String[] filteredKeys = new String[3]; // ".arch", "os.", "os.arch"
+ if (os == null) {
+ // only arch is specified. Provide properties defined for
+ // all os and a specific architecture
+ if (arch != null && arch.length() > 0) {
+ filteredKeys[0] = "." + arch; //$NON-NLS-1$
+ }
+ } else {
+ if (arch == null) {
+ // only os is specified. Provide properties defined for
+ // specific os and all architectures.
+ filteredKeys[1] = os + "."; //$NON-NLS-1$
+ } else {
+ // os and arch specified. Provide properties defined for
+ // the os, for the arch, and for both
+ filteredKeys[0] = "." + arch; //$NON-NLS-1$
+ filteredKeys[1] = os + "."; //$NON-NLS-1$
+ filteredKeys[2] = os + "." + arch; //$NON-NLS-1$
+ }
+ }
+ for (int i = 0; i < filteredKeys.length; i++) {
+ if (filteredKeys[i] != null) {
+ // copy all mappings that are filtered for this os and/or arch
+ HashMap<String, String> innerMap = filteredProperties.get(filteredKeys[i]);
+ if (innerMap != null) {
+ result.putAll(innerMap);
+ }
+ }
+
+ }
+ }
if (application != null && !result.containsKey(PROPERTY_ECLIPSE_APPLICATION))
result.put(PROPERTY_ECLIPSE_APPLICATION, application);
if (id != null && !result.containsKey(PROPERTY_ECLIPSE_PRODUCT))
@@ -801,13 +850,33 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
private void processPropertyConfiguration(Attributes attributes) {
String name = attributes.getValue(ATTRIBUTE_NAME);
String value = attributes.getValue(ATTRIBUTE_VALUE);
+ String os = attributes.getValue(ATTRIBUTE_OS);
+ if (os == null)
+ os = ""; //$NON-NLS-1$
+ String arch = attributes.getValue(ATTRIBUTE_ARCH);
+ if (arch == null)
+ arch = ""; //$NON-NLS-1$
+ String propOSArchKey = os + "." + arch; //$NON-NLS-1$
if (name == null)
return;
if (value == null)
value = ""; //$NON-NLS-1$
- if (properties == null)
- properties = new HashMap<String, String>();
- properties.put(name, value);
+ if (propOSArchKey.length() <= 1) {
+ // this is a generic property for all platforms and arch
+ if (properties == null)
+ properties = new HashMap<String, String>();
+ properties.put(name, value);
+ } else {
+ // store the property in the filtered map, keyed by "os.arch"
+ if (filteredProperties == null)
+ filteredProperties = new HashMap<String, HashMap<String, String>>();
+ HashMap<String, String> filteredMap = filteredProperties.get(propOSArchKey);
+ if (filteredMap == null) {
+ filteredMap = new HashMap<String, String>();
+ filteredProperties.put(propOSArchKey, filteredMap);
+ }
+ filteredMap.put(name, value);
+ }
}
private void processPluginConfiguration(Attributes attributes) {
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java
index b6de8bf6c..4e8116189 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductFileAdvice.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Code 9 and others. All rights reserved. This
+ * Copyright (c) 2008, 2014 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
@@ -8,6 +8,7 @@
* Code 9 - initial API and implementation
* EclipseSource - ongoing development
* IBM Corporation - ongoing development
+ * Rapicorp - additional features
******************************************************************************/
package org.eclipse.equinox.p2.publisher.eclipse;
@@ -107,7 +108,7 @@ public class ProductFileAdvice extends AbstractAdvice implements ILicenseAdvice,
public Map<String, String> getProperties() {
Map<String, String> result = new HashMap<String, String>();
CollectionUtils.putAll(configData.getProperties(), result);
- result.putAll(product.getConfigurationProperties());
+ result.putAll(product.getConfigurationProperties(os, arch));
return result;
}

Back to the top