Skip to content

Correctly defined resources for gradle subproject, which is outside of root project git structure, are silently ignored #359

@krzysztofgenge

Description

@krzysztofgenge

What version of OpenRewrite are you using?

I am using:

  • OpenRewrite v8.42.0
  • Gradle plugin v6.29.0
  • [org.openrewrite.recipe:rewrite-migrate-java v2.31.0

How are you running OpenRewrite?

I use Gradle plugin. I created a sample structure which replicates our issue

custom-path/
├── subproject2/
│   ├── src
│   ├── resources
│   ├── build.gradle
├── root-project/
│   ├── .git <- !!This git repo directory causes the subproject2/resources not being traversed. No recipes are applied for it!! 
│   ├── build.gradle
│   ├── settings.gradle
│   ├── subproject1/
│   │   ├── src
│   │   ├── resources
│   │   ├── build.gradle

the problem shows when the root-project contains a git repository and one of the subprojects is not a subfolder of the root-project. In the above example subproject2 is under custom-path next to root-project.

Can you share your configuration so that we can rule out any configuration issues?

Is your project public? If so, can you share a link to it?

I created a dummy project which demonstrates the issue - custom-path.zip

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

Unpack the sample project go to root-project directory and execute:

git init
gradle rewriteDryRun -Drewrite.activeRecipe=com.yourorg.TestXmlRecipeRange

What did you expect to see?

I expected to see log that subproject2 resources are parsed e.g.
These recipes would make changes to ../subproject2/resources/test-subproject2.xml
and the changes are present in the generated rewrite.patch file.
I would expect it behaves the same as for java files

What did you see instead?

When .git repo folder is in root-project directory the resources for subproject2 are ignored (the java files for that project are picked up correctly)
When .git repo folder is not in root-project directory all the files are correctly parsed.
See the attached screenshot that displays the result of both executions:
resources_subproject_issue

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

Please see the above screenshot and sample project. No errors, the resource path for subproject2 is ignored when .git repo is present on root-project.

##Possible root cause
Maybe the problem is somehow related with this logic https://github.com/openrewrite/rewrite-gradle-plugin/blob/main/plugin/src/main/java/org/openrewrite/gradle/isolated/DefaultProjectParser.java#L129

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions