spring-projects-experimental / spring-boot-migrator

Spring Boot Migrator (SBM) is a tool for automated code migrations to upgrade or migrate to Spring Boot
Apache License 2.0
447 stars 88 forks source link

Remove standard maven-compiler plugin for applications with boot parent #428

Open fabapp2 opened 2 years ago

fabapp2 commented 2 years ago

What needs to be done

Provide a recipe remove-redundant-maven-compiler-plugin that removes redundant maven-compiler-plugin configurations in Spring Boot applications that have a spring-boot parent where the compiler-plugin is managed.

Why it needs to be done

Cleaner pom.xml by using Spring Boot's plugin management

Acceptance Criteria

Given: A pom.xml with direct or indirect spring-boot-starter-parent and a standard maven-compiler-plugin configuration with only source and target When: remove-redundant-maven-compiler-plugin is applied Then: The maven-compiler-plugin is removed and Properties defining the java version are replaced with java.version property used by boot.

Additional Information

ahmedmq commented 2 years ago

@fabapp2 - would like to try creating a new recipe. Maybe I can pick this one to get started?

fabapp2 commented 2 years ago

Great, thanks! 🚀 Happily assigned-to: @ahmedmq

fabapp2 commented 2 years ago

The description is rather minimal, don't hesitate to pull all information you need.

ahmedmq commented 2 years ago

Hey @fabapp2 : Just wanted to share my understanding of the changes required . Could you let me know of anything i have missed

Recipe: Create new recipe using YML configuration possibly under sbm-support-boot module

Conditions:

Action:

Also, I was not sure about replacing the Java properties and what is to be done. Spring boot parent already defines these properties:

  <java.version>1.8</java.version>
  <maven.compiler.source>${java.version}</maven.compiler.source>
  <maven.compiler.target>${java.version}</maven.compiler.target>
fabapp2 commented 2 years ago

Hi @ahmedmq, thanks for your analysis!

Your observations are all correct for my understanding.

I can see the recipe doing two things:

. Always clean up properties . When no additional configuration is provided, remove the plugin

Clean up properties

Otherwise

gh428

PlatUML code: gh428.puml.txt

Removing the plugin

It's probably a good idea to have two Actions, one cleaning up the properties and one actually removing the plugin. This would allow us to use them separately (in two recipes) when needed.

Your thoughts on this?

ahmedmq commented 2 years ago

I think i get it. Let me start and I will reach out if I get stuck