Bug 361149 - Problem with Resolving Tycho-Built Sources Artifacts from Maven Repository
Summary: Problem with Resolving Tycho-Built Sources Artifacts from Maven Repository
Status: REOPENED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-17 10:36 EDT by Timo Rohrberg CLA
Modified: 2021-04-28 16:55 EDT (History)
3 users (show)

See Also:


Attachments
Sample projects to reproduce. (8.75 KB, application/zip)
2011-10-17 10:43 EDT, Timo Rohrberg CLA
no flags Details
fixed sample project (7.26 KB, application/x-zip-compressed)
2011-10-17 10:57 EDT, Jan Sievers CLA
no flags Details
Another set of sample projects to reproduce. (11.99 KB, application/zip)
2011-10-17 11:20 EDT, Timo Rohrberg CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Rohrberg CLA 2011-10-17 10:36:24 EDT
Build Identifier: M20110909-1335

This problem has already been discussed on the [tycho-user] mailinglist (http://dev.eclipse.org/mhonarc/lists/tycho-user/msg01043.html), but no solution could be found and thus, a bug is assumed.

When using Tycho to build own bundles, including the creation of source-bundles, Tycho apparently does not properly install p2 metadata for those source bundles in the local Maven repository. Consequently, Tycho cannot resolve dependencies to those source bundles, e.g. when subsequently building a source feature. See the attached sample projects for further details.

I think, with this a major feature is broken. Tycho cannot be used to build and re-use own bundles once including sources, once not. Thus, this bug should definitely be fixed.

Reproducible: Always

Steps to Reproduce:
1. Unzip the attached projects in a new and empty Eclipse Indigo workspace.
2. Run "mvn install" on the com.example.plugin project. This correctly builds the project and installs the resulting "com.example.plugin-1.0.0-SNAPSHOT.jar" and "com.example.plugin-1.0.0-SNAPSHOT-sources.jar" in the local Maven repository.
3. Run "mvn install" on the com.example.feature project. This works.
4. Run "mvn install" on the com.example.source.feature project. This fails as Tycho cannot resolve the dependency to the com.example.plugin.source bundle even though a corresponding dependency to the sources jar is defined in the pom.xml file.
Comment 1 Timo Rohrberg CLA 2011-10-17 10:43:16 EDT
Created attachment 205338 [details]
Sample projects to reproduce.
Comment 2 Jan Sievers CLA 2011-10-17 10:57:57 EDT
Created attachment 205339 [details]
fixed sample project
Comment 3 Jan Sievers CLA 2011-10-17 11:02:22 EDT
by changing the phase of tycho source-plugin from prepare-package to package, you kind of reintroduced bug

https://issues.sonatype.org/browse/TYCHO-473

=> Don't change the phase of the plugin-source goal.

The comment
            <!-- Need to specify phase since plugin is executed BEFORE sources
                 are extracted by the maven-dependency-plugin otherwise -->

is misleading since maven-dependency-plugin is not used at all in your sample project.

Also, pomDependencies=consider and all the pom dependencies are completely unnecessary for your project.
pomDependencies=consider is only for referencing bundles built by maven but not available in any p2 repository.
See https://docs.sonatype.org/display/TYCHO/Dependency+on+pom-first+artifacts
Comment 4 Timo Rohrberg CLA 2011-10-17 11:16:04 EDT
Ok, I agree that the comment in my pom.xml was misleading. But actually, I created the sample project from a more sophisticated one in which I use the maven-dependency-plugin plugin to extract sources from external maven artifacts for repacking them into an OSGi bundle. Unfortunately, tycho-source-plugin was always executed too early and the source had not been extracted yet. For that, I tried to reorganize the order of execution which apparently reintroduced the bug mentioned.

How do I achieve the extraction of sources via the maven-dependency-plugin BEFORE tycho-source-plugin runs? Do you have any further hints?

I will attach another sample project showing the problem in a second...
Comment 5 Timo Rohrberg CLA 2011-10-17 11:16:39 EDT
Sorry, forgot to reopen the issue.
Comment 6 Timo Rohrberg CLA 2011-10-17 11:20:13 EDT
Created attachment 205344 [details]
Another set of sample projects to reproduce.
Comment 7 Jan Sievers CLA 2011-10-17 11:39:59 EDT
(In reply to comment #6)
what are you trying to achieve?

why do you unpack sources from various maven artifacts in phase prepare-package in order to repackage them into a tycho source jar (i.e. you pack sources which have never been compiled)?

Sorry but your sample project seems very confused to me and I still don't see what should be the bug in tycho here.

If you reopen, make sure to provide

1. steps to reproduce
2. expected behaviour
3. observed behaviour and why it's a bug

If you need consulting, ask on tycho-user.
Comment 8 Igor Fedorenko CLA 2011-10-17 11:52:26 EDT
The point is to be able to "wrap" plain Maven jar artifacts and their corresponding sources in bundles and source bundles consumable as dependencies of Tycho projects. The usecase is legit, although I don't think we have to support the attached sample projects as is or suggest alternative solution.
Comment 9 Jan Sievers CLA 2011-10-17 16:28:45 EDT
this bug report was opened claiming that 

"I think, with this a major feature is broken. Tycho cannot be used to build and
re-use own bundles once including sources, once not. Thus, this bug should
definitely be fixed."

I have shown with the fixed sample project that tycho actually can resolve source bundles built by tycho from the local maven repository.

If the nature of this bug report changed now and it's actually a question

"How can I "wrap" plain Maven jar artifacts and their
corresponding sources in bundles and source bundles consumable as dependencies
of Tycho projects ?"

then I would like this to be clarified by Timo.

If anyone should work on this bug we need a precise description of what are the requirements to be fulfilled here.
Comment 10 Timo Rohrberg CLA 2011-10-18 03:45:36 EDT
Ok, first of all, I need to apologize: I did not want to blame Tycho or anyone for implementation shortcomings. In fact, I like Tycho and am convinced that it does a great job in helping us to build large, Eclipse based software projects in a structured way. It's just that I am trying to solve the task of building my own Eclipse target platform with Tycho for a couple of days now and have extensively been discussing the problems I run into on the tycho-user mailinglist (see [1] to [4]).

In the meantime, I was able to create a working solution for my usecase. Nevertheless, I am not completely sure if the way I did it is the recommended way or if there are more straightforward solutions available.

I try now to explain my usecase in detail and also provide you with a more sophisticated sample setup to reproduce it.

The basic idea is to have an own Eclipse target platform including a selection of Eclipse plugins, as well as bundles wrapping plain Maven jar artifacts (and their corresponding sources) for organization internal use and external deployment on customer systems. The target platform should only contain what is really necessary and thus, pre-packaged Eclipse features cannot easily be used since they include additional stuff which we don't need for our particular setup.

During development time, we would of course like to use the same target platform as the one which is later shipped to the customer. Additionally, we do need sources attachments available for all plugins and the ability to easily navigate and debug into those sources from within the Eclipse IDE.

In addition to this, own bundles need to be built within a continuous integration process based on the Jenkins build server. We do have a running setup using Buckminster, but would like to replace this by a Tycho based system. The continuous integration process should also build towards the custom target platform mentioned above. Once certain bundles become stable, they will be integrated into an additional second target platform defining the set of own bundles shipped to the customer (of course together with the Eclipse and thirdparty bundles of the first target platform).

To simulate all of this, I set up the attached sample projects. Building them with Tycho works in the meantime, but maybe you have additional comments on how to solve the issue more straightforward.

"build_stage_1_eclipse" contains two feature projects which just rebundle a certain selection of Eclipse plugins and their sources for the custom target platform. The selection is still subject to change.

"build_stage_2_external" contains the sample project "com.example.logging" which rebundles three existing Maven jar artifacts in one bundle and exports the SLF4J API. The "com.example.feature" project then defines and builds a feature containing the binary version of the resulting bundle and "com.example.source.feature" its sources version.

"build_stage_3_repository" contains the sample project "com.example.repository" which builds the p2 repository to be deployed on an internal Apache webserver. From there, an Eclipse target platform can then be setup on the developer machines.

"usage_demo" contains a Hello RCP demo project depending on the general Eclipse plugins, plus the "com.example.logging" bundles. Once a target platform has been setup using the p2 repository just built, the Eclipse IDE should be able to build the demo project and allow navigation into the sources of the required plugins.

Proceed as follows to reproduce the use case (note: using separate workspaces simulates the desired separate steps in the continuous integration process which should only build artifacts that have been changed and reuse the others as they were built before):

1. Extract the attached sample projects.
2. Move the contents of the "build_stage_*" folders into separate Eclipse Indigo Workspaces.
3. Move the "usage_demo" project into another separate Eclipse Indigo Workspace.
4. Subsequently run "mvn install" on the projects of the "build_stage_1_*" folders, except for the final one.
5. Run "mvn package" on the "com.example.repository" project to pack the resulting p2 repository.
6. Copy the results of the last step to a webserver.
7. In the workspace containing the "usage_demo" project setup a new target platform using the p2 repository just built. Make sure to select all features, including the source features.
8. Eclipse should now be able to build the "usage_demo" project and you should be able to navigate into the sources of the required bundles (Eclipse ones AND "com.example.logging").

I hope this explanation effectively describes my use case and I appreciate any hints and suggestions for implementing the solution in a more straightforward way.

Thank you for you patience and - once again - please forgive me if I wrongly blamed someone or something for shortcomings...

---
[1] http://dev.eclipse.org/mhonarc/lists/tycho-user/msg00907.html
[2] http://dev.eclipse.org/mhonarc/lists/tycho-user/msg00974.html
[3] http://dev.eclipse.org/mhonarc/lists/tycho-user/msg01018.html
[4] http://dev.eclipse.org/mhonarc/lists/tycho-user/msg01043.html
Comment 11 Timo Rohrberg CLA 2011-10-18 04:11:18 EDT
Please find the sample setup here (it's too large to add as an attachment):
https://docs.google.com/leaf?id=0B1Mh4R0LVb41YWRhMTlmNGQtMmM2MC00NjY0LTliZWItYjA0MzVjNGQ0ZmZl&hl=de
Comment 12 Mickael Istria CLA 2021-04-08 18:09:52 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.