-
Notifications
You must be signed in to change notification settings - Fork 86
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
Spring Batch recipe for MigrateStepBuilderFactory #284
Conversation
Sorry I haven't had time to look at this yet, but I haven't forgotten |
Hello, I'm interested in this recipe as SpringBatch4To5Migration doesn't contains this migration yet. Is it pending of anything? |
Hi @alexpm-14 ; I'd missed this comment as I wasn't subscribed to this thread yet; I've gone ahead and made some changes to adopt rewrite 8; that hasn't yet solved the template errors reported before, but at least one of the three tests now only has type issues, no longer any template issues, so there is some progress. As for what's needed to complete this one: I don't exactly know; I'd have to dive in more, but don't currently have the time. You're welcome to explore if you're up for it; you can fork https://github.com/desprez/rewrite-spring/tree/main and see if that get's you closer. Feel free to tag me if you make a PR there or here, and I can try to work in a review. |
@knutwannheden Perhaps you'd have an intuitive understanding of why we see template stop introduced here? A quick look would be appreciated if you're able to fit that in. |
doAfterVisit(new RemoveStepBuilderFactoryVisitor(clazz, enclosingMethod)); | ||
|
||
JavaTemplate template = JavaTemplate | ||
.builder("new StepBuilder(#{any(java.lang.String)}, jobRepository)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From looking at the problem briefly it appears this jobRepository
variable does not yet exist in the context when the template is applied, because that's only added as a method argument in doAfterVisit(new RemoveStepBuilderFactoryVisitor(clazz, enclosingMethod))
. That's then likely what triggers the template error, even if the produced output would otherwise textually be ok. It might help to introduce the method argument first, before using it here.
src/main/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactory.java
Outdated
Show resolved
Hide resolved
...WithSpringBoot_3_0/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactoryTest.java
Show resolved
Hide resolved
...WithSpringBoot_3_0/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactoryTest.java
Show resolved
Hide resolved
...WithSpringBoot_3_0/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactoryTest.java
Outdated
Show resolved
Hide resolved
...WithSpringBoot_3_0/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactoryTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactory.java
Outdated
Show resolved
Hide resolved
...WithSpringBoot_3_0/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactoryTest.java
Show resolved
Hide resolved
...WithSpringBoot_3_0/java/org/openrewrite/java/spring/batch/MigrateStepBuilderFactoryTest.java
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Reworked this a bit to ensure the |
Isolated the issue into this PR: |
* Isolate JavaTemplate issue with generic type parameters - For openrewrite/rewrite-spring#284 * Appease the bot * Inline template method `if` * Also print preceding comments for J prefixes * Look at padding before methodInvocation too * Clear out unintentional whitespace As this trips up the auto format in IntelliJ * Restore intentional newlines in `changeFieldToMethod` * Remove duplicate import for test template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for kicking this off @desprez , and you patience throughout. Wasn't easy to get this one across the line, given the JavaTemplate issue upstream, but we managed to polish this up into something I'm quite pleased with now.
TEMPLATE_STOP tell me that something is missing by I don't know what