Skip to content

CreateTextFile recipe operates in root dir instead of module #258

@abetaev-equinix

Description

@abetaev-equinix

What version of OpenRewrite are you using?

I am using

  • Gradle plugin (how do I check the version? it uses latest, but I don't have any direct dependencies on Openrewrite)

How are you running OpenRewrite?

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

root
|- module
|  |- ...
|  '- submodule
|- ...
|- gradlew
|- rewrite.yaml
|- init.gradle
'- build.gradle.kts

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

type: specs.openrewrite.org/v1beta/recipe
name: com.example.CreateGradleProperties
recipeList:
  - org.openrewrite.text.CreateTextFile:
      relativeFileName: gradle.properties
      fileContents: |
        group={{groupId}}
        rdomain={{rdomain}}
./gradlew module:submodule:rewriteRun --init gradle.init

What did you expect to see?

gradle.properties is created in module/submodule/ directory.

What did you see instead?

gradle.properties is created in root directory.

Are you interested in contributing a fix to OpenRewrite?

If this is a bug, I can think of how this can be fixed.
The plugin's documentation does not state what is path relative to. I would expect the module where task runs, as per the Gradle plugin documentation:

When applied to a multi-project build, plugin behavior differs depending on whether the plugin is applied to the root project or to a sub-project. Applied to the root project, the plugin will parse and refactor all sources from all projects. Applied to any project other than the root project, the plugin will parse and refactor only sources from that project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions