-
-
Notifications
You must be signed in to change notification settings - Fork 303
fix unable to reference non-jar resources in MavenBndRepo and repo macro #7038
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
fix unable to reference non-jar resources in MavenBndRepo and repo macro #7038
Conversation
db8dc80 to
89ed4fe
Compare
|
Update: I am certain that it is ok.
but with just So I think it is useful to have it. Original: I am not sure about my change in The current code is adopted from before the current code was adopted for Multi-Release JARs in a7a6bee#diff-32c7fa31300fdfcff9b45a51a4a8cf962650b0a2a2b9d14eea2bcb36aca3a25fR782 I wonder if I should just do this for non-Jar files: |
5eb9a2a to
7ef7597
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issues preventing the use of non-JAR files (e.g., .so, .dylib dynamic libraries) from Maven repositories via the ${repo} macro and -includeresource directive. The fix addresses two main problems: MavenBndRepository's inability to handle coordinates for non-JAR file extensions, and failures when including these resources via the ${repo} macro.
Key Changes
- Enhanced ZipException handling to gracefully process non-JAR files instead of failing
- Fixed file extension check bug (
.libinstead oflib) - Added filtering to prevent non-JAR files from being added as Eclipse classpath library entries
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| biz.aQute.bndlib/src/aQute/bnd/osgi/resource/ResourceBuilder.java | Added ZipException catch block to handle non-JAR files by treating them as octet-stream resources |
| biz.aQute.bndlib/src/aQute/bnd/build/ProjectBuilder.java | Added ZipException handling and null check when processing repo references to skip non-JAR files |
| biz.aQute.bndlib/src/aQute/bnd/build/Project.java | Fixed typo in extension check - changed endsWith("lib") to endsWith(".lib") |
| bndtools.builder/src/org/bndtools/builder/classpath/BndContainerInitializer.java | Added check to skip non-JAR files when adding library entries to Eclipse classpath |
| biz.aQute.bndlib.tests/test/test/ProjectTest.java | Added test case testRepoCollectorNonJar() to verify non-JAR resource inclusion |
| biz.aQute.bndlib.tests/testresources/ws-repononjar/* | Added test workspace with Maven repository cache containing .so and .dylib files |
- added testcase for non-jar repo references tp prove the current problems of bndtools#6660 - Fix file extension check for library containers. Changed the file name check from 'lib' to '.lib' to correctly identify library containers based on file extension. There are other places where ".lib" is checked already. - Added handling for ZipException in ProjectBuilder and ResourceBuilder to support non-JAR files (e.g., .so, .dylib) referenced in repositories. This prevents errors when such files are encountered (e.g. via ${repo} macro) and ensures dependencies and resources are processed gracefully. - Also do not add non-jar files as library entries in BndContainerInitializer Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
7ef7597 to
afd45dd
Compare


Closes #6660
This fixes the problem specifically in the comment #6660 (comment)
and the test github repo:
https://github.com/steinybot/bug-reports/tree/bnd/illegal-argumen
The problem was the the developer wants to reference a maven-repository entry which is NOT a .jar file via the
${repo}macro. But currently bnd assumes a .jar file in a couple of places and fails innew Jar(file)if it is not a .jar.There were two issues:
.soand.dylibfiles-includeresourceswith ${repo} macro fails to reference themfails to load e.g.
/.m2/repository/org/weasis/thirdparty/org/opencv/libopencv_java/4.6.0-dcm/libopencv_java-4.6.0-dcm-linux-x86-64.so( to my knowledge maven repos can contain various file extensions and not just .jar files)
After the fix
The two issues are resolve:
.soand.dylibfilesI got the
.soand.dylibfile included.BTW: also
latestwould work instead of the awkward version syntax4.6.0.-dcm(see description of #6660 )TODOs