question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove standard maven-compiler plugin for applications with boot parent

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ahmedmqcommented, Oct 12, 2022

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

0reactions
fabapp2commented, Oct 11, 2022

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

  • When target and source version differ, do nothing

Otherwise

  • maven.compiler.source and maven.compiler.target should be retrieved from parent
  • The version should be set using java.version
  • Custom property for version in maven-compiler-plugin should be replaced with maven.compiler.*
    • All other usages of the custom property should to be replaced with java.version
  • Fixed values for target and version should be replaced with maven.compiler.* properties set through java.version

gh428

PlatUML code: gh428.puml.txt

Removing the plugin

  • After cleaning up the properties
  • When the plugin has no additional configuration, remove it

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Disable a Maven Plugin Defined in a Parent POM
First, let's assume that restructuring the Maven project or changing the parent POM aren't acceptable solutions. If we could amend the parent ......
Read more >
Apache Maven Compiler Plugin
org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile. Description: ... Binds by default to the lifecycle phase: compile.
Read more >
Spring Boot Maven Plugin Documentation
The parent project provides the following features: Java 1.8 as the default compiler level. UTF-8 source encoding. Compilation with -parameters ...
Read more >
which dependencies to delete from Eclipse for maven project ...
I used the most recent version of Spring Boot 2.7.4 if you need something lower change the parent (and only change that nothing...
Read more >
Migrating a Spring Boot application to Java 17 – the hard way
3[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project app-project: Fatal ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found