diff options
7 files changed, 104 insertions, 3 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 87f7fd0a9..f3dc69b7f 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 @@ -51,6 +51,11 @@ public interface IProductDescriptor { public List<IVersionedId> getBundles(boolean includeFragments); /** + * Returns <code>true</code> when <code>getBundles(includeFragments)</code> returns a non-empty list. + */ + public boolean hasBundles(boolean includeFragments); + + /** * Returns the fragments listed in the product. * @see #useFeatures() */ @@ -63,6 +68,11 @@ public interface IProductDescriptor { public List<IVersionedId> getFeatures(); /** + * Returns <code>true</code> when <code>getFeatures()</code> returns a non-empty list. + */ + public boolean hasFeatures(); + + /** * Returns the features listed in the product. Note: These features are only part of * the product if {@link #useFeatures()} returns <code>true</code>. * @param options bitmask to indicate what kind of features to return. @@ -188,4 +198,4 @@ public interface IProductDescriptor { */ public List<IRepositoryReference> getRepositoryEntries(); -}
\ No newline at end of file +} 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 109837b64..71816dc1e 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 @@ -361,6 +361,11 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor { return result; } + public boolean hasBundles(boolean includeFragments) { + // implement directly; don't call the potentially overridden getBundles + return !plugins.isEmpty() || (includeFragments && !fragments.isEmpty()); + } + private List<FeatureEntry> getBundleEntries(boolean includeFragments) { List<FeatureEntry> result = new LinkedList<FeatureEntry>(); result.addAll(plugins); @@ -398,6 +403,11 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor { return getFeatures(INCLUDED_FEATURES); } + public boolean hasFeatures() { + // implement directly; don't call the potentially overridden getFeatures + return !features.isEmpty(); + } + public List<IVersionedId> getFeatures(int options) { List<IVersionedId> result = new LinkedList<IVersionedId>(); diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java index 650f1dd3c..edaa26842 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java @@ -136,14 +136,14 @@ public class ProductAction extends AbstractPublisherAction { case FEATURES : // include features only list = versionElements(listElements(product.getFeatures(), ".feature.group"), IInstallableUnit.NAMESPACE_IU_ID); //$NON-NLS-1$ - if (!product.getBundles(true).isEmpty()) { + if (product.hasBundles(true)) { finalStatus.add(new Status(IStatus.INFO, Activator.ID, Messages.bundlesInProductFileIgnored)); } break; case BUNDLES : // include bundles only list = versionElements(listElements(product.getBundles(true), null), IInstallableUnit.NAMESPACE_IU_ID); - if (!product.getFeatures().isEmpty()) { + if (product.hasFeatures()) { finalStatus.add(new Status(IStatus.INFO, Activator.ID, Messages.featuresInProductFileIgnored)); } break; 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 8ec7a5fb5..7c0c36402 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 @@ -137,6 +137,27 @@ public class ProductFileTest extends TestCase { assertThat(rootFeaturesProduct.getFeatures(), is(rootFeaturesProduct.getFeatures(IProductDescriptor.INCLUDED_FEATURES))); } + public void testHasFeatures() throws Exception { + ProductFile featuresOnly = new ProductFile(TestData.getFile("ProductActionTest", "onlyFeatures.product").toString()); + assertThat(featuresOnly.hasFeatures(), is(true)); + assertThat(featuresOnly.hasBundles(false), is(false)); + assertThat(featuresOnly.hasBundles(true), is(false)); + } + + public void testHasBundles() throws Exception { + ProductFile bundlesOnly = new ProductFile(TestData.getFile("ProductActionTest", "onlyBundles.product").toString()); + assertThat(bundlesOnly.hasFeatures(), is(false)); + assertThat(bundlesOnly.hasBundles(false), is(true)); + assertThat(bundlesOnly.hasBundles(true), is(true)); + } + + public void testHasFragments() throws Exception { + ProductFile bundlesOnly = new ProductFile(TestData.getFile("ProductActionTest", "onlyFragments.product").toString()); + assertThat(bundlesOnly.hasFeatures(), is(false)); + assertThat(bundlesOnly.hasBundles(false), is(false)); + assertThat(bundlesOnly.hasBundles(true), is(true)); + } + /** * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getIcons(java.lang.String)}. */ diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyBundles.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyBundles.product new file mode 100644 index 000000000..618127834 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyBundles.product @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product uid="product.with.plugin" useFeatures="false" includeLaunchers="false"> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + + <plugins> + <plugin id="org.eclipse.core.commands"/> + </plugins> + + <features> + </features> + +</product> diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyFeatures.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyFeatures.product new file mode 100644 index 000000000..1fc92b22c --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyFeatures.product @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product uid="product.with.feature" useFeatures="true" includeLaunchers="false"> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + + <plugins> + </plugins> + + <features> + <feature id="org.eclipse.rcp"/> + </features> + +</product> diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyFragments.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyFragments.product new file mode 100644 index 000000000..0c8ae9b35 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/onlyFragments.product @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product uid="product.with.fragment" useFeatures="false" includeLaunchers="false"> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + + <plugins> + <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/> + </plugins> + + <features> + </features> + +</product> |