Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2008-02-19 23:49:54 +0000
committerAndrew Niefer2008-02-19 23:49:54 +0000
commit050b097943b83c9a5b891bef25f0365638cc3af4 (patch)
treedd19b19cbb334ee11a2e6d24d1b5ad5512c47a9b /bundles
parent0bd943e913f14878005da37d18c1ee2d38f4ffb5 (diff)
downloadrt.equinox.p2-050b097943b83c9a5b891bef25f0365638cc3af4.tar.gz
rt.equinox.p2-050b097943b83c9a5b891bef25f0365638cc3af4.tar.xz
rt.equinox.p2-050b097943b83c9a5b891bef25f0365638cc3af4.zip
bug 218649 - read existing config.ini for product IU
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java120
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java33
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties22
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/ProductQuery.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java322
8 files changed, 400 insertions, 156 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF
index 39927645b..3f05fdcd3 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF
@@ -23,7 +23,7 @@ Import-Package: org.eclipse.core.runtime.adaptor,
org.osgi.service.log;version="1.3.0",
org.osgi.service.startlevel;version="1.0.0",
org.osgi.util.tracker;version="1.3.2"
-Export-Package: org.eclipse.equinox.internal.frameworkadmin.equinox;x-internal:=true,
+Export-Package: org.eclipse.equinox.internal.frameworkadmin.equinox;x-friends:=org.eclipse.equinox.p2.metadata.generator,
org.eclipse.equinox.internal.frameworkadmin.equinox.utils;x-internal:=true
Require-Bundle: org.eclipse.equinox.common
Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java
index 470a62d41..00143712f 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java
@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.equinox.internal.frameworkadmin.equinox.utils.FileUtils;
import org.eclipse.equinox.internal.frameworkadmin.utils.Utils;
import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
+import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
@@ -47,20 +48,20 @@ public class EquinoxFwConfigFileParser {
if (location == null)
return null;
boolean useReference = true;
- if (location.startsWith("file:")) {
- if (USE_REFERENCE_STRING != null && USE_REFERENCE_STRING.equals("false"))
+ if (location.startsWith("file:")) { //$NON-NLS-1$
+ if (USE_REFERENCE_STRING != null && USE_REFERENCE_STRING.equals("false")) //$NON-NLS-1$
useReference = false;
}
try {
new URL(location);
} catch (MalformedURLException e) {
- Log.log(LogService.LOG_ERROR, "EquinoxFwConfigFileParser.getCommandLine():bundleInfo=" + bundleInfo, e);
+ Log.log(LogService.LOG_ERROR, "EquinoxFwConfigFileParser.getCommandLine():bundleInfo=" + bundleInfo, e); //$NON-NLS-1$
// Never happen. ignore.
}
if (useReference)
- if (!location.startsWith("reference:"))
- location = "reference:" + location;
+ if (!location.startsWith("reference:")) //$NON-NLS-1$
+ location = "reference:" + location; //$NON-NLS-1$
int startLevel = bundleInfo.getStartLevel();
boolean toBeStarted = bundleInfo.isMarkedAsStarted();
@@ -74,11 +75,11 @@ public class EquinoxFwConfigFileParser {
sb.append(location);
if (startLevel == BundleInfo.NO_LEVEL && !toBeStarted)
return sb.toString();
- sb.append("@");
+ sb.append('@');
if (startLevel != BundleInfo.NO_LEVEL)
sb.append(startLevel);
if (toBeStarted)
- sb.append(":start");
+ sb.append(":start"); //$NON-NLS-1$
return sb.toString();
}
@@ -105,7 +106,7 @@ public class EquinoxFwConfigFileParser {
normalizeLocation(bInfos[i]);
sb.append(getCommandLine(bInfos[i], null));
if (i + 1 < bInfos.length)
- sb.append(",");
+ sb.append(',');
}
props.setProperty(EquinoxConstants.PROP_BUNDLES, sb.toString());
@@ -138,12 +139,26 @@ public class EquinoxFwConfigFileParser {
if (msg == null)
return false;
msg = msg.trim();
- if (msg.equals("start")) {
- return true;
+ int colon = msg.indexOf(":"); //$NON-NLS-1$
+ if (colon > -1) {
+ return msg.substring(colon + 1).equals("start"); //$NON-NLS-1$
}
- if (!msg.equals(""))
- new IllegalArgumentException("Invalid Format =" + original);
- return false;
+ return msg.equals("start"); //$NON-NLS-1$
+ }
+
+ private static int getStartLevel(String msg, String original) {
+ if (msg == null)
+ return BundleInfo.NO_LEVEL;
+ msg = msg.trim();
+ int colon = msg.indexOf(":"); //$NON-NLS-1$
+ if (colon > 0) {
+ try {
+ return Integer.parseInt(msg.substring(0, colon));
+ } catch (NumberFormatException e) {
+ return BundleInfo.NO_LEVEL;
+ }
+ }
+ return BundleInfo.NO_LEVEL;
}
static boolean isFwDependent(String key) {
@@ -156,7 +171,7 @@ public class EquinoxFwConfigFileParser {
private static void normalizeLocation(BundleInfo bInfo) {
String location = bInfo.getLocation();
try {
- if (location.startsWith("file:")) {
+ if (location.startsWith("file:")) { //$NON-NLS-1$
bInfo.setLocation(new URL(location).toExternalForm());
} else {
bInfo.setLocation(new File(location).toURL().toExternalForm());
@@ -185,46 +200,23 @@ public class EquinoxFwConfigFileParser {
private static void setInstallingBundles(Manipulator manipulator, String value) throws NumberFormatException {
ConfigData configData = manipulator.getConfigData();
if (value != null) {
- String[] bInfoStrings = Utils.getTokens(value, ",");
+ String[] bInfoStrings = Utils.getTokens(value, ","); //$NON-NLS-1$
for (int i = 0; i < bInfoStrings.length; i++) {
String token = bInfoStrings[i].trim();
- token = FileUtils.getRealLocation(manipulator, token, false);
- int index = 0;
- while (true) {
- if (token.charAt(index) == ' ')
- index++;
- else
- break;
- }
- if (index != 0)
- token = token.substring(index);
-
- int indexI = token.indexOf("@");
- if (indexI == -1) {
- String location = FileUtils.getEclipseRealLocation(manipulator, token);
- configData.addBundle(new BundleInfo(location));
- // configData.installingBundlesList.add(new BundleInfo(this.convertUrl(bInfoStrings[i])));
- continue;
- }
- String location = token.substring(0, indexI);
- location = FileUtils.getEclipseRealLocation(manipulator, location);
- // URL url = this.convertUrl(bInfoStrings[i].substring(0, indexI));
- String slAndFlag = token.substring(indexI + "@".length());
- boolean markedAsStarted = false;
- int startLevel = -1;
- int indexJ = slAndFlag.indexOf(":");
- if (indexJ == -1) {
- markedAsStarted = getMarkedAsStartedFormat(slAndFlag, token);
- configData.addBundle(new BundleInfo(location, markedAsStarted));
- continue;
- } else if (indexJ == 0) {
- markedAsStarted = getMarkedAsStartedFormat(slAndFlag.substring(indexJ + ":".length()), token);
- configData.addBundle(new BundleInfo(location, startLevel, markedAsStarted));
- continue;
- }
- startLevel = Integer.parseInt(slAndFlag.substring(0, indexJ));
- markedAsStarted = getMarkedAsStartedFormat(slAndFlag.substring(indexJ + ":".length()), bInfoStrings[i]);
- configData.addBundle(new BundleInfo(location, startLevel, markedAsStarted));
+ token = FileUtils.getRealLocation(manipulator, token, false).trim();
+
+ int indexI = token.indexOf("@"); //$NON-NLS-1$
+ String location = (indexI == -1) ? token : token.substring(0, indexI);
+ String realLocation = FileUtils.getEclipseRealLocation(manipulator, location);
+ String slAndFlag = (indexI > -1) ? token.substring(indexI + 1) : null;
+
+ boolean markedAsStarted = getMarkedAsStartedFormat(slAndFlag, token);
+ int startLevel = getStartLevel(slAndFlag, token);
+
+ if (realLocation != null)
+ configData.addBundle(new BundleInfo(realLocation, startLevel, markedAsStarted));
+ else
+ configData.addBundle(new BundleInfo(location, null, null, startLevel, markedAsStarted));
}
}
}
@@ -238,7 +230,7 @@ public class EquinoxFwConfigFileParser {
*/
public void readFwConfig(Manipulator manipulator, File inputFile) throws IOException {
if (inputFile.isDirectory())
- throw new IllegalArgumentException("inputFile:" + inputFile + " must not be a directory.");
+ throw new IllegalArgumentException(NLS.bind(Messages.exception_inputFileIsDirectory, inputFile));
//Initialize data structures
ConfigData configData = manipulator.getConfigData();
@@ -306,7 +298,7 @@ public class EquinoxFwConfigFileParser {
launcherData.setLauncher(new File(launcherPath, launcherName + EquinoxConstants.EXE_EXTENSION));
}
- Log.log(LogService.LOG_INFO, "Config file(" + inputFile.getAbsolutePath() + ") is read successfully.");
+ Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_configFile, inputFile.getAbsolutePath()));
}
private static Properties makeRelative(Properties props, URL rootURL, File fwJar, File configArea, File osgiInstallArea) throws IOException {
@@ -372,9 +364,9 @@ public class EquinoxFwConfigFileParser {
if (args == null)
return null;
for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-startup") && i + 1 < args.length && args[i + 1].charAt(1) != '-') {
+ if (args[i].equals("-startup") && i + 1 < args.length && args[i + 1].charAt(1) != '-') { //$NON-NLS-1$
IPath parentFolder = new Path(args[i + 1]).removeLastSegments(1);
- if (parentFolder.lastSegment().equals("plugins"))
+ if (parentFolder.lastSegment().equals("plugins")) //$NON-NLS-1$
return parentFolder.removeLastSegments(1).toFile();
return parentFolder.toFile();
}
@@ -391,35 +383,35 @@ public class EquinoxFwConfigFileParser {
if (outputFile.exists()) {
if (outputFile.isFile()) {
if (!outputFile.getName().equals(EquinoxConstants.CONFIG_INI))
- throw new IllegalStateException("launcherData.getFwConfigLocation() is a File but its name doesn't equal " + EquinoxConstants.CONFIG_INI);
+ throw new IllegalStateException(NLS.bind(Messages.exception_fwConfigLocationName, outputFile.getAbsolutePath(), EquinoxConstants.CONFIG_INI));
} else { // Directory
outputFile = new File(outputFile, EquinoxConstants.CONFIG_INI);
}
} else {
if (!outputFile.getName().equals(EquinoxConstants.CONFIG_INI)) {
if (!outputFile.mkdir())
- throw new IOException("Fail to mkdir (" + outputFile + ")");
+ throw new IOException(NLS.bind(Messages.exception_failedToCreateDir, outputFile));
outputFile = new File(outputFile, EquinoxConstants.CONFIG_INI);
}
}
- String header = "This properties were written by " + this.getClass().getName();
+ String header = NLS.bind(Messages.msg_ConfigFileHeader, this.getClass().getName());
Properties configProps = getConfigProps(bInfos, configData, launcherData, relative, fwJar);
if (configProps == null || configProps.size() == 0) {
- Log.log(LogService.LOG_WARNING, this, "saveFwConfig() ", "configProps is empty");
+ Log.log(LogService.LOG_WARNING, this, "saveFwConfig() ", Messages.log_configProps); //$NON-NLS-1$
return;
}
Utils.createParentDir(outputFile);
if (DEBUG)
- Utils.printoutProperties(System.out, "configProps", configProps);
+ Utils.printoutProperties(System.out, "configProps", configProps); //$NON-NLS-1$
if (backup)
if (outputFile.exists()) {
File dest = Utils.getSimpleDataFormattedFile(outputFile);
if (!outputFile.renameTo(dest))
- throw new IOException("Fail to rename from (" + outputFile + ") to (" + dest + ")");
- Log.log(LogService.LOG_INFO, this, "saveFwConfig()", "Succeed to rename from (" + outputFile + ") to (" + dest + ")");
+ throw new IOException(NLS.bind(Messages.exception_failedToRename, outputFile, dest));
+ Log.log(LogService.LOG_INFO, this, "saveFwConfig()", NLS.bind(Messages.log_renameSuccessful, outputFile, dest)); //$NON-NLS-1$
}
FileOutputStream out = null;
@@ -427,7 +419,7 @@ public class EquinoxFwConfigFileParser {
out = new FileOutputStream(outputFile);
configProps = makeRelative(configProps, launcherData.getLauncher().getParentFile().toURL(), fwJar, outputFile.getParentFile(), getOSGiInstallArea(manipulator.getLauncherData()));
configProps.store(out, header);
- Log.log(LogService.LOG_INFO, "FwConfig is saved successfully into:" + outputFile);
+ Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_fwConfigSave, outputFile));
} finally {
try {
out.flush();
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java
new file mode 100644
index 000000000..77a80e9be
--- /dev/null
+++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Messages.java
@@ -0,0 +1,33 @@
+/**********************************************************************
+ * Copyright (c) 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 - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.equinox.internal.frameworkadmin.equinox;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.frameworkadmin.equinox.messages";//$NON-NLS-1$
+
+ public static String exception_inputFileIsDirectory;
+ public static String exception_fwConfigLocationName;
+ public static String exception_failedToCreateDir;
+ public static String exception_failedToRename;
+
+ public static String log_configFile;
+ public static String log_configProps;
+ public static String log_renameSuccessful;
+ public static String log_fwConfigSave;
+
+ public static String msg_ConfigFileHeader;
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties
new file mode 100644
index 000000000..1eb78cf51
--- /dev/null
+++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/messages.properties
@@ -0,0 +1,22 @@
+###############################################################################
+# Copyright (c) 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
+###############################################################################
+
+exception_inputFileIsDirectory= Illegal Argument: inputFile {0} must not be a directory.
+exception_fwConfigLocationName = Illegal State: Framework Configuration location "{0}" does not match {1}.
+exception_failedToCreateDir = Failed to create directory {0}.
+exception_failedToRename=Failed to rename {0} to {1}.
+
+log_configFile= Configuration file ({0}) has been read successfully.
+log_configProps= Configuration properties is empty.
+log_renameSuccessful= Successfully renamed {0} to {1}.
+log_fwConfigSave= Framework Configuration was saved successfully in {0}.
+
+msg_ConfigFileHeader= This configuration file was written by {0}. \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
index b378834a6..2cee7e85d 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
@@ -14,6 +14,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.p2.metadata,
org.eclipse.equinox.internal.p2.metadata.repository,
org.eclipse.equinox.internal.provisional.frameworkadmin,
+ org.eclipse.equinox.internal.frameworkadmin.equinox,
org.eclipse.equinox.internal.provisional.p2.artifact.repository,
org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing,
org.eclipse.equinox.internal.provisional.p2.metadata,
@@ -23,6 +24,6 @@ Bundle-Activator: org.eclipse.equinox.internal.p2.metadata.generator.Activator
Export-Package: org.eclipse.equinox.internal.p2.metadata.generator;x-internal:=true,
org.eclipse.equinox.internal.p2.metadata.generator.features;x-friends:="org.eclipse.equinox.p2.updatesite",
org.eclipse.equinox.internal.provisional.p2.metadata.generator
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.4,
CDC-1.1/Foundation-1.1
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/ProductQuery.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/ProductQuery.java
index ba856a39c..7286b2088 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/ProductQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/ProductQuery.java
@@ -21,22 +21,34 @@ public class ProductQuery extends Query {
private final ProductFile product;
private final String flavor;
- private final String launcherCUPrefix;
private final Map children = new HashMap();
- public ProductQuery(ProductFile product, String flavor) {
+ public ProductQuery(ProductFile product, String flavor, Map configIUs) {
this.product = product;
this.flavor = flavor;
- this.launcherCUPrefix = flavor + product.getId() + ".launcher"; //$NON-NLS-1$
- initialize();
+ initialize(configIUs);
}
- private void initialize() {
+ private void initialize(Map configIUs) {
List contents = product.useFeatures() ? product.getFeatures() : product.getPlugins();
for (Iterator iterator = contents.iterator(); iterator.hasNext();) {
String item = (String) iterator.next();
children.put(item, VersionRange.emptyRange);
- children.put(flavor + item, VersionRange.emptyRange); //CUs
+ if (configIUs.containsKey(item)) {
+ for (Iterator ius = ((Set) configIUs.get(item)).iterator(); ius.hasNext();) {
+ IInstallableUnit object = (IInstallableUnit) ius.next();
+ children.put(object.getId(), new VersionRange(object.getVersion(), true, object.getVersion(), true));
+ }
+ }
+ }
+
+ //also include the launcher CU fragments as a workaround to bug 218890
+ String launcherPrefix = product.getId() + ".launcher"; //$NON-NLS-1$
+ if (configIUs.containsKey(launcherPrefix)) {
+ for (Iterator ius = ((Set) configIUs.get(launcherPrefix)).iterator(); ius.hasNext();) {
+ IInstallableUnit object = (IInstallableUnit) ius.next();
+ children.put(object.getId(), new VersionRange(object.getVersion(), true, object.getVersion(), true));
+ }
}
//also add the launcher.jar
@@ -44,6 +56,14 @@ public class ProductQuery extends Query {
children.put(EQUINOX_LAUNCHER, VersionRange.emptyRange);
children.put(flavor + EQUINOX_LAUNCHER, VersionRange.emptyRange);
}
+
+ // and launcher fragment CUs
+ if (configIUs.containsKey(EQUINOX_LAUNCHER)) {
+ for (Iterator ius = ((Set) configIUs.get(EQUINOX_LAUNCHER)).iterator(); ius.hasNext();) {
+ IInstallableUnit object = (IInstallableUnit) ius.next();
+ children.put(object.getId(), new VersionRange(object.getVersion(), true, object.getVersion(), true));
+ }
+ }
}
/* (non-Javadoc)
@@ -59,13 +79,6 @@ public class ProductQuery extends Query {
return range.isIncluded(candidate.getVersion());
}
- //also include the launcher CU fragments as a workaround to bug 218890
- if (candidate.getId().startsWith(launcherCUPrefix))
- return true;
- //and include the launcher fragment CUs
- if (candidate.getId().startsWith(flavor + EQUINOX_LAUNCHER))
- return true;
-
return false;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java
index 00bf3a599..2f540c73e 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java
@@ -14,6 +14,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.*;
+import org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.generator.Activator;
import org.eclipse.equinox.internal.p2.metadata.generator.Messages;
@@ -209,6 +210,20 @@ public class EclipseInstallGeneratorInfoProvider implements IGeneratorInfo {
return manipulator == null ? null : manipulator.getConfigData();
}
+ public ConfigData loadConfigData(File location) {
+ if (manipulator == null)
+ return null;
+
+ EquinoxFwConfigFileParser parser = new EquinoxFwConfigFileParser(Activator.getContext());
+ try {
+ parser.readFwConfig(manipulator, location);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return manipulator.getConfigData();
+ }
+
public File getConfigurationLocation() {
return configLocation;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
index f677c927c..1e26f1a9b 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
@@ -13,6 +13,7 @@ import java.net.URL;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxConstants;
import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.p2.metadata.generator.*;
import org.eclipse.equinox.internal.p2.metadata.generator.Messages;
@@ -47,6 +48,16 @@ public class Generator {
final Set nonRootIUs = new HashSet();
/**
+ * Map of symbolic name to a set of generated CUs for that IU
+ */
+ final Map configurationIUs = new HashMap();
+
+ /**
+ * Map launcherConfig to config.ini ConfigData
+ */
+ final Map configData = new HashMap();
+
+ /**
* Returns all IUs generated during this execution of the generator.
*/
Set allGeneratedIUs() {
@@ -78,6 +89,7 @@ public class Generator {
private static final String ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR = "org.eclipse.equinox.simpleconfigurator"; //$NON-NLS-1$
private static final String ORG_ECLIPSE_UPDATE_CONFIGURATOR = "org.eclipse.update.configurator"; //$NON-NLS-1$
+ private static final String ORG_ECLIPSE_EQUINOX_LAUNCHER = "org.eclipse.equinox.launcher"; //$NON-NLS-1$
// private static String[][] defaultMappingRules = new String[][] { {"(& (namespace=eclipse) (classifier=feature))", "${repoUrl}/feature/${id}_${version}"}, {"(& (namespace=eclipse) (classifier=plugin))", "${repoUrl}/plugin/${id}_${version}"}, {"(& (namespace=eclipse) (classifier=native))", "${repoUrl}/native/${id}_${version}"}};
@@ -132,21 +144,24 @@ public class Generator {
return (iu.getId().indexOf(".feature.default") > 0 ? true : false); //$NON-NLS-1$
}
- protected IInstallableUnit createProductIU() {
- GeneratorResult result = new GeneratorResult();
+ protected IInstallableUnit createProductIU(GeneratorResult result) {
+ generateProductConfigCUs(result);
+
+ GeneratorResult productContents = new GeneratorResult();
- ProductQuery query = new ProductQuery(productFile, info.getFlavor());
+ ProductQuery query = new ProductQuery(productFile, info.getFlavor(), result.configurationIUs);
Collector collector = info.getMetadataRepository().query(query, new Collector(), null);
for (Iterator iterator = collector.iterator(); iterator.hasNext();) {
- result.rootIUs.add(iterator.next());
+ productContents.rootIUs.add(iterator.next());
}
//TODO get a real version
String version = info.getRootVersion() != null ? info.getRootVersion() : "0.0.0"; //$NON-NLS-1$
ArrayList requires = new ArrayList(1);
- requires.add(MetadataFactory.createRequiredCapability(productFile.getId(), productFile.getId() + ".launcher", VersionRange.emptyRange, null, false, true)); //$NON-NLS-1$
- requires.add(MetadataFactory.createRequiredCapability(productFile.getId(), productFile.getId() + ".ini", VersionRange.emptyRange, null, true, false)); //$NON-NLS-1$
- InstallableUnitDescription root = createTopLevelIUDescription(result, productFile.getId(), version, productFile.getProductName(), requires, false);
+ requires.add(MetadataFactory.createRequiredCapability(info.getFlavor() + productFile.getId(), productFile.getId() + ".launcher", VersionRange.emptyRange, null, false, true)); //$NON-NLS-1$
+ requires.add(MetadataFactory.createRequiredCapability(info.getFlavor() + productFile.getId(), productFile.getId() + ".ini", VersionRange.emptyRange, null, true, false)); //$NON-NLS-1$
+ requires.add(MetadataFactory.createRequiredCapability(info.getFlavor() + productFile.getId(), productFile.getId() + ".config", VersionRange.emptyRange, null, false, false)); //$NON-NLS-1$
+ InstallableUnitDescription root = createTopLevelIUDescription(productContents, productFile.getId(), version, productFile.getProductName(), requires, false);
return MetadataFactory.createInstallableUnit(root);
}
@@ -188,49 +203,68 @@ public class Generator {
ConfigData configData = info.getConfigData();
if (configData != null) {
- for (Iterator iterator = configData.getFwDependentProps().entrySet().iterator(); iterator.hasNext();) {
- Entry aProperty = (Entry) iterator.next();
- String key = ((String) aProperty.getKey());
- if (key.equals("osgi.frameworkClassPath") || key.equals("osgi.framework") || key.equals("osgi.bundles") || key.equals("eof")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- continue;
- configurationData += "setFwDependentProp(propName:" + key + ", propValue:" + ((String) aProperty.getValue()) + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- unconfigurationData += "setFwDependentProp(propName:" + key + ", propValue:);"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- for (Iterator iterator = configData.getFwIndependentProps().entrySet().iterator(); iterator.hasNext();) {
- Entry aProperty = (Entry) iterator.next();
- String key = ((String) aProperty.getKey());
- if (key.equals("osgi.frameworkClassPath") || key.equals("osgi.framework") || key.equals("osgi.bundles") || key.equals("eof")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- continue;
- configurationData += "setFwIndependentProp(propName:" + key + ", propValue:" + ((String) aProperty.getValue()) + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- unconfigurationData += "setFwIndependentProp(propName:" + key + ", propValue:);"; //$NON-NLS-1$ //$NON-NLS-2$
- }
+ String[] dataStrings = getConfigurationStrings(configData);
+ configurationData += dataStrings[0];
+ unconfigurationData += dataStrings[1];
}
if (configureLauncherData) {
LauncherData launcherData = info.getLauncherData();
if (launcherData != null) {
- final String[] jvmArgs = launcherData.getJvmArgs();
- for (int i = 0; i < jvmArgs.length; i++) {
- configurationData += "addJvmArg(jvmArg:" + jvmArgs[i] + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- unconfigurationData += "removeJvmArg(jvmArg:" + jvmArgs[i] + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- final String[] programArgs = launcherData.getProgramArgs();
- for (int i = 0; i < programArgs.length; i++) {
- String programArg = programArgs[i];
- if (programArg.equals("--launcher.library") || programArg.equals("-startup") || programArg.equals("-configuration")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- i++;
- configurationData += "addProgramArg(programArg:" + programArg + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- unconfigurationData += "removeProgramArg(programArg:" + programArg + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- }
+ String[] dataStrings = getLauncherConfigStrings(launcherData.getJvmArgs(), launcherData.getProgramArgs());
+ configurationData += dataStrings[0];
+ unconfigurationData += dataStrings[1];
}
}
+
touchpointData.put("configure", configurationData); //$NON-NLS-1$
touchpointData.put("unconfigure", unconfigurationData); //$NON-NLS-1$
root.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
return root;
}
+ private String[] getConfigurationStrings(ConfigData configData) {
+ String configurationData = ""; //$NON-NLS-1$
+ String unconfigurationData = ""; //$NON-NLS-1$
+ for (Iterator iterator = configData.getFwDependentProps().entrySet().iterator(); iterator.hasNext();) {
+ Entry aProperty = (Entry) iterator.next();
+ String key = ((String) aProperty.getKey());
+ if (key.equals("osgi.frameworkClassPath") || key.equals("osgi.framework") || key.equals("osgi.bundles") || key.equals("eof")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ continue;
+ configurationData += "setFwDependentProp(propName:" + key + ", propValue:" + ((String) aProperty.getValue()) + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ unconfigurationData += "setFwDependentProp(propName:" + key + ", propValue:);"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ for (Iterator iterator = configData.getFwIndependentProps().entrySet().iterator(); iterator.hasNext();) {
+ Entry aProperty = (Entry) iterator.next();
+ String key = ((String) aProperty.getKey());
+ if (key.equals("osgi.frameworkClassPath") || key.equals("osgi.framework") || key.equals("osgi.bundles") || key.equals("eof")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ continue;
+ configurationData += "setFwIndependentProp(propName:" + key + ", propValue:" + ((String) aProperty.getValue()) + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ unconfigurationData += "setFwIndependentProp(propName:" + key + ", propValue:);"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return new String[] {configurationData, unconfigurationData};
+ }
+
+ private String[] getLauncherConfigStrings(final String[] jvmArgs, final String[] programArgs) {
+ String configurationData = ""; //$NON-NLS-1$
+ String unconfigurationData = ""; //$NON-NLS-1$
+
+ for (int i = 0; i < jvmArgs.length; i++) {
+ configurationData += "addJvmArg(jvmArg:" + jvmArgs[i] + ");"; //$NON-NLS-1$ //$NON-NLS-2$
+ unconfigurationData += "removeJvmArg(jvmArg:" + jvmArgs[i] + ");"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ for (int i = 0; i < programArgs.length; i++) {
+ String programArg = programArgs[i];
+ if (programArg.equals("--launcher.library") || programArg.equals("-startup") || programArg.equals("-configuration")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ i++;
+ configurationData += "addProgramArg(programArg:" + programArg + ");"; //$NON-NLS-1$ //$NON-NLS-2$
+ unconfigurationData += "removeProgramArg(programArg:" + programArg + ");"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return new String[] {configurationData, unconfigurationData};
+ }
+
public IStatus generate() {
GeneratorResult result = incrementalResult != null ? incrementalResult : new GeneratorResult();
@@ -250,7 +284,7 @@ public class Generator {
generateNativeIUs(info.getExecutableLocation(), result, info.getArtifactRepository());
- generateConfigIUs(info.getConfigData() == null ? null : info.getConfigData().getBundles(), result);
+ generateConfigIUs(result);
if (info.addDefaultIUs())
generateDefaultConfigIU(result.rootIUs);
@@ -310,25 +344,114 @@ public class Generator {
}
}
- protected void generateConfigIUs(BundleInfo[] infos, GeneratorResult result) {
- if (infos != null) {
- for (int i = 0; i < infos.length; i++) {
- GeneratorBundleInfo bundle = new GeneratorBundleInfo(infos[i]);
- if (bundle.getSymbolicName().equals(ORG_ECLIPSE_UPDATE_CONFIGURATOR)) {
- bundle.setStartLevel(BundleInfo.NO_LEVEL);
- bundle.setMarkedAsStarted(false);
- bundle.setSpecialConfigCommands("addJvmArg(jvmArg:-Dorg.eclipse.update.reconcile=false);" + //$NON-NLS-1$
- "addJvmArg(jvmArg:-Dorg.eclipse.p2.update.compatibility=false);"); //$NON-NLS-1$
- bundle.setSpecialUnconfigCommands("removeJvmArg(jvmArg:-Dorg.eclipse.update.reconcile=false);" + //$NON-NLS-1$
- "removeJvmArg(jvmArg:-Dorg.eclipse.p2.update.compatibility=false);"); //$NON-NLS-1$
- }
- if (bundle.getSymbolicName().equals(ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR)) {
- bundle.setSpecialConfigCommands("addJvmArg(jvmArg:-Dorg.eclipse.equinox.simpleconfigurator.useReference=true);"); //$NON-NLS-1$
- bundle.setSpecialUnconfigCommands("removeJvmArg(jvmArg:-Dorg.eclipse.equinox.simpleconfigurator.useReference=true);"); //$NON-NLS-1$
+ private void storeConfigData(GeneratorResult result) {
+ if (result.configData.containsKey(info.getLauncherConfig()))
+ return; //been here, done this
+
+ File fwConfigFile = new File(info.getLauncherData().getFwConfigLocation(), EquinoxConstants.CONFIG_INI);
+ if (fwConfigFile.exists()) {
+ if (info instanceof EclipseInstallGeneratorInfoProvider) {
+ ((EclipseInstallGeneratorInfoProvider) info).loadConfigData(fwConfigFile);
+ ConfigData data = info.getConfigData();
+ result.configData.put(info.getLauncherConfig(), data);
+ }
+ }
+ }
+
+ protected GeneratorBundleInfo createGeneratorBundleInfo(BundleInfo bundleInfo, GeneratorResult result) {
+ if (bundleInfo.getLocation() != null)
+ return new GeneratorBundleInfo(bundleInfo);
+
+ String name = bundleInfo.getSymbolicName();
+
+ //easy case: do we have a matching IU?
+ IInstallableUnit iu = result.getInstallableUnit(name);
+ if (iu != null) {
+ bundleInfo.setVersion(iu.getVersion().toString());
+ return new GeneratorBundleInfo(bundleInfo);
+ }
+
+ //harder: try id_version
+ int i = name.indexOf('_');
+ while (i > -1) {
+ Version version = null;
+ try {
+ version = new Version(name.substring(i));
+ bundleInfo.setSymbolicName(name.substring(0, i));
+ bundleInfo.setVersion(version.toString());
+ return new GeneratorBundleInfo(bundleInfo);
+ } catch (IllegalArgumentException e) {
+ // the '_' found was probably part of the symbolic id
+ i = name.indexOf('_', i);
+ }
+ }
+
+ return null;
+ }
+
+ protected void generateBundleConfigIUs(BundleInfo[] infos, GeneratorResult result, String launcherConfig) {
+ if (infos == null)
+ return;
+
+ String cuIdPrefix = ""; //$NON-NLS-1$
+ String filter = null;
+ if (launcherConfig != null) {
+ //launcher config is os_ws_arch, we want suffix ws.os.arch
+ String[] config = getArrayFromString(launcherConfig, "_"); //$NON-NLS-1$
+ cuIdPrefix = config[1] + '.' + config[0] + '.' + config[2];
+
+ filter = "(& (osgi.ws=" + config[1] + ") (osgi.os=" + config[0] + ") (osgi.arch=" + config[2] + "))"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ for (int i = 0; i < infos.length; i++) {
+ GeneratorBundleInfo bundle = createGeneratorBundleInfo(infos[i], result);
+ if (bundle == null)
+ continue;
+
+ if (bundle.getSymbolicName().equals(ORG_ECLIPSE_UPDATE_CONFIGURATOR)) {
+ bundle.setStartLevel(BundleInfo.NO_LEVEL);
+ bundle.setMarkedAsStarted(false);
+ bundle.setSpecialConfigCommands("addJvmArg(jvmArg:-Dorg.eclipse.update.reconcile=false);" + //$NON-NLS-1$
+ "addJvmArg(jvmArg:-Dorg.eclipse.p2.update.compatibility=false);"); //$NON-NLS-1$
+ bundle.setSpecialUnconfigCommands("removeJvmArg(jvmArg:-Dorg.eclipse.update.reconcile=false);" + //$NON-NLS-1$
+ "removeJvmArg(jvmArg:-Dorg.eclipse.p2.update.compatibility=false);"); //$NON-NLS-1$
+ }
+ if (bundle.getSymbolicName().equals(ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR)) {
+ bundle.setSpecialConfigCommands("addJvmArg(jvmArg:-Dorg.eclipse.equinox.simpleconfigurator.useReference=true);"); //$NON-NLS-1$
+ bundle.setSpecialUnconfigCommands("removeJvmArg(jvmArg:-Dorg.eclipse.equinox.simpleconfigurator.useReference=true);"); //$NON-NLS-1$
+ }
+
+ IInstallableUnit cu = MetadataGeneratorHelper.createBundleConfigurationUnit(cuIdPrefix + bundle.getSymbolicName(), new Version(bundle.getVersion()), false, bundle, info.getFlavor(), filter);
+ if (cu != null) {
+ result.rootIUs.add(cu);
+ if (result.configurationIUs.containsKey(bundle.getSymbolicName())) {
+ ((Set) result.configurationIUs.get(bundle.getSymbolicName())).add(cu);
+ } else {
+ Set set = new HashSet();
+ set.add(cu);
+ result.configurationIUs.put(bundle.getSymbolicName(), set);
}
- IInstallableUnit cu = MetadataGeneratorHelper.createBundleConfigurationUnit(bundle.getSymbolicName(), new Version(bundle.getVersion()), false, bundle, info.getFlavor(), null);
- if (cu != null)
- result.rootIUs.add(cu);
+ }
+ }
+
+ }
+
+ protected void generateConfigIUs(GeneratorResult result) {
+ ConfigData data = info.getConfigData();
+ if ((data == null || data.getBundles().length == 0) && info.getLauncherConfig() != null) {
+ //We have the config.ini but not necessarily all the needed bundle IUs, remember for later
+ storeConfigData(result);
+ } else if (data != null) {
+ // generation against an eclipse install (config.ini + bundles)
+ generateBundleConfigIUs(data.getBundles(), result, info.getLauncherConfig());
+ } else if (result.configData.size() > 0 && generateRootIU) {
+ // generation from remembered config.ini's
+ // we have N platforms, generate a CU for each
+ // TODO try and find common properties across platforms
+ for (Iterator iterator = result.configData.keySet().iterator(); iterator.hasNext();) {
+ String launcherConfig = (String) iterator.next();
+ data = (ConfigData) result.configData.get(launcherConfig);
+ generateBundleConfigIUs(data.getBundles(), result, launcherConfig);
}
}
@@ -343,6 +466,15 @@ public class Generator {
//the configuration unit should share the same platform filter as the IU being configured.
if (cu != null)
result.rootIUs.add(cu);
+ if (bundle.getSymbolicName().startsWith(ORG_ECLIPSE_EQUINOX_LAUNCHER + '.')) {
+ if (result.configurationIUs.containsKey(ORG_ECLIPSE_EQUINOX_LAUNCHER)) {
+ ((Set) result.configurationIUs.get(ORG_ECLIPSE_EQUINOX_LAUNCHER)).add(cu);
+ } else {
+ Set set = new HashSet();
+ set.add(cu);
+ result.configurationIUs.put(ORG_ECLIPSE_EQUINOX_LAUNCHER, set);
+ }
+ }
}
}
}
@@ -456,10 +588,10 @@ public class Generator {
IArtifactKey key = MetadataGeneratorHelper.createLauncherArtifactKey(launcherId, launcherVersion);
iu.setArtifacts(new IArtifactKey[] {key});
iu.setTouchpointType(MetadataGeneratorHelper.TOUCHPOINT_NATIVE);
- ProvidedCapability launcherCapability = MetadataFactory.createProvidedCapability(productNamespace, launcherIdPrefix, new Version("1.0.0")); //$NON-NLS-1$
+ ProvidedCapability launcherCapability = MetadataFactory.createProvidedCapability(info.getFlavor() + productNamespace, launcherIdPrefix, new Version("1.0.0")); //$NON-NLS-1$
iu.setCapabilities(new ProvidedCapability[] {MetadataGeneratorHelper.createSelfCapability(launcherId, launcherVersion), launcherCapability});
- String launcherFragment = "org.eclipse.equinox.launcher." + ws + '.' + os; //$NON-NLS-1$
+ String launcherFragment = ORG_ECLIPSE_EQUINOX_LAUNCHER + '.' + ws + '.' + os;
if (!Constants.OS_MACOSX.equals(os))
launcherFragment += '.' + arch;
iu.setRequiredCapabilities(new RequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, launcherFragment, VersionRange.emptyRange, filter, false, false)});
@@ -511,13 +643,60 @@ public class Generator {
String unConfigurationData = "cleanupzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
touchpointData.put("uninstall", unConfigurationData); //$NON-NLS-1$
cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
- result.rootIUs.add(MetadataFactory.createInstallableUnit(cu));
+ IInstallableUnit unit = MetadataFactory.createInstallableUnit(cu);
+ result.rootIUs.add(unit);
+ //The Product Query will need to include the launcher CU fragments as a workaround to bug 218890
+ if (result.configurationIUs.containsKey(launcherIdPrefix)) {
+ ((Set) result.configurationIUs.get(launcherIdPrefix)).add(unit);
+ } else {
+ Set set = new HashSet();
+ set.add(unit);
+ result.configurationIUs.put(launcherIdPrefix, set);
+ }
//Create the artifact descriptor
IArtifactDescriptor descriptor = MetadataGeneratorHelper.createArtifactDescriptor(key, root, false, true);
publishArtifact(descriptor, root.listFiles(), destination, false);
}
+ /*
+ * For each platform, generate a CU containing the information for the config.ini
+ */
+ private void generateProductConfigCUs(GeneratorResult result) {
+ for (Iterator iterator = result.configData.keySet().iterator(); iterator.hasNext();) {
+ String launcherConfig = (String) iterator.next();
+ String[] config = getArrayFromString(launcherConfig, "_"); //$NON-NLS-1$
+ String ws = config[1];
+ String os = config[0];
+ String arch = config[2];
+
+ ConfigData data = (ConfigData) result.configData.get(launcherConfig);
+
+ InstallableUnitDescription cu = new MetadataFactory.InstallableUnitDescription();
+ String configUnitId = info.getFlavor() + productFile.getId() + ".config." + ws + '.' + os + '.' + arch; //$NON-NLS-1$
+ Version cuVersion = new Version("0.0.0"); //$NON-NLS-1$
+ cu.setId(configUnitId);
+ cu.setVersion(cuVersion);
+ cu.setFilter("(& (osgi.ws=" + ws + ") (osgi.os=" + os + ") (osgi.arch=" + arch + "))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ ProvidedCapability productConfigCapability = MetadataFactory.createProvidedCapability(info.getFlavor() + productFile.getId(), productFile.getId() + ".config", Version.emptyVersion); //$NON-NLS-1$
+ ProvidedCapability selfCapability = MetadataGeneratorHelper.createSelfCapability(configUnitId, cuVersion);
+ cu.setCapabilities(new ProvidedCapability[] {selfCapability, productConfigCapability});
+
+ cu.setTouchpointType(MetadataGeneratorHelper.TOUCHPOINT_ECLIPSE);
+ Map touchpointData = new HashMap();
+ String[] dataStrings = getConfigurationStrings(data);
+ touchpointData.put("configure", dataStrings[0]); //$NON-NLS-1$
+ touchpointData.put("unconfigure", dataStrings[1]); //$NON-NLS-1$
+ cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
+
+ result.rootIUs.add(MetadataFactory.createInstallableUnit(cu));
+ }
+ }
+
+ /*
+ * For the given platform (ws, os, arch) generate the CU that will populate the product.ini file
+ */
private void generateProductIniCU(String ws, String os, String arch, String version, GeneratorResult result) {
if (productFile == null)
return;
@@ -533,34 +712,23 @@ public class Generator {
progArgs.addAll(Arrays.asList(getArrayFromString(productFile.getProgramArguments(os), " "))); //$NON-NLS-1$
jvmArgs.addAll(Arrays.asList(getArrayFromString(productFile.getVMArguments(os), " "))); //$NON-NLS-1$
- String configurationData = ""; //$NON-NLS-1$
- String unconfigurationData = ""; //$NON-NLS-1$
- for (Iterator iterator = jvmArgs.iterator(); iterator.hasNext();) {
- String arg = (String) iterator.next();
- configurationData += "addJvmArg(jvmArg:" + arg + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- unconfigurationData += "removeJvmArg(jvmArg:" + arg + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- for (Iterator iterator = progArgs.iterator(); iterator.hasNext();) {
- String arg = (String) iterator.next();
- if (arg.equals("--launcher.library") || arg.equals("-startup") || arg.equals("-configuration")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- continue;
- configurationData += "addProgramArg(programArg:" + arg + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- unconfigurationData += "removeProgramArg(programArg:" + arg + ");"; //$NON-NLS-1$ //$NON-NLS-2$
- }
+ String[] dataStrings = getLauncherConfigStrings((String[]) jvmArgs.toArray(new String[jvmArgs.size()]), (String[]) progArgs.toArray(new String[progArgs.size()]));
+ String configurationData = dataStrings[0];
+ String unconfigurationData = dataStrings[1];
if (configurationData.length() == 0)
return;
InstallableUnitDescription cu = new MetadataFactory.InstallableUnitDescription();
- String configUnitId = info.getFlavor() + productFile.getId() + ".ini." + os; //$NON-NLS-1$
+ String configUnitId = info.getFlavor() + productFile.getId() + ".ini." + ws + '.' + os + '.' + arch; //$NON-NLS-1$
Version cuVersion = new Version(version);
cu.setId(configUnitId);
cu.setVersion(cuVersion);
cu.setFilter("(& (osgi.ws=" + ws + ") (osgi.os=" + os + ") (osgi.arch=" + arch + "))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- ProvidedCapability productIniCapability = MetadataFactory.createProvidedCapability(productFile.getId(), productFile.getId() + ".ini", Version.emptyVersion); //$NON-NLS-1$
+ ProvidedCapability productIniCapability = MetadataFactory.createProvidedCapability(info.getFlavor() + productFile.getId(), productFile.getId() + ".ini", Version.emptyVersion); //$NON-NLS-1$
ProvidedCapability selfCapability = MetadataGeneratorHelper.createSelfCapability(configUnitId, cuVersion);
- cu.setCapabilities(new ProvidedCapability[] {IInstallableUnitFragment.FRAGMENT_CAPABILITY, selfCapability, productIniCapability});
+ cu.setCapabilities(new ProvidedCapability[] {selfCapability, productIniCapability});
cu.setTouchpointType(MetadataGeneratorHelper.TOUCHPOINT_ECLIPSE);
Map touchpointData = new HashMap();
@@ -643,7 +811,7 @@ public class Generator {
IInstallableUnit rootIU = null;
if (info.getProductFile() != null)
- rootIU = createProductIU();
+ rootIU = createProductIU(result);
else if (rootIUId != null)
rootIU = createTopLevelIU(result, rootIUId, rootIUVersion);

Back to the top