Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 453708 - Support for site/repository-reference/@location in eclipse-repository
Summary: Support for site/repository-reference/@location in eclipse-repository
Status: CLOSED MOVED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement with 9 votes (vote)
Target Milestone: ---   Edit
Assignee: guillaume dufour CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks: 452053
  Show dependency tree
 
Reported: 2014-12-01 04:37 EST by Andreas Sewe CLA
Modified: 2021-05-31 10:06 EDT (History)
16 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Sewe CLA 2014-12-01 04:37:44 EST
The category.xml replacement of site.xml's site/@associateSitesURL (Bug 346926), site/repository-reference/@location should be supported by the eclipse-repository packaging. Hence this request for an enhancement (as suggested in Bug 452053).
Comment 1 Andreas Sewe CLA 2015-01-05 11:59:56 EST
If some committer can give me some pointers here, I might be willing to give this bug a try, as I'd really like this feature in Tycho soon.
Comment 2 Mickael Istria CLA 2015-01-05 12:04:17 EST
Is this supported by p2 itself? Ie is this property kept in metadata when you export a category.xml as p2 repo from Eclipse?
Why can't you use associateSitesURL ?
Comment 3 Andreas Sewe CLA 2015-01-05 12:34:01 EST
(In reply to Mickael Istria from comment #2)
> Is this supported by p2 itself? Ie is this property kept in metadata when
> you export a category.xml as p2 repo from Eclipse?
> Why can't you use associateSitesURL ?

As far as I can see, associateSitesURL is no longer supported by category.xml; it only works with old-style site.xml update sites.

And no, just setting the property and searching the artifact.xml/contents.xml generated by Tycho for the URI didn't turn up a match (with Tycho 0.22).
Comment 4 Mickael Istria CLA 2015-01-05 12:56:06 EST
Ok.
It seems like this is available on p2 side: cf bug 436318. Tycho 0.22 includes a good version of p2 to support this feature (bug 444112 ). Looking at the PublisherServiceImpl (that directly takes the file and passes this to p2 ), it seems to me that Tycho 0.22 should already support that out-of-the-box...
Comment 5 Andreas Sewe CLA 2015-01-06 03:24:28 EST
(In reply to Mickael Istria from comment #4)
> Ok.
> It seems like this is available on p2 side: cf bug 436318. Tycho 0.22
> includes a good version of p2 to support this feature (bug 444112 ). Looking
> at the PublisherServiceImpl (that directly takes the file and passes this to
> p2 ), it seems to me that Tycho 0.22 should already support that
> out-of-the-box...

I am afraid I cannot get this to work:

I used the PDE UI to add a site/repository-reference/@location to my repositories/stable/category.xml

After the build, I grepped for my test URL:

$ grep -r 'example\.org' repositories/stable/target
repositories/stable/target/category.xml:   <repository-reference location="http://www.example.org/" enabled="true" />

Moreover, neither repositories/stable/target/repository/artifacts.jar nor repositories/stable/target/repository/content.jar contain the test URL.
Comment 6 Jan Sievers CLA 2015-01-07 03:37:06 EST
(In reply to Andreas Sewe from comment #5)
> I am afraid I cannot get this to work:

this may be a similar issue as bug 341744 comment 32
Comment 7 Tobias Oberlies CLA 2015-01-07 05:27:38 EST
(In reply to comment #4)
> It seems like this is available on p2 side: cf bug 436318. Tycho 0.22 includes a
> good version of p2 to support this feature (bug 444112 ). Looking at the
> PublisherServiceImpl (that directly takes the file and passes this to p2 ), it
> seems to me that Tycho 0.22 should already support that out-of-the-box...

The reason why this doesn't work is that PublishingRepository.getMetadataRepository() returns a ModuleMetadataRepository which only stores installable units and nothing else. So p2 probably calls addReferences on that repository, but that call is ignored. This is intentional: the ModuleMetadataRepository contains the build results of a module which can be used by other modules, and it doesn't make sense to copy "repository references" defined in a different module (or even in a remote p2 repository) to an eclipse-repository module.

So really the problem is that the category.xml publisher result currently is copied at all. The category.xml publisher could directly write into the p2 repository at target/repository. (This is what Jan tried out bug 341744.) This would make the references show up in the build result.

The side-effect of changing the publisher output repository is that these results can no longer be referenced by other modules (which can only read the p2metadata/p2artifacts.xml written by the ModuleMetadata/ArtifactRepository). But this is no problem because it anyway doesn't make sense (and was technically almost impossible) to reference category IUs in other modules.
Comment 8 Andreas Sewe CLA 2015-03-20 04:38:11 EDT
Any ETA for this?
Comment 9 Mickael Istria CLA 2017-01-29 06:21:19 EST
Just to place the information where it's the most relevant, a possible workaround is to use org.jboss.tools.tycho-plugins:repository-utils:generate-repository-facade mojo. https://github.com/mickaelistria/aCute/commit/2053ab221f5eaf1dfd3c28122691b99e4cc4dd03
Comment 10 Eclipse Genie CLA 2017-04-30 12:46:21 EDT
New Gerrit change created: https://git.eclipse.org/r/96098
Comment 11 guillaume dufour CLA 2017-04-30 12:47:09 EDT
What is exactly expected in the result ?
I create a unit test and all the parsing methods.
But i see a snapshoot and resolution in the LocalMetadataRepository (publishRepositoryReferences call by initialize while closing tag reading).

Does we must resolve it like this king of class of p2 repo. I don't know yet the internal p2 process sorry.

And if yes, when we do it? just after reading it, just like LocalMetadataRepository ?

I push my WIP, you can have a look
Comment 12 guillaume dufour CLA 2017-05-01 04:54:39 EDT
after investing a little, i am a little disappointed,

Why tycho used his own MetadataIO instead of the MetadataRepositoryIO directly from p2 ?
Because if we use it directly, we benefit of all their codes and must implements the repo but it's already done with the LocalMetadataRepository. no ?
did I miss something ?
Comment 13 Jan Sievers CLA 2017-05-02 04:11:06 EDT
(In reply to guillaume dufour from comment #12)
> after investing a little, i am a little disappointed,
> 
> Why tycho used his own MetadataIO instead of the MetadataRepositoryIO
> directly from p2 ?
> Because if we use it directly, we benefit of all their codes and must
> implements the repo but it's already done with the LocalMetadataRepository.
> no ?
> did I miss something ?

I can't tell why and from where exactly it was copied but e.g. the name "Parser35M7"
https://github.com/eclipse/tycho/blob/2694138a1611b81eaf4cc63a5f90dc3e86c091ed/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/p2/maven/repository/xmlio/ArtifactsIO.java#L49

seems to suggest this was copied as a snapshot from p2 (and possibly adapted/patched for Tycho needs)

the code has been in Tycho from day 1, so this one goes to Igor I guess
Comment 14 Igor Fedorenko CLA 2017-05-02 07:37:22 EDT
@guillaume if you are interested in software archeology, [1] is the commit where I introduced MetadataIO in its current shape (more or less, it used to share even less core with p2 back then). The reason I had to write Tycho-specific implementation was because MetadataRepositoryIO could not be used outside of running OSGi platform. You'd need to refactor MetadataRepositoryIO to allow standalone use if you want to replace MetadataIO with it.


[1] https://github.com/sonatype/sonatype-tycho/commit/23d1f55398353ee803be14912c7db2dc19f8f025#diff-a9608a3f73f40b964c46b9f42691b6d2
Comment 15 guillaume dufour CLA 2017-05-07 08:07:23 EDT
Thanks a lot for your reply. I finish this without touching p2. But if I have enough time, i will do a PR to p2 to benefits of their code without re-implementing their. Is that a good idea, are you ok ?
Comment 16 guillaume dufour CLA 2017-05-07 13:01:17 EDT
I see the jenkins build fail but no error in the log and all test pass. Any idea?
Comment 17 Jan Sievers CLA 2017-05-08 03:17:36 EDT
(In reply to guillaume dufour from comment #16)
> I see the jenkins build fail but no error in the log and all test pass. Any
> idea?

looks like there was a problem deleting the target/ folde. I retriggered the voter job.
Comment 18 Jan Sievers CLA 2017-05-08 03:19:48 EDT
(In reply to guillaume dufour from comment #15)
> Thanks a lot for your reply. I finish this without touching p2. But if I
> have enough time, i will do a PR to p2 to benefits of their code without
> re-implementing their. Is that a good idea, are you ok ?

if you can refactor p2 so that it can be reused without having to copy and adapt code for Tycho, yes that's a good idea. Tycho committer Tobias Oberlies is also a p2 committer so I hope he would be available to review your patch.
Comment 19 guillaume dufour CLA 2017-05-15 07:07:42 EDT
@Jan : to reply to the comment/review on patch 10 with the incompatibilty in MetadataIO.

I see it from MetadataRepositoryIO. But I don't know if this class is used for all parsing/writing from p2. Is there any reference doc for this? Because it seems to always be this format since 10 years...https://github.com/eclipse/rt.equinox.p2/blob/master/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java

So I think, maybe, i am on the wrong way...
I can do a compatible parser to all formats (with units root and repository root), but is it enought ? Is that what we want...

What i understand is, 
- category defined repo ref
- we must get it and add it to repo
- we must save them in the content.xml
- we must use them for resolution ?

The 3 first points are closed to be treated. The 3rd introduce a breaking change on the way tycho dump content.xml in p2 repo.

The last one not yet treated, because I don't know if i must do this.
Comment 20 Jan Sievers CLA 2017-05-16 04:13:05 EDT
(In reply to guillaume dufour from comment #19)
> @Jan : to reply to the comment/review on patch 10 with the incompatibilty in
> MetadataIO.
> 
> I see it from MetadataRepositoryIO. But I don't know if this class is used
> for all parsing/writing from p2. Is there any reference doc for this?
> Because it seems to always be this format since 10
> years...https://github.com/eclipse/rt.equinox.p2/blob/master/bundles/org.
> eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/
> metadata/repository/MetadataRepositoryIO.java

I am not aware of official docs but de facto the content.xml format defined by p2 is API in the sense that different p2 clients in different eclipse versions rely on it to be parseable.

> So I think, maybe, i am on the wrong way...
> I can do a compatible parser to all formats (with units root and repository
> root), but is it enought ? Is that what we want...

> What i understand is, 
> - category defined repo ref
> - we must get it and add it to repo
> - we must save them in the content.xml
> 
> The 3 first points are closed to be treated. The 3rd introduce a breaking
> change on the way tycho dump content.xml in p2 repo.

I think the problem is actually that Tycho initially decided to use a different format _internally_ for content.xml in target/p2content.xml and local maven repo. Note that this format is only used for intra-reactor and reactor-> local maven repo dependencies. This was a choice that is probably hard to change now. The way I see it there are 3 options:

1. revert back to the format given by p2
   pros: we would get all the parser patches/improvements from upstream
   cons: incompatible change i.e. you can't exchange Tycho artifacts
         using the local maven repo if Tycho versions are different, you
         need to silently ignore the older/newer format,...
2. find a way to add the repo references in the given Tycho content.xml format
   pros: compatible change i.e. transparent to users
   cons: have to double-maintain content.xml parser, 
         further divert from p2 content.xml format
3. Try to avoid the whole content.xml parser problem by publishing the 
   category.xml
   directly into target/repository, similar as per bug 341744 comment 32 .
   Although this didn't seem to work for p2.statsURI I think it could work for 
   repo references

Looking at what we are trying to achieve here vs. what we are potentially breaking I tend to prefer option 3 (or 2, in that order).

> - we must use them for resolution ?
> 
> The last one not yet treated, because I don't know if i must do this.

Not sure if I got you right, but here is my take:

Dependency resolution of a Tycho project is a different story (governed by its target platform, see [1]). repo references in category.xml are only there for dependency resolution *at install time*, i.e. when someone is using the eclipse-repository build result to install what has been built by Tycho into an eclipse installation. I think the main usecase here is you provide a plugin that depends on another third-party plugin (not published by eclipse) and you can't/don't want (e.g. for legal reasons) to include the third-party plugin(s) in your own p2 repo but rather just reference their public p2 repo for dependency resolution at install time.

Also, repo references in category.xml are only used and IMHO only make sense in an eclipse-repository module as a module-local property. I don't see a use-case for an upstream module  having a dependency on the eclipse-repository module and referring to its repo references. 

[1] https://wiki.eclipse.org/Tycho/Target_Platform
Comment 21 guillaume dufour CLA 2017-05-16 17:05:01 EDT
So I create a new gerrit review without all my crap and i just push the category.xml to the target/repo with the publisher.
Comment 22 Jan Sievers CLA 2017-05-17 03:43:59 EDT
(In reply to guillaume dufour from comment #21)
> So I create a new gerrit review without all my crap and i just push the
> category.xml to the target/repo with the publisher.

I hope this will work. Sorry for the detour but that's how it goes sometimes
Comment 23 guillaume dufour CLA 2017-05-28 11:52:24 EDT
after some days, I get back to this dev and to be sure what to implement.
here is my dev:
- keep my impact on AbstractSiteDependenciesAction & ProductDependenciesAction to read repo ref
- provide them by repo properties (P2GeneratorImpl)
- read this repo ref while executing the tycho-p2-director:materialize-products mojo (in DirectorMojo#getBuildOutputRepository) , no ?

Is that it in your head ?
Comment 24 Jan Sievers CLA 2017-05-29 04:05:24 EDT
(In reply to guillaume dufour from comment #23)
> after some days, I get back to this dev and to be sure what to implement.
> here is my dev:
> - keep my impact on AbstractSiteDependenciesAction &
> ProductDependenciesAction to read repo ref
> - provide them by repo properties (P2GeneratorImpl)
> - read this repo ref while executing the
> tycho-p2-director:materialize-products mojo (in
> DirectorMojo#getBuildOutputRepository) , no ?
> 
> Is that it in your head ?

I'm not into the details right now but the repo references in category.xml should not affect the build itself, i.e. the repo refs are not added the build's target platform and not read anywhere during build except for being published along with category.xml. I think we should just make sure that the repo refs are published and end up in the target/repository build result (as opposed to the tycho-internal target/{p2content|p2artifacts}.xml).
I'd start by changing PublishCategoriesMojo to publish the category.xml directly into target/repository (similar to   bug 341744 comment 32 ) and see  if that helps.
Comment 25 guillaume dufour CLA 2017-06-09 15:36:24 EDT
I stop working on this ticket. I think i don't know enought p2 and tycho to treat. I will treat other ticket and if no one have treat it, maybe in some month/year, I will do it. sorry
Comment 26 Christoph Laeubrich CLA 2019-02-05 13:28:59 EST
Is there any progress on this?
Comment 27 Eclipse Genie CLA 2019-03-28 14:39:26 EDT
New Gerrit change created: https://git.eclipse.org/r/139698
Comment 28 guillaume dufour CLA 2019-03-28 14:41:41 EDT
Hello,

i am back on this jira, before doing it, can some one provide a test project. Because I create one, but i am not sure it's a good one. Can someone check if it's ok or correct/provide me a good one:
https://git.eclipse.org/r/#/c/139698/
Comment 30 Eclipse Genie CLA 2019-04-25 08:06:37 EDT
New Gerrit change created: https://git.eclipse.org/r/141135
Comment 32 Eclipse Genie CLA 2019-05-09 07:46:23 EDT
New Gerrit change created: https://git.eclipse.org/r/141872
Comment 34 Christian Schneider CLA 2020-01-09 18:38:05 EST
First of all thanks for taking care about this issue, I appreciate that a lot.

Unfortunately the solution doesn't work out in the end for me with an Eclipse 2019-03 IDE
into which I tried to install some content from a self-built update site defining referenced repositories.
They are originally defined in my category.xml, like
 <repository-reference location="http://download.eclipse.org/tools/orbit/downloads/drops/R20180606145124/repository" enabled="true" />
 <repository-reference location="http://download.eclipse.org/modeling/mdt/uml2/updates/5.4/" enabled="true" />

After confirming everything in the "New Software Installer", I get exceptions like

!ENTRY org.eclipse.equinox.p2.engine 4 4 2020-01-10 00:07:37.428
!MESSAGE An error occurred while collecting items to be installed
!SUBENTRY 1 org.eclipse.equinox.p2.engine 4 0 2020-01-10 00:07:37.428
!MESSAGE session context was:(profile=epp.package.dsl, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
!SUBENTRY 1 org.eclipse.equinox.p2.artifact.repository 4 0 2020-01-10 00:07:37.428
!MESSAGE No repository found containing: osgi.bundle,com.google.inject,3.0.0.v201605172100
!SUBENTRY 1 org.eclipse.equinox.p2.artifact.repository 4 0 2020-01-10 00:07:37.428
!MESSAGE No repository found containing: osgi.bundle,org.eclipse.uml2.uml,5.4.0.v20180903-1400
!SUBENTRY 1 org.eclipse.equinox.p2.artifact.repository 4 0 2020-01-10 00:07:37.428
!MESSAGE No repository found containing: org.eclipse.update.feature,org.eclipse.uml2.uml,5.4.0.v20180903-1400

As far as I could drill down the misbehaviour, the problem seems to be rather simple:

While the jboss mojo ("org.jboss.tools.tycho-plugins:repository-utils:generate-repository-facade")
generates type="0" AND type="1" repository declaration tags into content.xml,
tycho's eclipse-repository packager (in v1.5.0) generates type="0" repository declarations only.

After I added the missing type="1" repository definitions manually in the content.xml (in the jar & xz archives)
and removing the previous "Available Software Sites" entries in the IDE's preference page the installation works like a charm.

It would be awesome if you guys could add that fix, as I'm not familiar with the Tycho code base at all.
Comment 35 Alexander Levsha CLA 2020-05-14 04:22:07 EDT
https://github.com/eclipse/tycho/blob/master/tycho-bundles/org.eclipse.tycho.p2.tools.impl/src/main/java/org/eclipse/tycho/p2/tools/mirroring/MirrorApplication.java#L74

This seems to be the causing line. Only METADATA repo reference is added, but the ARTIFACTS is also/instead needed.

I don't know if adding both types/changing type to ARTIFACTS is a correct fix, but it sure would be a quick one.

I'd appreciate if someone with more knowledge on p2 would fix this.
Comment 36 Felix Dorner CLA 2020-05-19 03:38:38 EDT
I also get the errors described by Christian in Comment #34. And what's even worse: If the user now goes to Preferences->Install New Software, it really seems like the referenced site is fully added. I tried to "reload" that site from the preferences, which doesn't work. The only way to fix errors is to remove the site, and add it again. Maybe even a restart required?
Comment 37 Dimitris Kolovos CLA 2020-09-02 07:04:45 EDT
In case it helps anyone else, as a workaround until this Tycho issue is fixed, in the Epsilon project [1] we've added a Groovy program [2] to our POM [3] that clones the <repository> elements in the Tycho-generated content.xml and sets the type of the cloned repository elements to 1 (i.e. adds artefact repositories with the same URLs). Following this change, installation works as expected both from P2 Director and from the Eclipse UI.

[1] https://eclipse.org/epsilon
[2] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/releng/org.eclipse.epsilon.updatesite/patch-content-xml-and-zip-site.groovy
[3] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/releng/org.eclipse.epsilon.updatesite/pom.xml
Comment 38 Mickael Istria CLA 2021-04-08 18:09:40 EDT
Eclipse Tycho is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/tycho/issues/ instead. If this issue is relevant to you, your action is required.
0. Verify this issue is still happening with latest Tycho 2.4.0-SNAPSHOT
  if issue has disappeared, please change status of this issue to "CLOSED WORKFORME" with some details about your testing environment and how you did verify the issue; and you're done
  if issue is still present when latest release:
* Create a new issue at https://github.com/eclipse/tycho/issues/
  ** Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience)
  ** In the GitHub description, start with a link to this bugzilla ticket
  ** Optionally add new content to the description if it can helps towards resolution
  ** Submit GitHub issue
* Update bugzilla ticket
  ** Add to "See also" property (up right column) the link to the newly created GitHub issue
  ** Add a comment "Migrated to <link-to-newly-created-GitHub-issue>"
  ** Set status as CLOSED MOVED
  ** Submit

All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for Tycho will be archived and made read-only.
Comment 39 Lorenzo Bettini CLA 2021-05-31 10:06:15 EDT
Migrated to https://github.com/eclipse/tycho/issues/141