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

Gradle parser does not parse subproject resources #252

Closed
travisboettcher opened this issue Dec 29, 2023 · 0 comments · Fixed by #257
Closed

Gradle parser does not parse subproject resources #252

travisboettcher opened this issue Dec 29, 2023 · 0 comments · Fixed by #257
Labels
bug Something isn't working

Comments

@travisboettcher
Copy link

When using the org.openrewrite.properties.AddProperty recipe, I noticed that the file I was trying to target (hibernate.properties) was not being updated. In trying to get it to work, I've seen the recipe work on other properties files, so I don't believe it's the recipe.

I'm wondering it the culprit is here when it is parsing the resources of a project:

for (File resourcesDir : sourceSet.getResources().getSourceDirectories()) {
    if (resourcesDir.exists()) {
        OmniParser omniParser = omniParser(alreadyParsed);
        List<Path> accepted = omniParser.acceptedPaths(resourcesDir.toPath());
        sourceSetSourceFiles = Stream.concat(
                sourceSetSourceFiles,
                omniParser.parse(accepted, resourcesDir.toPath(), new InMemoryExecutionContext())
        );
        sourceSetSize += accepted.size();
    }
}

In particular, passing a new InMemoryExecutionContext into the omniparser rather than the existing ctx.

What version of OpenRewrite are you using?

I am using the OpenRewrite Gradle plugin v6.6.2 (I also tried 6.6.3 just in case)

How are you running OpenRewrite?

I am using the Gradle plugin and it is a multi-module project.

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

Reproduced here: OpenRewrite-bug.zip

What did you expect to see?

The file example/src/main/resources/hibernate.properties should be updated to include a new property, hibernate.type.preferred_uuid_jdbc_type=CHAR

What did you see instead?

The file is not updated, although if I move it to the top-level directory, it does get updated. If I remove the precondition, the gradle/gradle-wrapper.properties file gets updated - so I don't believe it's the recipe.

Are you interested in contributing a fix to OpenRewrite?

Possibly!

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
1 participant