Skip to content

Commit

Permalink
Add optional, greedy and disabled by default requirement to the source
Browse files Browse the repository at this point in the history
Currently it is quite cumbersome effort to include the source of a
bundle with an installation even though there might be multiple demands,
for example legal reasons or debugging.

This now adds a new greedy, optional requirement that is disabled by a
filter so it is not effective by default but enables an install agent to
specify a property of org.eclipse.update.install.source=true to
include sources of bundles in products whenever available.
  • Loading branch information
laeubi committed Feb 4, 2024
1 parent 7ced201 commit ec509b6
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ec509b6

Please sign in to comment.