Closed runeflobakk closed 2 weeks ago
Hi @runeflobakk ; thanks for detailed write up! Must say I hadn't come across that type of usage of the rewrite-maven-plugin before; good to hear you already came this far with your use case.
The one thing I'm missing from your description above is if you had already considered or tried the -Drewrite.runPerSubmodule=true
option. It sounds like that might be what you're after to not wait until all modules are parsed.
Does that help you there? Otherwise we'd indeed be open to a fix if you're able to provide one.
@timtebeek Ooooh, that was spot-on! Thank you, it works perfectly! I must say my first experience trying out OpenRewrite is ridiculously good! 😄👍
@timtebeek Ooooh, that was spot-on! Thank you, it works perfectly! I must say may first experience trying out OpenRewrite is ridiculously good! 😄👍
Great to hear that got you past this hurdle, and glad to have try out the project. Thanks for the kind words, and perhaps see you at JavaBin in October!
What version of OpenRewrite are you using?
I am using
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a multi module project.
I want to rewrite source code in an early phase of the build (process-sources), in order to have the rewritten code participate in the usual compiling phase. This seems to work when building only the single module the way I would intuitively set it up: by binding
runNoFork
to aprocess-sources
in my POM:Everything appears to work really well when working with the Maven module in question, I get the source files rewritten as they should, but when running the entire multiproject, I get the following logged at the stage where I have configured rewrite-maven-plugin to execute:
And then further goals in the build fail because they depend on the code being rewritten.
I suspect my use-case is very similar to #755 , though I do not depend on the build-helper-maven-plugin. I use maven-dependency-plugin:unpack on an existing sources artifact, unpacking to
src/main/java
, and then wanted to runrunNoFork
on the unpacked sources for them to participate in the rest of the build, like ordinary Java source files.Is this related to the existing issues with running in multimodule projects? I am not sure why the plugin insists on delaying the execution, but I also found #720 which indicates this is by design. I have not found any configuration option to force the rewriting happening during the phase the plugin execution is bound to. Maybe that is what I am missing? :)
Attempt with earlier version
I did try downgrading to plugin v5.20.0 (together with rewrite-migrate-java v2.7.0) just to see if the version before #720 was released in 5.21.0 would give me the behavior I wanted. It seemed however to behave the same; the sources are rewritten when building only the single module, and no rewriting happens with a full multi module build. Only observable difference is the plugin does not log the "Delaying execution" message.
Are you interested in contributing a fix to OpenRewrite?
Sure, I can give it a go, if this seems to be a viable contribution to OpenRewrite :)
I hope it is OK to remove some sections in the issue template, as I intended the above to sufficiently describe the issue. I would be happy to provide a more self-contained reproducing example if you need it :)