-
Notifications
You must be signed in to change notification settings - Fork 339
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
org.openrewrite.maven.AddDependency: Make version
optional
#4637
Comments
hi! In general we're fairly cautious in allowing recipes to make changes that might negatively affect the build health. In that sense it's perhaps also not desirable to make the version optional, as that might then blow up when the version is not managed. In what use cases do you want to add quite literally any version of a dependency? Would it be an option for those cases to define a version initially, and then to clear it out using https://docs.openrewrite.org/recipes/maven/removeredundantdependencyversions ? |
Hi, @timtebeek ! I understand your vision and it really is a tricky balance between shielding the user from himself and make the tool flexible... However I want to point out that I find a a bit counterintuitive having to add a version where I don't want one. I think it would be simpler that OpenRewrite followed the Maven schema on that... Maybe the recipe should check if there is a managed version defined, what do you think? Is there any validation to check whether the version exists or not? About the https://docs.openrewrite.org/recipes/maven/removeredundantdependencyversions, it didn't work for me... My scenario is like this: <?xml version="1.0" encoding="UTF-8"?>
<project
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.company.app</groupId>
<artifactId>app-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<!-- OpenRewrite added this on a previous recipe -->
<dependency>
<groupId>my.company.mylibs</groupId>
<artifactId>mylibs-bom</artifactId>
<version>5.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project> <?xml version="1.0" encoding="UTF-8"?>
<project
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>my.company.app</groupId>
<artifactId>app-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>my.company.app</groupId>
<artifactId>app-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<!-- OpenRewrite added this -->
<dependencies>
<dependency>
<groupId>br.gov.bcb.ares</groupId>
<artifactId>ares-hibernate</artifactId>
<version>5.0.0-SNAPSHOT</version> <!-- RemoveRedundantDependencyVersions didn't removed this -->
</dependency>
</dependencies>
</project> The version is defined on the bom as the following: <dependency>
<groupId>br.gov.bcb.ares</groupId>
<artifactId>ares-hibernate</artifactId>
<version>${project.version}</version>
</dependency> Maybe OpenRewrite is comparing |
@timtebeek, version is option on the Gradle recipe: https://docs.openrewrite.org/recipes/gradle/adddependency |
On Maven, the tag
<version>
on<dependency>
is optional, as it can be managed by a managed dependency. If can manually add a dependency without version, theorg.openrewrite.maven.AddDependency
should also allow this.If you agree with my point of view, I think I can implement this as I already implemented a recipe from scratch.
The text was updated successfully, but these errors were encountered: