gnodet-bot commented on code in PR #27293:
URL: https://github.com/apache/camel/pull/27293#discussion_r4172057068
##########
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");
+ // a component in a base package does not claim every class in it
+ assertNull(resolver.mavenGavForImport("org.apache.camel.Exchange"));
+
assertNull(resolver.mavenGavForImport("org.apache.camel.component.Anything"));
+ // a class looked up at runtime (often only probed for) still needs
the component class itself
+
assertNull(resolver.mavenGavForClass("org.apache.camel.component.aws2.s3.AWS2S3Constants"));
+ assertGav(resolver,
"org.apache.camel.component.aws2.s3.AWS2S3Component", "org.apache.camel",
"camel-aws2-s3");
Review Comment:
🔴 **Not addressed (davsclaus finding):** `com.fasterxml.jackson.databind` is
not mapped on `camel-4.22.x` — that mapping came from CAMEL-24809's third-party
list. `mavenGavForClass("com.fasterxml.jackson.databind.ObjectMapper")` returns
`null` here, so `assertNotNull` fails.
The mapping that does exist on this branch is
`com.fasterxml.jackson.annotation` (added by this PR to
`camel-main-known-dependencies.properties`). Use that instead:
```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:
⚠️ **Not addressed (davsclaus finding):** This paragraph is about
downloading dependencies, but it opens the "Running with Spring Boot or
Quarkus" section. It should be moved 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]