davsclaus commented on code in PR #27293:
URL: https://github.com/apache/camel/pull/27293#discussion_r4171965431
##########
dsl/camel-kamelet-main/src/test/java/org/apache/camel/main/download/KnownDependenciesResolverTest.java:
##########
@@ -53,4 +55,47 @@ void mavenGavForClass_returnsPackageScopedDependency() {
public static class SomeClass {
}
+
+ @Test
+ void anImportResolvesAnyClassOfAComponent() {
+ // CAMEL-25239: any class of a component a source imports, not only
the component class itself, such as the
+ // constants of the headers of a component that a kamelet uses
+ KnownDependenciesResolver resolver = new KnownDependenciesResolver(new
SimpleCamelContext(), null, null);
+ resolver.loadKnownDependencies();
+
+ assertImport(resolver,
"org.apache.camel.component.aws2.s3.AWS2S3Component", "camel-aws2-s3");
+ assertImport(resolver,
"org.apache.camel.component.aws2.s3.AWS2S3Constants", "camel-aws2-s3");
+ assertImport(resolver,
"org.apache.camel.component.aws2.s3.utils.AWS2S3Utils", "camel-aws2-s3");
+ // a sibling package of another component is not mistaken for it
+ assertImport(resolver,
"org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConstants",
"camel-aws2-s3-vectors");
+ // a sub package of another component's package wins for its own
classes
+ assertImport(resolver,
"org.apache.camel.component.file.remote.SftpConstants", "camel-ftp");
+ assertImport(resolver, "org.apache.camel.component.file.GenericFile",
"camel-file");
+ // the libraries still resolve as before
+ assertGav(resolver, "com.fasterxml.jackson.databind.ObjectMapper",
"com.fasterxml.jackson.core", "jackson-databind");
Review Comment:
On camel-4.22.x nothing maps `com.fasterxml.jackson.databind` (that came
from CAMEL-24809), so this returns null and the assertion fails. Assert the
mapping that exists on this branch instead; this also covers the
jackson-annotations line added to `camel-main-known-dependencies.properties`:
```suggestion
assertGav(resolver, "com.fasterxml.jackson.annotation.JsonProperty",
"com.fasterxml.jackson.core", "jackson-annotations");
```
##########
docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc:
##########
@@ -226,6 +226,13 @@ camel run foo.java --download=false
== Running with Spring Boot or Quarkus
+For an `import` in a Java or Groovy source, a Camel component is also found by
its package, so
+importing any class of a component downloads it, not only the component class
itself. For
+example, a route that imports
`org.apache.camel.component.aws2.s3.AWS2S3Constants` for the
+headers of the `aws-s3-source` Kamelet gets `camel-aws2-s3` before the route
is compiled. A class
+that is only looked up while running still needs the component class itself,
so probing whether
+a class is present does not download a component.
Review Comment:
This paragraph is about downloading dependencies, but here it opens the
"Running with Spring Boot or Quarkus" section. Please move it up into `==
Downloading JARs over the internet`, after the `--download=false` example.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]