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

Latest commit

 

History

History
48 lines (30 loc) · 2.02 KB

README.md

File metadata and controls

48 lines (30 loc) · 2.02 KB

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");
}