Use Guava Ranges

io.github.timoa.misc.UseRangesRecipes


Simplifies hand crafted range checks.


Recipe Source

  • groupId: io.github.timo-a

  • artifactId: rewrite-recipe-starter

  • version: 0.4.2

Usage

  • Maven POM

  • Maven Command Line

  • Gradle

  • Gradle init script

  1. Add the following to your pom.xml file:

    pom.xml
    <project>
      <build>
        <plugins>
          <plugin>
            <groupId>org.openrewrite.maven</groupId>
            <artifactId>rewrite-maven-plugin</artifactId>
            <version>5.42.2</version>
            <configuration>
              <activeRecipes>
                <recipe>io.github.timoa.misc.UseRangesRecipes</recipe>
              </activeRecipes>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>io.github.timo-a</groupId>
                <artifactId>rewrite-recipe-starter</artifactId>
                <version>0.4.2</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </project>
  2. Run mvn rewrite:run to run the recipe.

You will need to have Maven installed on your machine before you can run the following command.

Shell
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=io.github.timo-a:rewrite-recipe-starter:RELEASE -Drewrite.activeRecipes=io.github.timoa.misc.UseRangesRecipes
  1. Add the following to your build.gradle file:

    build.gradle
    plugins {
        id("org.openrewrite.rewrite") version("6.25.1")
    }
    
    rewrite {
        activeRecipe("io.github.timoa.misc.UseRangesRecipes")
    }
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        rewrite("io.github.timo-a:rewrite-recipe-starter:0.4.2")
    }
  2. Run gradle rewriteRun to run the recipe.

  1. Create a file named init.gradle in the root of your project.

    init.gradle
    initscript {
        repositories {
            maven { url "https://plugins.gradle.org/m2" }
        }
        dependencies { classpath("org.openrewrite:plugin:6.25.1") }
    }
    rootProject {
        plugins.apply(org.openrewrite.gradle.RewritePlugin)
        dependencies {
            rewrite("io.github.timo-a:rewrite-recipe-starter:0.4.2")
        }
        rewrite {
            activeRecipe("io.github.timoa.misc.UseRangesRecipes")
        }
        afterEvaluate {
            if (repositories.isEmpty()) {
                repositories {
                    mavenCentral()
                }
            }
        }
    }
  2. Run gradle --init-script init.gradle rewriteRun to run the recipe.