| Summary: | Optional dependencies are packed in products | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Krum Tsvetkov <krum.tsvetkov> |
| Component: | Tycho | Assignee: | Tobias Oberlies <t-oberlies> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | gregory.amerson, hmalphettes, igor, j.joslet, jan.sievers, kai, lieven.lemiengre, mark.g.j.christiaens, pascal, support, t-oberlies |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Bug Depends on: | 247099, 342808 | ||
| Bug Blocks: | 320082 | ||
|
Description
Krum Tsvetkov
If I get it right the problem is caused by optional dependency Require-Bundle: [...] com.ibm.dtfj.api;bundle-version="1.3.0";resolution:=optional, in [1]. Maybe we can apply some p2.inf magic to work around this optional dependency being "greedily" added by the p2 director. However this would still not adress the more general problem of greedy optional dependencies in the transitive dependency chain being dragged in by p2 director. [1] http://dev.eclipse.org/viewcvs/viewvc.cgi/trunk/plugins/org.eclipse.mat.dtfj/META-INF/MANIFEST.MF?view=markup&root=TOOLS_MAT see related Pascal's comment https://bugs.eclipse.org/bugs/show_bug.cgi?id=306279#c2 on how to make an optional dependency "non-greedy" using p2.inf The suggestion with the p2.inf solved the problem 2). Now I have to work on trying to get the size somewhat better. But I can't add p2.inf files to non-MAT bundles to make them "non-greedy". It would be nice to have a global switch to turn packaging of optional dependencies on and off. Thanks for the help! Very interesting usecase. We need to cover it during product build support rework. In the mean time, you can use bundle based .product with packaging=eclipse-application, which only packages bundles explicitly listed in .product file. @Pascal
I remember we talked about this problem at EclipseCon.
You mentioned negative dependencies but I am not sure how to do this.
Do you have any suggestions for Krum's requirement
>It would be nice to have a global switch to turn packaging of optional
>dependencies on and off.
?
bug 306709 contains some hints on negative requirements. It seems it's not possible to add these negative requirements via p2.inf right now, see bug 312937 Can I reiterate my proposal to NOT include any optional dependencies by default or at least have an option to do so? I still believe it is much easier to add missing required dependencies than it is to exclude unwanted optional dependencies. see Tobias' comment on long-standing p2 bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=247099 <rant> I agree that optional MANIFEST dependencies should translate to *non*-greedy optional p2 requirements by default. At least there should be decent p2.inf editor support so people have a realistic chance to provide meaningful metadata for their bundles. Leaving it up to the p2 wizards to invert the default behavior of greedy=true de facto results in almost all optional dependencies being greedy. With p2 repos the size of Helios or Indigo, there is a high chance of dragging in unwanted optional dependencies. To make things more fun, right now there is no real way to amend/override greediness of optional requirements of consumed bundles. </rant> We have to accept however current p2 metadata is the way it is and it won't change at least for repos of the Indigo and past releases. So what we need is control over greediness of optional dependencies on the consumer side. (I think of it as similar to dependency excludes in maven dependency management). So what are the options we have? 1. Interpret IUs listed in .target as strict bill of materials defining the target platform which tycho p2 resolver resolves against. If an IU is not explicitly listed in .target, it won't be resolved. Thus if an optional dependency can't be resolved, it won't be dragged in ("absence-based behavior"). No need to amend metadata in this case. We use .target to define our restricted view on a p2 repository. 2. Introduce a global boolean switch in p2 director "forceNonGreedy". I guess basically this would mean fixing p2 bug 247099 which is open since 2008. 3. Provide a way to specify negative requirements (see bug 306709 ). We don't amend existing metadata but rather create a conflicting requirement from the IU which we are publishing causing the optional dependency not to be installed. All unwanted optional dependencies need to be listed explicitly. 1) probably requires changes on the tycho side only. Assumed effort rather high though, this would effectively mean to reuse the PDE target platform resolver in tycho. 2) changes almost only in p2. Not sure about effort. 3) a) provide a tycho-specific configuration format to specify negative requirements. Effort not very high and on tycho side only, rather a workaround and non-intrusive. b) support for match expressions in p2.inf ( bug 312937 ). This is like 3 a) but we fix the problem on the p2 side, enabling other tools to use the same solution. I was thinking to do a PoC for 3a) to get a better feeling for the problem. How is option 1. different from current behvaiour of packaging=eclipse-application? Personally, I rather strongly prefer option 2. Missing required dependencies are relatively easy to spot and fix. By contrast, finding and excluding unwanted optional dependencies (i.e. option 3.) is manual, tedious and error prone work. Such unwanted dependencies can sit there for very long time unnoticed, until you get invite to join a conf call with your legal department for example. We definately need some support for controlling optional dependencies. The reason is that from MAT's point of view, the optional dependency really should be greedy: If a user installs the MAT feature, the IBM plug-in shall be installed whenever it is available. Therefore changing the optional dependency to non-greedy only a workaround. The correct solution is setting the target platform for the assembly so that only legally allowed content can be assembled. @Krum: You said that the IBM bundle comes from a separate p2 repository? Then you should omit this repository from the target platform of the product build, e.g. through a separate .target file. More generally, I think that we will need proper dependency management support in Tycho (Jan's proposal 1). I've opened bug 342808 for this missing feature. The dependency management is really where the decision on optional dependencies should be taken. I'd rather like to see the "don't include any optional dependencies" switch there. However if someone is willing to teach this trick to the p2 director, we obviously also should support it in Tycho. To summarize (again - see comment #10): The product packing done by the tycho-p2-director-plugin works correctly - it uses the p2 director which includes optional greedy dependencies. However this behaviour may not be what people want. There should be ways to exclude optional dependencies, e.g. through dependency management (bug 342808) or an "exclude optional" switch to the p2 director (bug 247099). We should leave this open as enhancement request until either of these approaches are implemented. with slicer mode for .target files fixed in bug 342808, it should be possible now to define a .target that does not include the unwanted optional dependencies of the product. Unwanted optional dependencies should no longer be packed in the product as long as the build does not "see" them because they are not in the target platform. It would be nice if someone could verify this using tycho 0.13.0-SNAPSHOT. Add http://repository.sonatype.org/content/groups/sonatype-public-grid/ to your pluginRepositories if you want to use tycho 0.13.0-SNAPSHOT. (In reply to comment #12) > with slicer mode for .target files fixed in bug 342808, it should be possible > now to define a .target that does not include the unwanted optional > dependencies of the product. > > Unwanted optional dependencies should no longer be packed in the product as > long as the build does not "see" them because they are not in the target > platform. > > It would be nice if someone could verify this using tycho 0.13.0-SNAPSHOT. > > Add > > http://repository.sonatype.org/content/groups/sonatype-public-grid/ > > to your pluginRepositories if you want to use tycho 0.13.0-SNAPSHOT. How does this solution relate to the three options suggested in comment 8? <rant> I still believe target platform is not the right place to decide what gets included into an RCP and what is not. Optional dependencies are most likely required at build time by other projects, so we are basically forcing separate .target file just to control contents of the RCP project and this separate .target file will be virtually identical to its corresponding .product file. forceNonGreedy director flag, on the other hand, provides predictable, easy to explain and understand behaviour without forcing Tycho users to duplicate RCP contents configuration in .target and .produce files. </rant> (In reply to comment #13) > forceNonGreedy director flag, on the other hand, provides predictable, easy to > explain and understand behaviour without forcing Tycho users to duplicate RCP > contents configuration in .target and .produce files. Sure, forcing all optional dependencies to non-greedy would be a good feature for the director. But should the "forceNonGreedy" become a property of the profile (i.e. the installation), or if this can be set per install/update operation. The latter option is probably not what people want, because then it could happen that optional, greedy dependencies are installed later during an unrelated install operation. IIRC, bug 351420 covers a related use case that could require the same changes in p2. (In reply to comment #13) > (In reply to comment #12) > How does this solution relate to the three options suggested in comment 8? it's option 1 from comment#8. I would say that we now have *a* solution for the problem of optional dependencies in products: Create a target file with includeMode="slicer" and select a set of features (or possibly individual bundles) to make sure that the optionally required bundle is not part of the target platform. This works, but obviously can be quite tedious. Still, I would mark this issue as resolved: - The problem should become rare with Juno content. In Juno M1, the publishers were changed, so that optional dependencies are non-greedy by default (bug 247099) - If someone is keen on a more convenient solution (e.g. option 2 in comment 8) , please open a new enhancement request and link it from here. This issue has spawned a lot of interest - I suspect because there was no solution. Only by opening a new issue, we can know happy/unhappy people are with the current solution. FYI: In the meanwhile, there is a better option to avoid the inclusion of optional dependencies: target platform filters [1]. See [2] for an example how to use them in case unwanted optional dependencies are packed in a product. [1] http://wiki.eclipse.org/Tycho/Target_Platform#Filtering [2] http://stackoverflow.com/questions/12372269/eclipse-rcp-built-by-tycho-includes-unwanted-optional-dependencies |