0

I am trying to add a Spring cloud dependencies through OpenRewrite recipe:-

<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-starter</artifactId>
</dependency>

tried with org.openrewrite.maven.AddDependency , here version not required as it should come from bom or parent properties, but it is not working as below:-

- org.openrewrite.maven.AddDependency:
      groupId: io.awspring.cloud
      artifactId: spring-cloud-aws-starter
      releasesOnly: null
      optional: null
  • 1
    The version is required as per: https://docs.openrewrite.org/recipes/maven/adddependency – Tim Jul 24 '23 at 12:20
  • @Tim Even after adding version also not reflecting change in rewrite.patch - org.openrewrite.maven.AddDependency: groupId: io.awspring.cloud artifactId: spring-cloud-aws-starter version: 3.0.1 – manish kumar Jul 24 '23 at 17:30
  • 1
    You'll also want to add a `onlyIfUsing` argument I suppose, based on what I see here: https://github.com/openrewrite/rewrite/blob/084fbd8b28e0724d68e837de6baa3d7d96445851/rewrite-maven/src/main/java/org/openrewrite/maven/AddDependency.java#L174 – Tim Jul 24 '23 at 19:58
  • @Tim - onlyIfUsing argument is not much clear for me. `@Option(displayName = "Only if using", description = "Used to determine if the dependency will be added and in which scope it should be placed.", example = "org.junit.jupiter.api.*") String onlyIfUsing` Is it only asking for scope ? how package name ex: org.junit.jupiter.api.* will be decided. Please provide some more details. – manish kumar Jul 27 '23 at 14:16
  • 1
    Hi Manish; the `onlyIfUsing` argument should be a class that you're (already) using from the dependency that you're adding; it helps prevent adding a dependency to a project that's not used. There's some more examples here which could give you an idea of what to use: https://github.com/search?q=org%3Aopenrewrite+onlyIfUsing+language%3AYAML&type=code&l=YAML – Tim Jul 27 '23 at 20:02

0 Answers0