Skip to content
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

Tycho 4.0.5 cannot find dependency of fragment #3441

Open
Phillipus opened this issue Jan 30, 2024 · 9 comments
Open

Tycho 4.0.5 cannot find dependency of fragment #3441

Phillipus opened this issue Jan 30, 2024 · 9 comments

Comments

@Phillipus
Copy link

Phillipus commented Jan 30, 2024

I have:

Plugin com.archimatetool.editor
Plugin com.archimatetool.canvas - dependent on com.archimatetool.editor

Fragment com.archimatetool.editor.tests- host is com.archimatetool.editor
Fragment com.archimatetool.canvas.tests - host is com.archimatetool.canvas

Because some tests in com.archimatetool.canvas.tests extend tests in com.archimatetool.editor.tests there is an additional entry in the com.archimatetool.canvas.tests build.properties file:

extra.. = platform:/fragment/com.archimatetool.editor.tests

(I found the advice to do that here)

When I run the tests in the fragments using Tycho 4.0.5 I now get the error "Missing requirement: com.archimatetool.canvas.tests 4.0.0 requires 'org.eclipse.equinox.p2.iu; com.archimatetool.editor.tests 0.0.0' but it could not be found"

This is working with Tycho 4.0.4.

Did anything change in 4.0.5 that might affect how these are being resolved?

@laeubi
Copy link
Member

laeubi commented Jan 31, 2024

Did anything change in 4.0.5 that might affect how these are being resolved?

I have no clue, we changed the way filters are applied to be more generic so maybe the requirement simply don't match the environment, but the setup seems strange here and I did not found any reference to extra.. in any tests in Tycho itself so there is a good chance this is some kind of hidden feature no one is really aware of (the mentioned stack overflow is 10 years old!)

So best chance is provide an integration-test to demonstrate the issue and we can probably take a look here.

@Phillipus
Copy link
Author

The issue is that Fragment A has a dependency on Fragment B but Tycho doesn't resolve Fragment B because all the package names in Fragment A are the same as Fragment A's host plug-in and it resolves the host plug-in instead of the Fragment. So I've added an Import-Package: packageName statement to Fragment A where packageName is unique to Fragment B. Tycho can now resolve Fragment B.

As for the extra.. line, as you say that doesn't seem to be documented anywhere and that reference to it is very old.

@Phillipus
Copy link
Author

As for the extra.. line, as you say that doesn't seem to be documented

Actually it is documented:

extra. - extra classpaths used to perform automated build. Classpath can either be relative paths, or platform urls referring to plug-ins and fragments of your development environment (e.g. ../someplugin/xyz.jar, platform:/plugins/org.apache.ant/ant.jar). Platform urls are recommended over relative paths;

https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Freference%2Fpde_feature_generating_build.htm

So I don't know if this is something that Tycho should still support? It did in 4.0.4.

@laeubi
Copy link
Member

laeubi commented Jan 31, 2024

@Phillipus yes it is documented for pde build and Tycho try to support as much as possible but it seems there is no test for it --> it may break anytime :-\

So if there is demand for that feature a test would be required to make sure

  1. how it can be used
  2. that it works
  3. that it does not break in the future

@Phillipus
Copy link
Author

I attempted a basic test consisting of two plug-ins and two fragments with one fragment dependent on the other and using the extra.. statement. It passed on Tycho 4.0.5. It was only when I introduced JUnit and the fragment classes were converted to JUnit tests that it didn't pass on Tycho 4.0.5. Therefore it's not straightforward so I'm going to leave it for now and see if anyone else comes across the problem.

Phillipus added a commit to archimatetool/archi that referenced this issue Jan 31, 2024
- With Tycho 4.0.5 the com.archimatetool.editor.tests fragment is not resolved from com.archimatetool.canvas.tests

- See eclipse-tycho/tycho#3441

- Remove the line "extra.. = platform:/fragment/com.archimatetool.editor.tests" from build.properties

- Add "Import-Package: com.archimatetool.testingtools" to the com.archimatetool.canvas.tests manifest. This ensures that the com.archimatetool.editor.tests fragment is resolved by forcing it to load
Phillipus added a commit to archimatetool/archi that referenced this issue Jan 31, 2024
- With Tycho 4.0.5 the com.archimatetool.editor.tests fragment is not resolved from com.archimatetool.canvas.tests

- See eclipse-tycho/tycho#3441

- Remove the line "extra.. = platform:/fragment/com.archimatetool.editor.tests" from build.properties

- Add "Import-Package: com.archimatetool.testingtools" to the com.archimatetool.canvas.tests manifest. This ensures that the com.archimatetool.editor.tests fragment is resolved by forcing it to load because the package name is unique to that fragment (whereas importing a package that also exists in the fragment's host plug-in will load the host, not the fragment)
@Phillipus
Copy link
Author

Phillipus commented Jan 31, 2024

Actually Tycho 4.0.5 is resolving the extra.. = platform:/fragment line in build.properties but it depends upon the order of declaration of modules in the pom.xml.

Suppose we have two fragments, org.foo.package1 and org.foo.package2. If org.foo.package2 has a extra.. = platform:/fragment/org.foo.package1 declaration then the module order in the pom has to be:

<modules>
   <module>org.foo.package1</module>
   <module>org.foo.package2</module>
</modules>

In my own case I just re-arranged the order of modules in the pom and it works again.

But surely the order of modules should not matter?

@laeubi
Copy link
Member

laeubi commented Feb 1, 2024

@Phillipus then it seems we need to make sure it is used as a requirement in the resolving stage, would you mind to create a test that shows the wrong ordering issue?

@Phillipus
Copy link
Author

I made a simple test with 2 plug-ins, 2 fragments and one pom.xml and I can't reproduce it with that simple example. My real life use case is more complicated with more than one pm, tests, and profiles.

@Phillipus
Copy link
Author

Phillipus commented Feb 1, 2024

I've finally created a reproducer, attached.

It involves extending a class from a fragment in another class that contains unit tests. There's a .mvn/maven.config file with Tycho version set to 4.0.5 where the build fails. If this is set to 4.0.4 the build is successful.

Note - the comment above about the order of module declaration doesn't apply to this example.

Could someone try the attached project and see if they get the same result, or maybe I missed something?

test.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants