Croway commented on code in PR #125:
URL:
https://github.com/apache/camel-upgrade-recipes/pull/125#discussion_r3852159701
##########
camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.22.yaml:
##########
@@ -35,4 +36,18 @@ recipeList:
oldArtifactId: camel-spring-ai-tools-starter
newGroupId: org.apache.camel.springboot
newArtifactId: camel-ai-tool-starter
- newVersion: 4.22.0
+ newVersion: @camel-spring-boot-version@
+---
+##
https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc#camel-langchain4j-tools-deprecated
+type: specs.openrewrite.org/v1beta/recipe
+name: org.apache.camel.upgrade.camel422.migrateAiToolStarterDependency
+displayName: Use camel-ai-tool-starter instead of camel-ai-tool
+description: Replaces the plain camel-ai-tool dependency with
camel-ai-tool-starter, so that a Spring Boot application gets the component
auto-configuration. The plain artifact is what the Camel recipe adds when
migrating langchain4j-tools routes; duplicates are removed when the starter is
already declared.
+recipeList:
+ - org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
+ oldGroupId: org.apache.camel
+ oldArtifactId: camel-ai-tool
+ newGroupId: org.apache.camel.springboot
+ newArtifactId: camel-ai-tool-starter
+ newVersion: @camel-spring-boot-version@
+ - org.openrewrite.maven.RemoveDuplicateDependencies
Review Comment:
Both fixed in e047318.
**Multi-module gating.** The recipe is now gated on the module using Spring
Boot. I used `org.openrewrite.maven.search.FindDependency` rather than
`ModuleHasDependency`: `FindDependency` marks the pom that declares the
dependency, which is exactly the granularity this recipe needs since it only
edits poms, and it works without a Java parser. `ModuleHasDependency` needs the
sources grouped in a `mavenProject(...)`, and `org.openrewrite.java.Assertions`
cannot even initialise in this module — it only has `rewrite-java-21` on the
classpath while CI runs JDK 17, which is why no existing test here uses it.
Verified on a scratch two-module build (one Boot module, one plain Camel
module, both declaring `camel-ai-tool`): the Boot module gets the starter, the
plain module keeps `camel-ai-tool` untouched.
**RemoveDuplicateDependencies.** Removed entirely rather than scoped — it
has no groupId/artifactId options, so it could not have been narrowed anyway.
It turned out to be unnecessary: `ChangeDependencyGroupIdAndArtifactId` does
not create a duplicate when the target artifact is already declared. The
`aiToolStarterIsNotDuplicated` test now covers that directly (input declares
both `camel-ai-tool` and `camel-spring-ai-tools-starter`, output has a single
`camel-ai-tool-starter`) and passes with no dedupe step.
One thing this shook out: I first tried `RemoveDependency` + `AddDependency`
instead. It passed unit tests but silently failed on a real project —
`AddDependency` did not add, leaving a Boot module with no ai-tool dependency
at all, most likely because `camel-ai-tool-starter:4.22.0-SNAPSHOT` is not
resolvable yet. `ChangeDependencyGroupIdAndArtifactId` is a pure pom transform
and has no such dependency on resolution, so I kept it.
--
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]