-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider other locations when resolving IUs from updatesites #792
Consider other locations when resolving IUs from updatesites #792
Conversation
Test Results 273 files + 6 273 suites +6 1h 4m 43s ⏱️ + 19m 8s Results for commit 3e98782. ± Comparison against base commit fccc098. This pull request removes 1 test.
♻️ This comment has been updated with latest results. |
ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/P2TargetUtils.java
Outdated
Show resolved
Hide resolved
bcedeb8
to
66a5c24
Compare
This is now ready as the first minimal increment. It is likely that there are some changes one like to adjust sometime but at least this allows to resolve an
|
Testfailure seems unrelated, build is otherwhise green... |
66a5c24
to
04fc433
Compare
Using a Generic Type is simply bad and fixing this later on up by adding filter only complicates the whole story for absolutely no gain and will limit our ability to later, also this discussion about "API" or "not API" does not bring any value this is not API this is a decoupled way of using optional features and if we remove it and later replace it by some other means things have to be adjusted or one can use another Adapter that bridges old -> new behavior as done already in the past when migrating to the more feature rich target locations..
Because of mentioned flaws I discard that change. Let me know if we should close this instead as I don't want to invest more time in a crippled solution that sooner or later will break or only works by some inherit assumptions about Types we never can reliable enforce.. |
f31c542
to
66a5c24
Compare
968dac7
to
e825d30
Compare
Currently the IULocation can only consider units from other locations if these are also of type IU location but other target types might be able to supply items in a way not know to the IULocation. This adds the necessary infrastructure to support this usecase by using the adapter pattern. Fix eclipse-pde#207
e825d30
to
3e98782
Compare
@HannesWell I now reworked the whole part so it automatically queries the locations and converts them I hope this now addresses your concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HannesWell I now reworked the whole part so it automatically queries the locations and converts them I hope this now addresses your concerns.
Yes, this looks perfectly fine, thanks. 👍🏽
I'm glad we came to a better solution that has less requirements and also works without adjustments in other target-locations. :)
Just two small style-remarks below, but nothing critical.
public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] bundles) { | ||
if (bundles == null || bundles.length == 0) { | ||
return Stream.empty(); | ||
} | ||
return Arrays.stream(bundles).flatMap(InstallableUnitGenerator::generateInstallableUnits); | ||
} | ||
|
||
public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle targetBundle) { | ||
BundleInfo bundleInfo = targetBundle.getBundleInfo(); | ||
if (bundleInfo != null) { | ||
String manifest = bundleInfo.getManifest(); | ||
if (manifest != null) { | ||
try { | ||
Manifest parsed = new Manifest(new ByteArrayInputStream(manifest.getBytes(StandardCharsets.UTF_8))); | ||
Attributes mainAttributes = parsed.getMainAttributes(); | ||
CaseInsensitiveDictionaryMap<String, String> headers = new CaseInsensitiveDictionaryMap<>( | ||
mainAttributes.size()); | ||
Set<Entry<Object, Object>> entrySet = mainAttributes.entrySet(); | ||
for (Entry<Object, Object> entry : entrySet) { | ||
headers.put(entry.getKey().toString(), entry.getValue().toString()); | ||
} | ||
PublisherInfo publisherInfo = new PublisherInfo(); | ||
publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX); | ||
BundleDescription bundleDescription = BundlesAction.createBundleDescription(headers, null); | ||
IInstallableUnit iu = BundlesAction.createBundleIU(bundleDescription, | ||
BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(), | ||
bundleDescription.getVersion().toString()), | ||
publisherInfo); | ||
return Stream.of(iu); | ||
} catch (IOException e) { | ||
// can't use it then... | ||
} | ||
} | ||
} | ||
return Stream.empty(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Stream.mapMulti()
would save the creation of Streams with one element.
public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] bundles) { | |
if (bundles == null || bundles.length == 0) { | |
return Stream.empty(); | |
} | |
return Arrays.stream(bundles).flatMap(InstallableUnitGenerator::generateInstallableUnits); | |
} | |
public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle targetBundle) { | |
BundleInfo bundleInfo = targetBundle.getBundleInfo(); | |
if (bundleInfo != null) { | |
String manifest = bundleInfo.getManifest(); | |
if (manifest != null) { | |
try { | |
Manifest parsed = new Manifest(new ByteArrayInputStream(manifest.getBytes(StandardCharsets.UTF_8))); | |
Attributes mainAttributes = parsed.getMainAttributes(); | |
CaseInsensitiveDictionaryMap<String, String> headers = new CaseInsensitiveDictionaryMap<>( | |
mainAttributes.size()); | |
Set<Entry<Object, Object>> entrySet = mainAttributes.entrySet(); | |
for (Entry<Object, Object> entry : entrySet) { | |
headers.put(entry.getKey().toString(), entry.getValue().toString()); | |
} | |
PublisherInfo publisherInfo = new PublisherInfo(); | |
publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX); | |
BundleDescription bundleDescription = BundlesAction.createBundleDescription(headers, null); | |
IInstallableUnit iu = BundlesAction.createBundleIU(bundleDescription, | |
BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(), | |
bundleDescription.getVersion().toString()), | |
publisherInfo); | |
return Stream.of(iu); | |
} catch (IOException e) { | |
// can't use it then... | |
} | |
} | |
} | |
return Stream.empty(); | |
} | |
private static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] bundles) { | |
if (bundles == null || bundles.length == 0) { | |
return Stream.empty(); | |
} | |
return Arrays.stream(bundles).mapMulti(InstallableUnitGenerator::generateInstallableUnits); | |
} | |
private static void generateInstallableUnits(TargetBundle targetBundle, Consumer<IInstallableUnit> downStream) { | |
BundleInfo bundleInfo = targetBundle.getBundleInfo(); | |
if (bundleInfo != null) { | |
String manifest = bundleInfo.getManifest(); | |
if (manifest != null) { | |
try { | |
Manifest parsed = new Manifest(new ByteArrayInputStream(manifest.getBytes(StandardCharsets.UTF_8))); | |
Attributes mainAttributes = parsed.getMainAttributes(); | |
CaseInsensitiveDictionaryMap<String, String> headers = new CaseInsensitiveDictionaryMap<>( | |
mainAttributes.size()); | |
Set<Entry<Object, Object>> entrySet = mainAttributes.entrySet(); | |
for (Entry<Object, Object> entry : entrySet) { | |
headers.put(entry.getKey().toString(), entry.getValue().toString()); | |
} | |
PublisherInfo publisherInfo = new PublisherInfo(); | |
publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX); | |
BundleDescription bundleDescription = BundlesAction.createBundleDescription(headers, null); | |
IInstallableUnit iu = BundlesAction.createBundleIU(bundleDescription, | |
BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(), | |
bundleDescription.getVersion().toString()), | |
publisherInfo); | |
downStream.accept(iu); | |
} catch (IOException e) { | |
// can't use it then... | |
} | |
} | |
} | |
} |
return Stream.empty(); | ||
} | ||
|
||
public static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature[] features) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature[] features) { | |
private static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature[] features) { |
return Arrays.stream(features).flatMap(InstallableUnitGenerator::generateInstallableUnits); | ||
} | ||
|
||
public static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature targetFeature) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature targetFeature) { | |
private static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature targetFeature) { |
…e#792 Given that units from non-IU locations are considered when resolving IUs, it may happen that units are contained in the resolution path, which are not contained by any repository. This may break previously functional target definitions. To resolve this problem, an in-memory artifact and metadata repository is created, based on the metadata of the non-IU locations. Those repositories are then added to the provisioning context for further processing. Amends dd321b5
Currently the IULocation can only consider units from other locations if these are also of type IU location but other target types might be able to supply items in a way not know to the IULocation.
This adds the necessary infrastructure to support this usecase by using the adapter pattern.
Fix #207
Requires eclipse-equinox/p2#348