Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wetneb/openrefine-refactoring-recipes

Attempt to use OpenRewrite recipes to help with some refactorings in OpenRefine
https://github.com/wetneb/openrefine-refactoring-recipes

Last synced: 29 days ago
JSON representation

Attempt to use OpenRewrite recipes to help with some refactorings in OpenRefine

Awesome Lists containing this project

README

        

## Rewrite recipe starter

This repository serves as a template for building your own recipe JARs and publishing them to a repository where they can be applied on [public.moderne.io](https://public.moderne.io) against all of the public OSS code that is included there.

We've provided a sample recipe (NoGuavaListsNewArray) and a sample test class. Both of these exist as placeholders, and they should be replaced by whatever recipe you are interested in writing.

To begin, fork this repository and customize it by:

1. Changing the root project name in `settings.gradle.kts`.
2. Changing the `group` in `build.gradle.kts`.
3. Changing the package structure from `com.yourorg` to whatever you want.

## Detailed Guide

There is a [comprehensive getting started guide](https://docs.openrewrite.org/getting-started/recipe-development-environment)
available in the OpenRewrite docs that provides more details than the below README.

## Local Publishing for Testing

Before you publish your recipe module to an artifact repository, you may want to try it out locally.
To do this on the command line, run `./gradlew publishToMavenLocal` (or equivalently `./gradlew pTML`).
This will publish to your local maven repository, typically under `~/.m2/repository`.

Replace the groupId, artifactId, recipe name, and version in the below snippets with the ones that correspond to your recipe.

In a Maven project's pom.xml, make your recipe module a plugin dependency:
```xml




org.openrewrite.maven
rewrite-maven-plugin
4.38.0


com.yourorg.NoGuavaListsNewArrayList




com.yourorg
rewrite-recipe-starter
0.1.0-SNAPSHOT




```

Unlike Maven, Gradle must be explicitly configured to resolve dependencies from maven local.
The root project of your gradle build, make your recipe module a dependency of the `rewrite` configuration:

```groovy
plugins {
id("java")
id("org.openrewrite.rewrite") version("5.33.0")
}

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
rewrite("com.yourorg:rewrite-recipe-starter:0.1.0-SNAPSHOT")
}

rewrite {
activeRecipe("com.yourorg.NoGuavaListsNewArrayList")
}
```

Now you can run `mvn rewrite:run` or `gradlew rewriteRun` to run your recipe.

## Publishing to Artifact Repositories

This project is configured to publish to Moderne's open artifact repository (via the `publishing` task at the bottom of
the `build.gradle.kts` file). If you want to publish elsewhere, you'll want to update that task.
[public.moderne.io](https://public.moderne.io) can draw recipes from the provided repository, as well as from [Maven Central](https://search.maven.org).

Note:
Running the publish task _will not_ update [public.moderne.io](https://public.moderne.io), as only Moderne employees can
add new recipes. If you want to add your recipe to [public.moderne.io](https://public.moderne.io), please ask the
team in [Slack](https://join.slack.com/t/rewriteoss/shared_invite/zt-nj42n3ea-b~62rIHzb3Vo0E1APKCXEA) or in [Discord](https://discord.gg/xk3ZKrhWAb).

These other docs might also be useful for you depending on where you want to publish the recipe:

* Sonatype's instructions for [publishing to Maven Central](https://maven.apache.org/repository/guide-central-repository-upload.html)
* Gradle's instructions on the [Gradle Publishing Plugin](https://docs.gradle.org/current/userguide/publishing\_maven.html).

### From Github Actions

The `.github` directory contains a Github action that will push a snapshot on every successful build.

Run the release action to publish a release version of a recipe.

### From the command line

To build a snapshot, run `./gradlew snapshot publish` to build a snapshot and publish it to Moderne's open artifact repository for inclusion at [public.moderne.io](https://public.moderne.io).

To build a release, run `./gradlew final publish` to tag a release and publish it to Moderne's open artifact repository for inclusion at [public.moderne.io](https://public.moderne.io).