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

KnownDependenciesResolver to support packages #17035

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bartoszpop
Copy link
Contributor

This pull request enhances KnownDependenciesResolver to match the well known dependencies against packages up to the root package, so that a single entry in the camel-main-known-dependencies.properties file is sufficient to load any class from this jar, instead of having a separate entry for each class.

This is a cherry-pick from #17034

@davsclaus
Copy link
Contributor

what is the reason for this, this file is maintained by camel project and not be end users. It is an implementation detail.

@davsclaus
Copy link
Contributor

okay do you have an example of a real world situation this was beneficial - just want to understand better.

@bartoszpop
Copy link
Contributor Author

Hi @davsclaus, thank you for your feedback. We utilize this mechanism to inject predefined bean and AggregationStrategy classes to JBang runtime, meaning that we pass the parameter --dep=com.example:custom-catalog:1.0.0 and is contains camel-main-known-dependencies.properties with a list of custom classes pointing to custom jars, e.g.

org.example.some.BeanClass=com.example:some-jar:1.0.0
org.example.some.AggregationStrategyClass=com.example:some-jar:1.0.0
org.example.other.BeanClass=com.example:other-jar:1.0.0

Instead of having separate entries for each class it would be reasonable to have them merged, because all classes in the same jar will share the same package, e.g.

org.example.some=com.example:some-jar:1.0.0
org.example.other=com.example:other-jar:1.0.0

@davsclaus davsclaus force-pushed the package-scoped-deps-main branch from e61f438 to 7fbf7f0 Compare February 5, 2025 06:31

private String findGav(String prefix) {
String gav = mappings.get(prefix);
while (gav == null && prefix.lastIndexOf(".") != -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot keep dropping sub package names, which can end up into picking the wrong JAR.
It should only drop the classname

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the class may be in a subpackage, e.g. consider com.example:somejar:1.0.0 and two classes com.example.somejar.subpackage.SomeClass
com.example.somejar.otherpackage.OtherClass

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

Successfully merging this pull request may close these issues.

2 participants