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

Feature request : aggregate applied recipes in a multi module project and print them at the end #328

Closed
yeikel opened this issue Apr 8, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@yeikel
Copy link
Contributor

yeikel commented Apr 8, 2022

I am running mvn rewrite:run from the root directory of a multi module project. Doing so produces a log such as

[WARNING] Changes have been made to module/src/main/java/Java.java by:
[WARNING] org.openrewrite.java.logging.ParameterizedLogging

The problem is that when there are multiple modules, the logs are printed after the build of each module finishes

As my build prints many logs, it is very difficult and tedious to navigate the logs per module to find the recipes applied

It would be better if we could aggregate this and print it at the end of the build

An ideal output would look like this :

[WARNING] Changes have been made to module1/path by
[WARNING]     org.openrewrite.java.logging.ParameterizedLogging
[WARNING] Changes have been made to module2/path by
[WARNING]     org.openrewrite.java.cleanup.MinimumSwitchCases
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for multimodule 0.0.0-SNAPSHOT:
[INFO] 
[INFO] module1 ........................................... SUCCESS [ 16.625 s]
[INFO] module2 .......................................... SUCCESS [ 20.884 s]
[INFO] module3 .............................. SUCCESS [ 34.173 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:32 min (Wall Clock)
[INFO] Finished at: 2022-04-08T12:54:51-04:00
@tkvangorder tkvangorder added the enhancement New feature or request label Apr 8, 2022
@tkvangorder tkvangorder moved this to Ice Box in OpenRewrite Apr 8, 2022
@tkvangorder
Copy link
Contributor

This seems reasonable, we might be able to achieve this with a shutdown hook.

@tkvangorder tkvangorder moved this from Request for help to Future in OpenRewrite Apr 18, 2022
@tkvangorder tkvangorder moved this from Recipes Wanted to Backlog in OpenRewrite Apr 19, 2022
@tkvangorder
Copy link
Contributor

@yeikel This has been addressed in #349 .

We defer the running of the plugin, until the last project, parse source files from each module (in reactor order) and then run the recipe across all source files. The patch file is always generated in the root project.

Repository owner moved this from Backlog to Done in OpenRewrite May 11, 2022
@murdos
Copy link
Contributor

murdos commented May 11, 2022

Hi. I'm currently using the snapshot version of the maven plugin, and I'm not really found of this new behavior.
It doesn't really fit the maven way of doing things IMO.
For example there's no ending test report on a multi-module project for surefire and failsafe plugin, you'll check the log of each module.
And if I want to check only changes made to a module, I don't have a way to see only the report for this module.
It also doesn't really work well in IntelliJ which only shows log of a module when you select it: whereas I launched rewrite:run on the root of the project, selection a submodule will only show resources and compilation logs, but trace of rewrite.

@tkvangorder
Copy link
Contributor

@murdos I have added a configuration flag that will allow you to run on a per-module basis:

See #360

Note the new configuration flag runPerSubmodule :

			<plugin>
				<groupId>org.openrewrite.maven</groupId>
				<artifactId>rewrite-maven-plugin</artifactId>
				<version>4.24.0-SNAPSHOT</version>
				<configuration>
					<runPerSubmodule>true</runPerSubmodule>
					<activeRecipes>
					    <recipe>org.openrewrite.java.cleanup.AddSerialVersionUidToSerializable</recipe>
					</activeRecipes>
				</configuration>
			</plugin>

The default for this flag is false, so you will need to explicitly set this flag to revert to the previous behavior.

Thanks for the feedback!

@murdos
Copy link
Contributor

murdos commented May 11, 2022

@tkvangorder : thanks for taking my input in consideration!
I was reading other issues like #349 that led to #359 and I should admit that I don't the issue with #349 event when reading #349 (comment)

Now there's currently a big pitfall with running only once per multi-module project: you don't take into account that each module may have configured the maven plugin differently, including using specific recipes.
To demonstrate and check that I've configured this multi-module project: murdos/piggymetrics@38812ec
org.openrewrite.java.format.AutoFormat is only configured in submodule turbine-stream-service, however it's applied in the whole project:

[WARNING] Changes have been made to statistics-service/src/test/java/com/piggymetrics/statistics/client/ExchangeRatesClientTest.java by:
[WARNING] org.openrewrite.java.format.AutoFormat
[WARNING] Changes have been made to notification-service/src/main/java/com/piggymetrics/notification/repository/converter/FrequencyWriterConverter.java by:
[WARNING] org.openrewrite.java.format.AutoFormat

@tkvangorder
Copy link
Contributor

Yes, I totally understand. This issue was a request from one of our design partners. The model of applying the recipe at the top level of the project and then operating on sources across all submodules is closer to parity with what is done in the Gradle plugin and how recipes are executed on the SaaS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants