bndtools / bnd

Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
https://bndtools.org
Other
532 stars 305 forks source link

[bnd-maven-plugin] Disable M2E integration #6258

Closed Marcono1234 closed 1 month ago

Marcono1234 commented 2 months ago

Version

Description

When you have bnd-maven-plugin's bnd-process goal configured, it seems Eclipse generates the MANIFEST.MF automatically during build (without any extra Bnd Eclipse plugins).

The problem is that this MANIFEST.MF does not seem to match what a regular Maven execution from command line would produce:

For the project where I am seeing this behavior, the OSGi attributes are an additional feature, but it does not matter much whether Eclipse generates them or not (if necessary the integration test could tell users to use mvn ... instead of running the test in the IDE). However, due to the differences in the generated MANIFEST.MF, users will now see confusing assertions failures; especially if Eclipse is rebuilding the project while you are running mvn ... from command line.

Therefore in this situation it might be easiest to just disable M2E integration in the bnd-maven-plugin configuration. Is that possible somehow?

(I originally noticed this for https://github.com/google/gson, whose gson module is using bnd-maven-plugin)

[^1]: That is probably intended and the correct behavior, but for my use case that behavior is not helpful.

chrisrueger commented 2 months ago

Sounds a little bit like this: https://bnd.discourse.group/t/stop-gradle-from-stepping-on-eclipses-long-toes/295/5 (or here)

reckart commented 1 month ago

I haven't tried it, but I would assume you can probably override the default m2e lifecycle mapping provided by the plugin using the lifecycle-mapping plugin and set it to ignore.

Marcono1234 commented 1 month ago

Thanks for the tips from both of you!

I was hoping more for a simple boolean plugin parameter for bnd-maven-plugin, but I might give the lifecycle-mapping a try. The problem is that it is quite verbose, and keeping it in sync with bnd-maven-plugin might be a bit cumbersome / there is no direct connection between the two. So it can easily happen that one of the configurations becomes outdated, or when a user refactors their project they might forget to move or remove the lifecycle-mapping configuration.

pkriens commented 1 month ago

Can we close this?

Marcono1234 commented 1 month ago

Can we close this?

If bnd-maven-plugin itself does not provide an option for this, and you don't think adding a parameter for this would be worth it / possible, and instead users should use the solutions mentioned above, then yes feel free to close this. Thanks for asking though.