Source:
<code>public Collection<IInstallableUnit> resolve() { if (!addedLocationsHaveContent()) { return Collections.emptySet(); } ResolutionDataImpl data = new ResolutionDataImpl(executionEnvironment); data.setRootIUs(rootIUs); data.setAvailableIUsAndFilter(compoundQueriable(availableUnitSources)); AbstractResolutionStrategy strategy = getResolutionStrategy(); strategy.setData(data); Collection<IInstallableUnit> units = strategy.multiPlatformResolve(environments, monitor); if (includeSource) { ArrayList<IRequirement> requirements = new ArrayList<IRequirement>(); for (IInstallableUnit unit : units) { requirements .add(MetadataFactory.createRequirement("osgi.bundle", unit.getId() + ".source", new VersionRange(unit.getVersion(), true, unit.getVersion(), true), null, true, false, true)); } InstallableUnit sourceIU = new InstallableUnit(); sourceIU.setRequiredCapabilities(requirements.toArray(new IRequirement[requirements.size()])); data.setRootIUs(Collections.singleton((IInstallableUnit) sourceIU)); <START> Collection<IInstallableUnit> sourceUnits = strategy.resolve(new TargetEnvironment(), monitor); <END> sourceUnits.remove(sourceIU); units.addAll(sourceUnits); } return units; }</code><technical_language>While write integration-test + extension this behaviour configurable, I NPE while resolve "sourceIU" missing id. Also, approach of a single IUs resolve source is works here. resolution for tentative source IU</technical_language>

Target:
public Collection<IInstallableUnit> resolve() throws TargetDefinitionResolutionException, ResolverException { if (!addedLocationsHaveContent()) { return Collections.emptySet(); } ResolutionDataImpl data = new ResolutionDataImpl(executionEnvironment); data.setRootIUs(rootIUs); data.setAvailableIUsAndFilter(compoundQueriable(availableUnitSources)); AbstractResolutionStrategy strategy = getResolutionStrategy(); strategy.setData(data); Collection<IInstallableUnit> units = strategy.multiPlatformResolve(environments, monitor); if (includeSource && !units.isEmpty()) { final IRequirement bundleRequirement = MetadataFactory.createRequirement( "org.eclipse.equinox.p2.eclipse.type", "bundle", null, null, false, false, false); ArrayList<IRequirement> requirements = new ArrayList<IRequirement>(); for (IInstallableUnit unit : units) { if (unit.satisfies(bundleRequirement)) { requirements.add(MetadataFactory.createRequirement("osgi.bundle", unit.getId() + ".source", new VersionRange(unit.getVersion(), true, unit.getVersion(), true), null, true, false, true)); } } InstallableUnitDescription sourceDescription = new MetadataFactory.InstallableUnitDescription(); sourceDescription.setSingleton(true); sourceDescription.setId(SOURCE_IU_ID); Version sourceIUVersion = Version.createOSGi(1, 0, 0); sourceDescription.setVersion(sourceIUVersion); sourceDescription.addRequirements(requirements); IProvidedCapability capability = MetadataFactory.createProvidedCapability( IInstallableUnit.NAMESPACE_IU_ID, SOURCE_IU_ID, sourceIUVersion); sourceDescription.setCapabilities(new IProvidedCapability[] { capability }); IInstallableUnit sourceIU = MetadataFactory.createInstallableUnit(sourceDescription); data.setRootIUs(Collections.singleton((IInstallableUnit) sourceIU)); Collection<IInstallableUnit> sourceUnits = strategy.resolve(new TargetEnvironment(), monitor); sourceUnits.remove(sourceIU); units.addAll(sourceUnits); } return units; }