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

"Illegal character in path at index" error with org.openrewrite.maven.RemoveProperty recipe #4632

Open
rcsilva83 opened this issue Oct 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@rcsilva83
Copy link
Contributor

rcsilva83 commented Oct 31, 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 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.RemoveManagedDependency: # This uses ${spring-boot.version}
      groupId: org.springframework.boot
      artifactId: spring-boot-dependencies
  - org.openrewrite.maven.RemoveProperty:
      propertyName: spring-boot.version

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

  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.4</version>
    <relativePath/>
  </parent>

  <groupId>my.company.myappgroupId>
  <artifactId>myapp-parent</artifactId>
  <packaging>pom</packaging>
  <name>My App</name>
  <version>1.0.0-SNAPSHOT</version>

  <properties>
    <spring-boot.version>2.5.4</spring-boot.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <plugins>
      <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>
    </plugins>
  </build>
</project>

What did you expect to see?

Property spring-boot.version removed.

What did you see instead?

No changes.

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

java.lang.IllegalArgumentException: Illegal character in path at index 96: file:///C:/Users/user/.m2/repository/org/springframework/boot/spring-boot-dependencies/${spring-boot.version}/spring-boot-dependencies-${spring-boot.version}.pom
  java.base/java.net.URI.create(URI.java:883)
  org.openrewrite.maven.internal.MavenPomDownloader.download(MavenPomDownloader.java:560)
  org.openrewrite.maven.tree.ResolvedPom$Resolver.mergeDependencyManagement(ResolvedPom.java:802)
  org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentDependenciesRecursively(ResolvedPom.java:435)
  org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentDependenciesRecursively(ResolvedPom.java:453)
  org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively(ResolvedPom.java:387)
  org.openrewrite.maven.tree.ResolvedPom$Resolver.resolve(ResolvedPom.java:358)
  org.openrewrite.maven.tree.ResolvedPom.resolve(ResolvedPom.java:176)
  org.openrewrite.maven.UpdateMavenModel.updateResult(UpdateMavenModel.java:162)
  org.openrewrite.maven.UpdateMavenModel.lambda$updateResult$8(UpdateMavenModel.java:167)
  org.openrewrite.internal.ListUtils.map(ListUtils.java:177)
  org.openrewrite.maven.UpdateMavenModel.updateResult(UpdateMavenModel.java:165)
  org.openrewrite.maven.UpdateMavenModel.visitDocument(UpdateMavenModel.java:131)
  org.openrewrite.xml.tree.Xml$Document.acceptXml(Xml.java:149)
  org.openrewrite.xml.tree.Xml.accept(Xml.java:54)
  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
  ...

Are you interested in contributing a fix to OpenRewrite?

yes

@rcsilva83 rcsilva83 added the bug Something isn't working label Oct 31, 2024
@rcsilva83
Copy link
Contributor Author

I found out that it works when I run org.openrewrite.maven.RemoveManagedDependency and org.openrewrite.maven.RemoveProperty separately, i.e on separate mvn rewrite:run commands.

It looks like org.openrewrite.maven.RemoveManagedDependency recipe isn't updating the model used by OpenRewrite after removing spring-boot-dependencies...

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

No branches or pull requests

1 participant