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

Bug 570883 - m2e PDE Maven target location: Snapshot-Builds with the same version are not updated #124

Closed
elbird opened this issue May 11, 2021 · 8 comments
Milestone

Comments

@elbird
Copy link

elbird commented May 11, 2021

When a Snapshot build of an artifact which is referenced via "<location type="Maven" ..." is updated, the changes are not reflected in the next tycho build. Because the tycho will use the artifact from the OSGI bundle cache "~/.m2/repository/p2/osgi/bundle" instead the updated in the local maven repository.

Steps to reproduce

  • Setup and install a simple Maven project which publishes a jar-file as SNAPSHOT release
  • Reference the Maven project in a tycho build's target platform with "<location type="Maven" ..."
  • Build the tycho-project
  • Make changes to the simple Maven and run mvn install again
  • Rebuild the tycho-project

Result:
the changes in the SNAPSHOT build of the simple Maven project are not reflected in the tycho build

Workaround:
Clean the maven osgi cache manually - delete Directory of the simple Maven project from the local OSGI cache in the local maven repo "~/.m2/repository/p2/osgi/bundle"

Here is a quick reproducer:
https://github.com/elbird/tycho-pde-maven-snapshot-reproducer

https://bugs.eclipse.org/bugs/show_bug.cgi?id=570883

@laeubi
Copy link
Member

laeubi commented Jan 2, 2022

Even though it sounds a bit nasty, a simple fix might be to simply ignore the cache for any version that ends with SNAPSHOT ..

@Bananeweizen
Copy link
Contributor

Would your suggestion still work for "mvn -o"?

@mickaelistria
Copy link
Contributor

I think this is an interesting limitiation to mitigate. Artifacts coming from <location type="Maven" should ideally not be copied to ~/.m2/repository/p2/osgi/bundle, they should be directly referenced from the usual Maven repo. This would also greatly facilitate implementation of #443 and other integration with plain Maven stuff.

@laeubi
Copy link
Member

laeubi commented Jan 3, 2022

Artifacts coming from <location type="Maven" should ideally not be copied to ~/.m2/repository/p2/osgi/bundle, they should be directly referenced from the usual Maven repo.

Actually any artifact coming from a local file should not be copied there (this problem not only applies to maven location type files), but I found it rather hard to follow the path of method calls and find a way to inject that information without much hassle.

@mickaelistria
Copy link
Contributor

@elbird Can you please retry with 2.7.0-SNAPSHOT , it's possible that #484 actually fixes this issue.

@jstroleny
Copy link
Contributor

Hi @mickaelistria: I've tested this with Directory target location (pointed by @laeubi that it should be handled in same way, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=570883#c3) and I can confirm that issue is no longer reproducible with 2.7.0-SNAPSHOT version. (artifacts are not copied into ~/.m2/repository/p2/osgi/bundle)

I've tested it using this simple project https://github.com/jstroleny/tycho-exploded-bundles (from https://bugs.eclipse.org/bugs/show_bug.cgi?id=569146 where we met same caching issue).

I did following steps to reproduce (see project above):

  1. have library in target platform which exports some package (e.g. org.apache.tools.ant)
  2. use class from that package in bundle (e.g. import org.apache.tools.ant.DirectoryScanner in my.example.bundle.Example).
  3. run mvn clean package
  4. build succeeded
  5. change Export-Package directive in MANIFEST.MF for library in target platform and remove org.apache.tools.ant package
  6. run mvn clean package again
  7. build should fail

With version 2.5.0 the build succeeds at the end as previous artifact is cached in m2 repo and it is reused wrongly for subsequent builds. In 2.7.0-SNAPSHOT, it fails correctly.

I think these steps can be automated by tycho-its if you find it valuable, from previous issue, there is already integration test with similar structure, but it is testing just explosion of bundle and library is not exporting anything to bundles (see e8e6e5c), so there is no real compilation behind it, would be needed to adjust or create similar test for testing of this issue.

@mickaelistria
Copy link
Contributor

Thanks for verifying!

@mickaelistria mickaelistria added this to the 2.7 milestone Jan 6, 2022
@laeubi
Copy link
Member

laeubi commented Jan 6, 2022

@jstroleny ist would be cool if you could provide a PR that adds an integration test-case for this!

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

5 participants