Skip to content
This repository was archived by the owner on Apr 4, 2022. It is now read-only.

Gradle plugin that automatically discovers Rewrite refactoring rules and applies them to your codebase.

License

Notifications You must be signed in to change notification settings

spring-attic/rewrite-gradle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

rewrite-gradle is no longer actively maintained by VMware, Inc.

Rewrite plugin

Build Status Gitter Apache 2.0

A Gradle plugin that discovers and applies Rewrite refactoring rules to your codebase.

Requirements

  • Gradle 2.x (2.9 or later) or Gradle 3.x. Gradle 2.8 and earlier are not supported.
  • Java 8 or later

Using the plugin

To apply the plugin, see the instructions on the Gradle plugin portal.

The Rewrite plugin scans each source set's classpath for methods marked with @AutoRewrite and applies their contents to the source set.

To generate a report of what should be refactored in your project based on the @AutoRewrite methods found, run:

./gradlew lintSource

To automatically fix your code (preserving all of your beautiful code style), run:

./gradlew fixSourceLint && git diff

It is up to you to check the diff, run tests, and commit the resultant changes!

Creating an @AutoRewrite rule

@AutoRewrite must be placed on a public static method that takes a single Refactor argument. The method may return anything you wish or nothing at all.

Below is an example of a rule:

@AutoRewrite(value = "reactor-mono-flatmap", description = "change flatMap to flatMapMany")
public static void migrateMonoFlatMap(Refactor refactor) {
  // a compilation unit representing the source file we are refactoring
  Tr.CompilationUnit cu = refactor.getOriginal();

  refactor.changeMethodName(cu.findMethodCalls("reactor.core.publisher.Mono flatMap(..)"),
    "flatMapMany");
}

About

Gradle plugin that automatically discovers Rewrite refactoring rules and applies them to your codebase.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •