-
Notifications
You must be signed in to change notification settings - Fork 196
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
Question regarding build classpath resolution problem with Tycho 4 #4653
Comments
Hi @zladdi mayn thanks for your detailed report and example! Embedding external jars like In any case of course in general it should still work and I'll try to take a look into it the next days, if you like you can try to transform your example into an integration-test to demonstrate the issue that will ensure such issue do not get unnoticed in the future. |
Thank you for the very fast response, @laeubi . Agreed, the embedding of JAR files is bad practice. Both our team and the development team are aware of this painful technical debt in the project. I appreciate the help I will try to transform the example into an integration test. Thanks for all the great work by you and all the other Tycho contributors! |
I have took a quick look and found out that the issue is caused by a slightly different classpath. While in the working case one see the following classpath:
And with the failing case one can see
so the issue is that we use the final build jar in one case and then it can't find the embedded jar of course. While it is strange that it happens explicitly with the I need to investigate deeper, but think the example itself is already small enough to be used as an integration case, so I just can encourage you to just integrate it then we should be able to verify if any fix makes the situation better here. |
Currently we cache the "known location" for an artifact, but for a reactor project this location can change (e.g. when it is finally packed to a jar). This leads to the unfortunate situation that we probably no longer find it in the map. This now first lookup the project with the map key, but if it is not found performs a deeper analysis of the artifacts and check if the location actually maps to the artifact location of the reactor project. If that is the case we use that instead of return nothing. Fix eclipse-tycho#4653
I now found the culprit, and why it is a problem with eager resolve, fix is here:
With the fix it works in both modes, I still want to encourage you to provide an integration-test to demonstrate the issue so we are sure such things do not happen in the future. |
Currently we cache the "known location" for an artifact, but for a reactor project this location can change (e.g. when it is finally packed to a jar). This leads to the unfortunate situation that we probably no longer find it in the map. This now first lookup the project with the map key, but if it is not found performs a deeper analysis of the artifacts and check if the location actually maps to the artifact location of the reactor project. If that is the case we use that instead of return nothing. Fix #4653 (cherry picked from commit 4d75930)
Please try out the current tycho snapshot build if it also fixes the problem in your larger project setup! |
Hi @laeubi |
No problem @zladdi the report here was very well written and the example was helpful to identify the issue quickly, well done!
If your company want to help with the development of Tycho itself, you might want to consider sponsor me to help with ongoing open source work. |
Hi @laeubi I also noticed that with version I am presently finalizing the port of the example project to the Tycho integration tests. Looks good so far, but want to make another round of tests before I push to my fork and create a PR. Hopefully at the beginning of next week I ll have everything ready.
I will see what I can do, as I am just an engineer at the bottom of the corporate ladder. But maybe I can convince the higher-ups to contribute. Let's keep our fingers crossed 🤞 |
About the BREE error see: https://github.com/eclipse-tycho/tycho/blob/tycho-4.0.x/RELEASE_NOTES.md#4011 I'll try to take a look at the build sadly there are some infra issues at the moment :-( |
Currently we cache the "known location" for an artifact, but for a reactor project this location can change (e.g. when it is finally packed to a jar). This leads to the unfortunate situation that we probably no longer find it in the map. This now first lookup the project with the map key, but if it is not found performs a deeper analysis of the artifacts and check if the location actually maps to the artifact location of the reactor project. If that is the case we use that instead of return nothing. Fix #4653 (cherry picked from commit 4d75930)
Currently we cache the "known location" for an artifact, but for a reactor project this location can change (e.g. when it is finally packed to a jar). This leads to the unfortunate situation that we probably no longer find it in the map. This now first lookup the project with the map key, but if it is not found performs a deeper analysis of the artifacts and check if the location actually maps to the artifact location of the reactor project. If that is the case we use that instead of return nothing. Fix #4653 (cherry picked from commit 4d75930)
Hello,
Context
At the company I work for, we have a long-standing Tycho project (> 10 years) that has some peculiarities. And before I ask the development team (which I am not part of) to address certain issues with the project setup, I wanted to ask here to get some clarifications.
The project consists of many (we are talking 100-eds of) Eclipse plugins, some of which may reference (via manifest entry
Require-Bundle
) each other. In some cases, the dependee plugin exports packages from an embedded JAR (whose relative path is specified in theBundle-Classpath
entry of its manifest) which are then imported and classes from which are referenced in the dependent's bundle.The problem
Up until Tycho 3.0.5, the above setup built without problems and worked during runtime, too. But we now how to upgrade to Tycho 4 (at least 4.0.8, but we plan on getting the latest, which is 4.0.10 at time of writing). However, we cannot do this, as we run into build classpath problems - i.e. the packages/classes referenced by a plugin that reside in JARs embedded in a required bundle cannot be resolved anymore (i.e. errors of the form
The import x.y.z cannot be resolved
andThe type x.y.z.T1 cannot be resolved. It is indirectly referenced from required type u.v.w.T2
).Small reproducible example
To demonstrate the exact problem and error messages we get, I have created a quite small (but not minimal) reproducible example here: https://github.com/zladdi/tycho-4-classpath-issue/
The setup is as follows:
dependee
uses classes fromcommons-lang3-3.17.0.jar
, which is embedded in the plugin underlib/
(i.e.Bundle-ClassPath: lib/commons-lang3-3.17.0.jar
), and exports the packageorg.apache.commons.lang3
(viaExport-Package
entry in the plugin's manifest)dependent
requires the plugindependee
(manifest entryRequire-Bundle: dependee
) and imports the packageorg.apache.commons.lang3
(manifest entryImport-Package: org.apache.commons.lang3
)dependee
) classes from packageorg.apache.commons.lang3
Attempting to build the the parent/aggregator project with the following command:
mvn -B clean verify -DskipTests -Dtycho.localArtifacts=ignore
fails with Tycho 4 (but succeeds with Tycho 3.0.5 and e.g. 2.7.5, for that matter) with the following errors, where
<parent-of-repo>
is the folder containing this repository/the aggregator/parent project:A few notes:
While the example project would build successfully when omitting this configuration option, the actual project won't. The reason for this is that with Tycho 4 we get an error of the form
The projects in the reactor contain a cyclic reference: ...
when using the default resolver. We will address this problem separately with the development team, but it could take quite some time until they will actually address this. That is why we switched to using<requireEagerResolve>true</requireEagerResolve>
, which does not report that problem, in the first placeSome more info acquired during build debugging
I noticed the following log output when running the above Maven command with the
-X
switchThis message is logged at
tycho-core-4.0.10.jar:org.eclipse.tycho.core.osgitools.OsgiBundleProject
line 234. I stepped through the build in the debugger to find out why this happens. AtOsgiBundleProject
line 217, there is the code that fetches the artifact descriptor for a given dependency:When building
dependent
and theentry
in above code corresponds todependee
, the return value ofgetArtifact
isnull
, which leads to above debug-level log message. Digging deeper intogetArtifact
, the key under whichdependee
is stored in a (linked hash) map that holds all artifacts is<parent-of-repo>/tycho-4-classpath-issue/dependee
, i.e. the Maven project's base directory, while the lookup key is<parent-of-repo>/tycho-4-classpath-issue/dependee/target/dependee-0.0.1-SNAPSHOT.jar
, i.e. the path to the Maven project's target artifact. As such, the lookup ingetArtifact
will not find the location ofdependee
and returnnull
.Question
Could someone please explain if the change in build classpath resolution behavior from Tycho 3 to 4 for above use case is intentional or a bug?
The text was updated successfully, but these errors were encountered: