Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2018-02-22 12:05:10 -0500
committerMickael Istria2018-02-26 04:16:09 -0500
commite92e31abc7ed83117b9cd25b4026531b4ae47064 (patch)
treebba25f17cb0e5640d5bc3a422d900ab157ae1288
parent9009085b72e9507fdc4b7d0adb87883adefc5637 (diff)
downloadrt.equinox.p2-e92e31abc7ed83117b9cd25b4026531b4ae47064.tar.gz
rt.equinox.p2-e92e31abc7ed83117b9cd25b4026531b4ae47064.tar.xz
rt.equinox.p2-e92e31abc7ed83117b9cd25b4026531b4ae47064.zip
Bug 218650 - Parse the product <vm> settingI20180228-2000I20180227-2000
Change-Id: I2aa1af9333619e0a078c8b8a1e7c90960876197d Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java51
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/productWithVM.product36
4 files changed, 105 insertions, 1 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 f3dc69b7f..f9f2c2210 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
@@ -198,4 +198,11 @@ public interface IProductDescriptor {
*/
public List<IRepositoryReference> getRepositoryEntries();
+ /**
+ * Returns the VM associated as Execution Environment with the given OS.
+ * @param os the OS
+ * @return the VM for this OS, null if none is set
+ */
+ public String getVM(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 bd37a4691..99292cf2e 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
@@ -71,6 +71,7 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
private static final String PROGRAM_ARGS_MAC = "programArgsMac"; //$NON-NLS-1$
private static final String PROGRAM_ARGS_SOLARIS = "programArgsSol"; //$NON-NLS-1$
private static final String PROGRAM_ARGS_WIN = "programArgsWin"; //$NON-NLS-1$
+ private static final String VM = "vm"; //$NON-NLS-1$
private static final String VM_ARGS = "vmArgs"; //$NON-NLS-1$
private static final String VM_ARGS_LINUX = "vmArgsLin"; //$NON-NLS-1$
private static final String VM_ARGS_MAC = "vmArgsMac"; //$NON-NLS-1$
@@ -94,6 +95,8 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
private static final String OS_LINUX = "linux";//$NON-NLS-1$
private static final String OS_SOLARIS = "solaris";//$NON-NLS-1$
private static final String OS_MACOSX = "macosx";//$NON-NLS-1$
+ private static final String OS_MACOS = "macos";//$NON-NLS-1$
+ private static final String OS_WINDOWS = "windows";//$NON-NLS-1$
// These must match Platform constant values
private static final String ARCH_X86 = "x86"; //$NON-NLS-1$
@@ -159,6 +162,10 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
private static final int STATE_ARCH_PA_RISC = 26;
private static final int STATE_ARCH_SPARC = 27;
private static final int STATE_REPOSITORIES = 28;
+ private static final int STATE_VM = 29;
+ private static final int STATE_VM_LINUX = 31;
+ private static final int STATE_VM_MACOS = 32;
+ private static final int STATE_VM_WINDOWS = 33;
private static final String PI_PDEBUILD = "org.eclipse.pde.build"; //$NON-NLS-1$
private final static int EXCEPTION_PRODUCT_FORMAT = 23;
@@ -197,6 +204,7 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
private String licenseText = null;
private final String currentOS;
private final List<IRepositoryReference> repositories = new ArrayList<>();
+ private final Map<String, String> vms = new HashMap<>();
private static String normalize(String text) {
if (text == null || text.trim().length() == 0)
@@ -752,6 +760,8 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
state = STATE_LICENSE;
} else if (EL_REPOSITORIES.equals(localName)) {
state = STATE_REPOSITORIES;
+ } else if (VM.equals(localName)) {
+ state = STATE_VM;
}
break;
@@ -886,6 +896,16 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
processPropertyConfiguration(attributes);
}
break;
+
+ case STATE_VM :
+ if (OS_LINUX.equals(localName)) {
+ state = STATE_VM_LINUX;
+ } else if (OS_WINDOWS.equals(localName)) {
+ state = STATE_VM_WINDOWS;
+ } else if (OS_MACOS.equals(localName)) {
+ state = STATE_VM_MACOS;
+ }
+ break;
}
}
@@ -1003,6 +1023,14 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
if (EL_LICENSE.equals(localName))
state = STATE_PRODUCT;
break;
+ case STATE_VM :
+ state = STATE_PRODUCT;
+ break;
+ case STATE_VM_LINUX :
+ case STATE_VM_WINDOWS :
+ case STATE_VM_MACOS :
+ state = STATE_VM;
+ break;
case STATE_PROGRAM_ARGS :
case STATE_PROGRAM_ARGS_LINUX :
@@ -1111,7 +1139,30 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor {
if (licenseText != null)
licenseText += String.valueOf(ch, start, length);
break;
+ case STATE_VM_LINUX :
+ addVM(OS_LINUX, String.valueOf(ch, start, length));
+ break;
+ case STATE_VM_WINDOWS :
+ addVM(OS_WINDOWS, String.valueOf(ch, start, length));
+ break;
+ case STATE_VM_MACOS :
+ addVM(OS_MACOS, String.valueOf(ch, start, length));
+ break;
+ }
+ }
+
+ private void addVM(String os, String vm) {
+ vms.put(os, vm);
+ }
+
+ @Override
+ public String getVM(String os) {
+ if (os.equals(OS_MACOSX)) {
+ os = OS_MACOS;
+ } else if (os.equals(OS_WIN32)) {
+ os = OS_WINDOWS;
}
+ return vms.get(os);
}
private void addLaunchArgumentToMap(String key, String value) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
index 173234c25..78da7417b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
@@ -17,10 +17,13 @@ import static org.junit.Assert.assertThat;
import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IVersionedId;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionedId;
import org.eclipse.equinox.p2.tests.TestData;
/**
@@ -267,4 +270,11 @@ public class ProductFileTest extends TestCase {
assertEquals("1.0", "This is the liCenSE.", product.getLicenseText().trim());
}
+ public void testGetVM() throws Exception {
+ String productWithVM = TestData.getFile("ProductActionTest", "productWithVM.product").toString();
+ ProductFile product = new ProductFile(productWithVM);
+ assertEquals("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/OSGi%Minimum-1.2", product.getVM(Platform.OS_WIN32));
+ assertEquals("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9", product.getVM(Platform.OS_LINUX));
+ assertNull(product.getVM(Platform.OS_MACOSX));
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/productWithVM.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/productWithVM.product
new file mode 100644
index 000000000..03c10345a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/productWithVM.product
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?pde version="3.5"?>
+
+<product name="Product With License" uid="licenseIU.product" useFeatures="false" includeLaunchers="true">
+
+ <configIni use="default">
+ </configIni>
+
+ <launcherArgs>
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
+ </vmArgsMac>
+ </launcherArgs>
+
+ <launcher>
+ <win useIco="false">
+ <bmp/>
+ </win>
+ </launcher>
+
+ <vm>
+ <linux include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9</linux>
+ <windows include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/OSGi%Minimum-1.2</windows>
+ </vm>
+
+ <license>
+ <url>http://www.example.com</url>
+ <text>
+ This is the liCenSE.
+ </text>
+ </license>
+
+ <plugins>
+ </plugins>
+
+
+</product>

Back to the top