Skip to content
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.UpgradeDependencyVersion doesn't add a version if there wasn't one previously #4638

Open
rcsilva83 opened this issue Nov 1, 2024 · 3 comments
Labels
bug Something isn't working question Further information is requested

Comments

@rcsilva83
Copy link
Contributor

rcsilva83 commented Nov 1, 2024

What version of OpenRewrite are you using?

I am using

  • Maven plugin v5.43.1
  • rewrite-maven v8.38.0

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a multi-module project.

      <plugin>
        <groupId>org.openrewrite.maven</groupId>
        <artifactId>rewrite-maven-plugin</artifactId>
        <version>5.43.1</version>
        <configuration>
          <activeRecipes>
            <recipe>my.company.rewrite.recipe.MyRecipe</recipe>
          </activeRecipes>
          <exportDatatables>true</exportDatatables>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>my.company.rewrite.recipe</groupId>
            <artifactId>my-rewrite</artifactId>
            <version>1.0.0-SNAPSHOT</version>
          </dependency>
        </dependencies>
      </plugin>

And this is MyRecipe:

type: specs.openrewrite.org/v1beta/recipe
name: my.company.rewrite.recipe.MyRecipe
displayName: My Recipe
description: This is an OpenRewrite recipe
recipeList:
  - org.openrewrite.maven.UpgradeDependencyVersion:
      groupId: com.querydsl
      artifactId: "*"
      newVersion: 5.1.0

What is the smallest, simplest way to reproduce the problem?

<?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/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>my.company.myapp</groupId>
  <artifactId>myapp</artifactId>
  <packaging>jar</packaging>
  <name>My App</name>

  <dependencies>
    <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-jpa</artifactId>
    </dependency>
  </dependencies>

</project>

What did you expect to see?

<?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/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>my.company.myapp</groupId>
  <artifactId>myapp</artifactId>
  <packaging>jar</packaging>
  <name>My App</name>

  <dependencies>
    <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-jpa</artifactId>
      <version>5.1.0</version>
    </dependency>
  </dependencies>

</project>

What did you see instead?

Nothing changed:

<?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/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>my.company.myapp</groupId>
  <artifactId>myapp</artifactId>
  <packaging>jar</packaging>
  <name>My App</name>

  <dependencies>
    <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-jpa</artifactId>
    </dependency>
  </dependencies>

</project>

What is the full stack trace of any errors you encountered?

None

Are you interested in contributing a fix to OpenRewrite?

Yes. If you agree with this bug report, I can implement as I already implemented a recipe from scratch.

@rcsilva83 rcsilva83 added the bug Something isn't working label Nov 1, 2024
@timtebeek
Copy link
Contributor

hi! Did you also try the property overrideManagedVersion already? That's set to false by default:
https://docs.openrewrite.org/recipes/maven/upgradedependencyversion

@timtebeek timtebeek added the question Further information is requested label Nov 1, 2024
@mccartney
Copy link
Contributor

I suppose the sections:

What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
What did you see instead?

are messed up in the description.

The observed is without the <version>5.1.0</version>. The expected is with the line. And the foo-bar is irrelevant.

@rcsilva83
Copy link
Contributor Author

@timtebeek , I tried but it didn't work either.

@mccartney , sorry about that. I fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
Status: No status
Development

No branches or pull requests

3 participants