diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java index 1bef45500e..501d9a88d7 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java @@ -72,6 +72,11 @@ @SuppressWarnings("restriction") public class BundlesAction extends AbstractPublisherAction { + /** + * A suffix used to match a bundle IU to its source + */ + public static final String SOURCE_SUFFIX = ".source"; //$NON-NLS-1$ + /** * A capability name in the {@link PublisherHelper#NAMESPACE_ECLIPSE_TYPE} * namespace representing and OSGi bundle resource @@ -276,6 +281,13 @@ protected IInstallableUnit doCreateBundleIU(BundleDescription bd, IArtifactKey k providedCapabilities.add(SOURCE_BUNDLE_CAPABILITY); } else { providedCapabilities.add(BUNDLE_CAPABILITY); + // add an optional greedy disabled by default requirement to the source so a + // product or install agent can choose to include sources from a bundle + VersionRange strictRange = new VersionRange(iu.getVersion(), true, iu.getVersion(), true); + String sourceIu = iu.getId() + SOURCE_SUFFIX; + String filter = "(org.eclipse.update.install.source=true)"; //$NON-NLS-1$ + requirements.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, sourceIu, strictRange, + filter, true, false, true)); } // If needed add an additional capability to identify this as an OSGi fragment