Skip to content

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

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

Merged
merged 16 commits into from
Dec 15, 2022

Conversation

ahmedmq
Copy link
Contributor

@ahmedmq ahmedmq commented Oct 27, 2022

Changes for #428

  • Two Actions (RemoveRedundantMavenCompilerPluginProperties, RemoveRedundantMavenCompilerPlugin)
  • New Recipe (remove-redundant-maven-compiler-plugin.yaml) and condition (SpringBootMavenCompilerExists)

@ahmedmq ahmedmq changed the title Remove standard maven-compiler plugin for applications with boot parent - #428 Remove standard maven-compiler plugin for applications with boot parent - gh-428 Oct 27, 2022
@fabapp2 fabapp2 added this to the v0.13.0 milestone Nov 3, 2022
@fabapp2 fabapp2 added the openrewrite Marks issues that might contain code worth contributing to OpenRewrite label Nov 7, 2022
Copy link
Contributor

@fabapp2 fabapp2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ahmedmq
I didn't make it through (5/23) but will proceed asap.
I think by moving more logic into Plugin and Plugin#Configuration some parts will get shorter and more cohesive 🤞

Thanks for your work! 🚀

@fabapp2 fabapp2 modified the milestones: v0.13.0, v0.14.0 Nov 22, 2022
@ahmedmq
Copy link
Contributor Author

ahmedmq commented Dec 6, 2022

@fabapp2 - Do you want to have a look at the changes done?

Mushtaq Ahmed added 14 commits December 14, 2022 15:37
- Fix typo
- Generate maven properties
- Change type to packaging
- Add test
- Rename `Plugin.java` as `OpenRewriteMavenPlugin.java`
- Extract interface from OpenRewriteMavenPlugin into `Plugin.java` - - An API interface for a potential gradle implementation in the future
- Create new interface `Plugin#Configuration` and implementation - `OpenRewriteMavenPluginConfiguration`- Does not implement all methods in this commit
- Refactor `Plugin#Execution` into `OpenRewriteMavenPlugin#OpenRewriteMavenPluginExecution`

These changes are similar to the JavaSource rewrite approach.
setProperty() API no longer removes the maven property if the value supplied is null.
- Use Jackson XML pretty print to generate XML string for plugin configuration
- Use Plugin interface instead of OpenRewriteMavenPlugin implementation in dealing with objects
- Clean up BuildFile API
- Use Java Refactoring to apply recipes via the plugin API
- Disable multi-module tests as this needs core changes to POM file updates
Copy link
Contributor

@fabapp2 fabapp2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ahmedmq for your heroic effort with this contribution! 🚀

import org.springframework.sbm.engine.context.ProjectContext;
import org.springframework.sbm.engine.recipe.Condition;

public class SpringBootMavenCompilerExists implements Condition {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename: SpringBootMavenCompilerpLuginExists

@Override
public boolean evaluate(ProjectContext context) {

FileMatchingPatternExist fileMatchingPatternExist = new FileMatchingPatternExist();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about:

return context.getModules().stream()
   .map(Module::getBuildFile())
   .flatMap(b -> b.getPlugins().stream())
   .anyMatch(p -> "maven-compiler-plugin".equals(p.getArtfactId()));

private static Stream<Arguments> input() {
return Stream.of(
Arguments.of(
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

@Test
void removeRedundantMavenCompilerPlugin() {
String applicationDir = "simple-boot";
RecipeIntegrationTestSupport.initializeProject(applicationDir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

@fabapp2 fabapp2 merged commit 270ad9b into spring-projects-experimental:main Dec 15, 2022
fabapp2 pushed a commit that referenced this pull request Jan 31, 2023
…nt - gh-428 (#508)

- Add New recipe and condition
- Enhance PomBuilder.java
- Use MavenBuildFileRefactoring to apply recipe, similar to JavaRefactoring
- Refactor getPlugins() method in OpenRewriteMavenBuildFile
- Extract Plugin interface and refactor Maven Plugin implementation
- Create new interface `Plugin#Configuration` and implementation
- Refactor `Plugin#Execution` into `OpenRewriteMavenPlugin#OpenRewriteMavenPluginExecution`
- Add deleteProperty() API to BuildFile
- setProperty() API no longer removes the maven property if the value supplied is null.
- Add maven plugin configuration to PomBuilder
- Use Jackson XML pretty print to generate XML string for plugin configuration
- Add findPlugins API to BuildFile
- Use Plugin interface instead of OpenRewriteMavenPlugin implementation in dealing with objects
- Refactor Maven compiler plugin actions
- Clean up BuildFile API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openrewrite Marks issues that might contain code worth contributing to OpenRewrite Recipe type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants