openrewrite / rewrite-gradle-plugin

OpenRewrite's Gradle plugin.
Apache License 2.0
65 stars 41 forks source link
openrewrite

Logo

Eliminate Tech-Debt. At build time.

ci Gradle Plugin Portal Apache 2.0 Revved up by Develocity Contributing Guide

What is this?

This project provides a Gradle plugin that applies Rewrite checking and fixing tasks as build tasks, one of several possible workflows for propagating change across an organization's source code.

plugins {
    id("java")
    id("org.openrewrite.rewrite").version("latest_version_here")
}

rewrite {
    // Reformats Java Code
    activeRecipe("org.openrewrite.java.format.AutoFormat")
}

Consuming latest snapshots from OSSRH

To use the latest -SNAPSHOT of the rewrite-gradle-plugin, update your project's settings.gradle.kts:

pluginManagement {
    resolutionStrategy {
        eachPlugin {
            if (requested.id.namespace == "org.openrewrite") {
                useModule("org.openrewrite:plugin:${requested.version}")
            }
        }
    }

    repositories {
        // ...
        maven {
            url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
        }
        // ...
        // you'll likely also need this if you don't have a pluginManagement section already:
        gradlePluginPortal()
        // ...
    }
}

The plugin can be consumed in your build.gradle.kts:

plugins {
    id("org.openrewrite.rewrite") version "X.Y.Z-SNAPSHOT"
    // or resolved dynamically to absolute latest:
    id("org.openrewrite.rewrite") version "latest.integration"
}

Contributing

We appreciate all types of contributions. See the contributing guide for detailed instructions on how to get started.

Documentation