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

Fix resources exclusion in a multi-module project with git repo #257

Merged

Conversation

radoslaw-panuszewski
Copy link
Contributor

@radoslaw-panuszewski radoslaw-panuszewski commented Jan 7, 2024

What's changed?

Fixed the bug with resources in subproject being excluded from processing.

What's your motivation?

I have a multi-module project like this:

.
├── src
│   └── main
│       └── resources
│           └── application-root.yml
└── subproject
    └── src
        └── main
            └── resources
                └── application-subproject.yml  

And I have a custom recipe to modify some YAML. While the application-root.yml is correctly modified, the application-subproject.yml is skipped. It is reproduced in the resources in subproject committed to git are correctly processed test case.

There is already a test case rewriteRun applies recipe to a multi-project build which aims to verify this situation, but it doesn't check the case when Git repo is available. There is a different code path in OmniParser for such case and it's not reached.

I believe that I've found a bug in the code of DefaultProjectParser. When the OmniParser is created for the root project, it is configured to exclude contents of its subprojects. But when it's created for the subproject, it's still configured to exclude the root project's subprojects, so also the subproject we want to parse.

Anything in particular you'd like reviewers to focus on?

I've added the Project parameter to the omniParser(). Please verify that the updated method usages are correct.

Additional changes

There was a typo in dependencyRepositoriesDeclaredInSettings test case which caused the test to fail. I fixed it: nevVersion -> newVersion

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@timtebeek
Copy link
Contributor

@travisboettcher this PR takes a slightly different approach to what you suggested in #252 ; Any thoughts to share here?

@travisboettcher
Copy link

@travisboettcher this PR takes a slightly different approach to what you suggested in #252 ; Any thoughts to share here?

I don't think I have any concerns, no - this change makes sense to me. If I understand correctly, we don't need to use the existing execution context when parsing resources, since they aren't likely to reference other sub-modules. In addition, the test added seems to cover my case, so I think we're good!

@timtebeek timtebeek linked an issue Jan 8, 2024 that may be closed by this pull request
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the detailed look & fix!

@timtebeek timtebeek added the bug Something isn't working label Jan 8, 2024
@timtebeek timtebeek merged commit 441bdb6 into openrewrite:main Jan 8, 2024
1 check passed
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
Archived in project
Development

Successfully merging this pull request may close these issues.

Gradle parser does not parse subproject resources
4 participants