Skip to content

Commit

Permalink
Revert "GITBOOK-508: change request with no subject merged in GitBook"
Browse files Browse the repository at this point in the history
This reverts commit 4ed05bd.
  • Loading branch information
mike-solomon committed Nov 20, 2023
1 parent 4ed05bd commit 92f1470
Show file tree
Hide file tree
Showing 16 changed files with 539 additions and 639 deletions.
Binary file not shown.
Binary file removed .gitbook/assets/image (1).png
Binary file not shown.
Binary file removed .gitbook/assets/image.png
Binary file not shown.
162 changes: 81 additions & 81 deletions SUMMARY.md

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions authoring-recipes/recipe-development-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ description: Prerequisites, tools, and recommendations for developing with OpenR

This getting started guide covers setting up your development environment for creating your own OpenRewrite recipes.

{% hint style="info" %}
If you are looking to build [OpenRewrite](https://github.com/openrewrite/rewrite) itself instead of a specific recipe, check out our [building and developing OpenRewrite guide](../reference/building-openrewrite-from-source.md). 
{% endhint %}

## Prerequisites

* [JDK](https://adoptopenjdk.net) (version 1.8+)
Expand Down Expand Up @@ -249,7 +245,7 @@ Having configured the project per these recommendations, you're now able to begi

* `src/main/java` - Recipe implementations
* `src/test/java` - Recipe tests
* (optional) `src/main/resources/META-INF/rewrite` - YAML files for defining [declarative OpenRewrite Recipes](../reference/yaml-format-reference.md)
* (optional) `src/main/resources/META-INF/rewrite` - YAML files for defining [declarative OpenRewrite Recipes](/reference/yaml-format-reference.md)

With all of that done, your project setup is complete! You are now ready to [create a Recipe](writing-a-java-refactoring-recipe.md).

Expand Down Expand Up @@ -370,7 +366,7 @@ Now you can run your recipe with `mvn rewrite:run` or `mvn rewrite:dryRun`

## Next steps

* [Learn about the different types of recipes you can create](types-of-recipes.md)
* [Learn about the different types of recipes you can create](/authoring-recipes/types-of-recipes.md)
* [Write a Java refactoring recipe](writing-a-java-refactoring-recipe.md)
* [Maven plugin configuration](../reference/rewrite-maven-plugin.md)
* [Gradle plugin configuration](../reference/gradle-plugin-configuration.md)
* [Maven plugin configuration](/reference/rewrite-maven-plugin.md)
* [Gradle plugin configuration](/reference/gradle-plugin-configuration.md)
789 changes: 394 additions & 395 deletions changelog/8-1-2-Release.md

Large diffs are not rendered by default.

73 changes: 5 additions & 68 deletions reference/building-openrewrite-from-source.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
# Building and developing OpenRewrite

## Building OpenRewrite
# Building OpenRewrite from source

OpenRewrite is built with [Gradle](https://gradle.org/). It is not typically necessary to manually install Gradle, as invoking the `./gradlew` (Linux and Mac) or `gradlew.bat` (Windows) shell scripts will download the appropriate version of Gradle to your user directory.

OpenRewrite requires several JDK versions to be installed on your system. If you are able to access [Adoptium](https://adoptium.net/), then Gradle will automatically download and install any needed JDKs which you may be missing. If your network configuration or security policies do not permit this, then you must manually install JDK versions 8, 11, and 17.

{% hint style="danger" %}
If you are developing on a Mac M1 or M2 you must install the Java 1.8 JDK manually (for example using [SDKMAN!](https://sdkman.io/)), as there is no matching JDK available on Adoptium.
{% endhint %}

To compile and run tests, invoke `./gradlew build`. To publish a snapshot build to your maven local repository, run `./gradlew publishToMavenLocal`.

{% hint style="info" %}
If some of your tests fail with a message like:

```
java.lang.IllegalArgumentException: Invalid value: gpg.format=ssh
```
> **Note** If you are developing on a Mac M1 or M2 you must install the Java 1.8 JDK manually (for example using [SDKMAN!](https://sdkman.io/)), as there is no matching JDK available on Adoptium.
Please try running the following command in the `rewrite` directory to disable GPG signing for your commits:

```bash
git config commit.gpgsign false
```
To compile and run tests invoke `./gradlew build`. To publish a snapshot build to your maven local repository, run `./gradlew publishToMavenLocal`.

After this succeeds, please re-run the build. You should not longer see the error. This error is due to the fact that there are some tests that use the [JGit](https://projects.eclipse.org/projects/technology.jgit) library to run git commands, which at the time of writing does not support SSH-based signed commits. See [this bug](https://bugs.eclipse.org/bugs/show\_bug.cgi?id=581483) for more information.
{% endhint %}
> **Note** If some of your tests fail with a message like `java.lang.IllegalArgumentException: Invalid value: gpg.format=ssh`, try running `git config commit.gpgsign false` in the `rewrite` directory to disable GPG signing for your commits then re-run the build. This is because there are some tests that use the [JGit](https://projects.eclipse.org/projects/technology.jgit) library to run git commands, which at the time of writing does not support SSH-based signed commits. See [this bug](https://bugs.eclipse.org/bugs/show_bug.cgi?id=581483) for more information.
## Building within Secure/Isolated environments
### Building within Secure/Isolated environments

OpenRewrite typically accesses the Maven Central artifact repository to download necessary dependencies. If organizational security policy or network configuration forbids this, then you can use a Gradle [init script](https://docs.gradle.org/current/userguide/init\_scripts.html) to forcibly reconfigure the OpenRewrite build to use a different repository.

Expand Down Expand Up @@ -112,48 +94,3 @@ allprojects {

With this file placed, all of your Gradle builds will prefer to use your corporate repository instead of whatever repositories they would normally be configured with.

## Developing tips

We recommend that you use [IntelliJ IDEA](https://www.jetbrains.com/idea/) for development, as some of the Gradle specifics in `openrewrite/rewrite` are not supported as well in other IDEs. We also require all code contributions to be formatted using the IntelliJ IDEA auto-formatter. 

### IntelliJ IDEA changes

By default, IntelliJ IDEA uses Gradle to build and run tests with. While that ensures compatibility, it is very slow. To help speed up compilation and testing, we recommend that you change this to use `IntelliJ IDEA` instead. You can update this by going to the IntelliJ settings, searching for Gradle, and clicking on the `Build, Execution, Deployment` -> `Build Tools` -> `Gradle` setting:

<figure><img src="https://github.com/openrewrite/.github/raw/main/resources/gradle-select.png" alt=""><figcaption></figcaption></figure>

As part of doing that, you'll also need to update the `Java Compiler` to set the `-parameters` compiler flag. If your system does not have `UTF-8` as its default character encoding (e.g., Windows), you must also add `-encoding utf8`.

<figure><img src="https://github.com/openrewrite/.github/raw/main/resources/parameters.png" alt=""><figcaption></figcaption></figure>

You will also need to add an override to the compiler parameters for the `rewrite.rewrite-java-17.main` module to have the compilation options of:

```bash
-parameters --add-exports jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
```

<figure><img src="https://github.com/openrewrite/.github/raw/main/resources/compilation-options.png" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
If you've previously run tests using Gradle and you update the project to use IntelliJ instead, it's a good idea to make sure that your tests are actually using IntelliJ rather than Gradle. You can confirm the tests are not using Gradle by clicking on the run configurations in the top right hand corner of IntelliJ and ensuring that the tests have a left and right arrow next to them instead of the Gradle icon:

&#x20; Correct: ![](<../.gitbook/assets/Screen Shot 2023-11-20 at 9.32.54 AM.png>) Incorrect: ![](<../.gitbook/assets/image (1).png>)
{% endhint %}

### Optimizing your IDE for only modules you want to work on

If you are only working on a subset of the modules in [openrewrite/rewrite](https://github.com/openrewrite/rewrite), you can optimize your IDE to only load those modules. To do so, create a new `IDE.properties` file if one doesn't exist in the base directory of the project. Then, copy the contents of [IDE.properties.tmp](https://github.com/openrewrite/rewrite/blob/main/IDE.properties.tmp) file to it. Next, comment out any lines that correspond to modules that you do not want to work on. This will cause Gradle to swap those project dependencies for binary dependencies resolved from either Maven local or the OSS snapshots repository – which will speed up your IDE.

### Windows Caveats

If you are contributing to OpenRewrite on Windows, please ensure that you set `core.autocrlf = false` as [Rewrite](https://github.com/openrewrite/rewrite) requires unix-style line endings. This can be done when you clone the repository:

```bash
git clone -c core.autocrlf=false https://github.com/openrewrite/rewrite.git
```

Also, as mentioned in the [IntelliJ IDEA section](building-openrewrite-from-source.md#intellij-idea-changes) above, please ensure that your system uses `UTF-8` for character encoding.

\


4 changes: 3 additions & 1 deletion reference/recipes/analysis/controlflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

## Recipes

* [Control Flow Visualization](broken-reference)
* [Control Flow Visualization](./controlflowvisualization.md)


4 changes: 3 additions & 1 deletion reference/recipes/gradle/security/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

## Recipes

* [Use HTTPS for repositories](../../maven/security/usehttpsforrepositories.md)
* [Use HTTPS for repositories](./usehttpsforrepositories.md)


26 changes: 10 additions & 16 deletions reference/recipes/java/migrate/javax/addjaxbruntime.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**org.openrewrite.java.migrate.javax.AddJaxbRuntime**

_Update build files to use the latest JAXB runtime from Jakarta EE 8 to maintain compatibility with Java version 11 or greater. The recipe will add a JAXB run-time, in Gradle `compileOnly`+`testImplementation` and Maven `provided` scope, to any project that has a transitive dependency on the JAXB API. **The resulting dependencies still use the**** ****`javax`**** ****namespace, despite the move to the Jakarta artifact**._
_Update build files to use the latest JAXB runtime from Jakarta EE 8 to maintain compatibility with Java version 11 or greater. The recipe will add a JAXB run-time, in Gradle `compileOnly`+`testImplementation` and Maven `provided` scope, to any project that has a transitive dependency on the JAXB API. **The resulting dependencies still use the `javax` namespace, despite the move to the Jakarta artifact**._

### Tags

Expand All @@ -24,16 +24,17 @@ _Update build files to use the latest JAXB runtime from Jakarta EE 8 to maintain
{% hint style="info" %}
This recipe is composed of more than one recipe. If you want to customize the set of recipes this is composed of, you can find and copy the GitHub source for the recipe from the link above.
{% endhint %}

## Options

| Type | Name | Description |
| -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Type | Name | Description |
| -- | -- | -- |
| `String` | runtime | Which implementation of the JAXB run-time that will be added to maven projects that have transitive dependencies on the JAXB API |


## Usage

This recipe has required configuration parameters. Recipes with required configuration parameters cannot be activated directly. To activate this recipe you must create a new recipe which fills in the required parameters. In your `rewrite.yml` create a new recipe with a unique name. For example: `com.yourorg.AddJaxbRuntimeExample`. Here's how you can define and customize such a recipe within your rewrite.yml:
This recipe has required configuration parameters. Recipes with required configuration parameters cannot be activated directly. To activate this recipe you must create a new recipe which fills in the required parameters. In your `rewrite.yml` create a new recipe with a unique name. For example: `com.yourorg.AddJaxbRuntimeExample`.
Here's how you can define and customize such a recipe within your rewrite.yml:

{% code title="rewrite.yml" %}
```yaml
Expand All @@ -48,11 +49,9 @@ recipeList:
{% endcode %}
Now that `com.yourorg.AddJaxbRuntimeExample` has been defined activate it and take a dependency on org.openrewrite.recipe:rewrite-migrate-java:2.3.0 in your build file:

{% tabs %}
{% tab title="Gradle" %}
1. Add the following to your `build.gradle` file:

{% code title="build.gradle" %}
```groovy
plugins {
Expand All @@ -72,13 +71,10 @@ dependencies {
}
```
{% endcode %}

2. Run `gradle rewriteRun` to run the recipe.
{% endtab %}

{% tab title="Maven" %}
1. Add the following to your `pom.xml` file:

{% code title="pom.xml" %}
```xml
<project>
Expand Down Expand Up @@ -106,10 +102,8 @@ dependencies {
</project>
```
{% endcode %}

2. Run `mvn rewrite:run` to run the recipe.
{% endtab %}

{% tab title="Moderne CLI" %}
You will need to have configured the [Moderne CLI](https://docs.moderne.io/moderne-cli/cli-intro) on your machine before you can run the following command.

Expand All @@ -125,8 +119,9 @@ mod run . --recipe AddJaxbRuntime

{% tabs %}
{% tab title="Recipe List" %}
* [Use latest JAXB API and runtime for Jakarta EE 8](addjaxbruntime$addjaxbruntimegradle.md)
* [Use latest JAXB API and runtime for Jakarta EE 8](addjaxbruntime$addjaxbruntimemaven.md)
* [Use latest JAXB API and runtime for Jakarta EE 8](../../../java/migrate/javax/addjaxbruntime$addjaxbruntimegradle.md)
* [Use latest JAXB API and runtime for Jakarta EE 8](../../../java/migrate/javax/addjaxbruntime$addjaxbruntimemaven.md)

{% endtab %}

{% tab title="Yaml Recipe List" %}
Expand Down Expand Up @@ -154,12 +149,11 @@ recipeList:

## See how this recipe works across multiple open-source repositories

[![Moderne Link Image](../../../../../.gitbook/assets/ModerneRecipeButton.png)](https://app.moderne.io/recipes/org.openrewrite.java.migrate.javax.AddJaxbRuntime)
[![Moderne Link Image](/.gitbook/assets/ModerneRecipeButton.png)](https://app.moderne.io/recipes/org.openrewrite.java.migrate.javax.AddJaxbRuntime)

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please [contact Moderne](https://moderne.io/product) for more information about safely running the recipes on your own codebase in a private SaaS.

## Contributors

[Shannon Pamperl](mailto:[email protected]), Tyler Van Gorder, [Jonathan Schneider](mailto:[email protected]), [Sam Snyder](mailto:[email protected]), [Simon Verhoeven](mailto:[email protected])
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**org.openrewrite.java.migrate.javax.AddJaxwsRuntime$AddJaxwsRuntimeGradle**

_Update Gradle build files to use the latest JAX-WS runtime from Jakarta EE 8 to maintain compatibility with Java version 11 or greater. The recipe will add a JAX-WS run-time, in `compileOnly`+`testImplementation` configurations, to any project that has a transitive dependency on the JAX-WS API. **The resulting dependencies still use the**** ****`javax`**** ****namespace, despite the move to the Jakarta artifact**._
_Update Gradle build files to use the latest JAX-WS runtime from Jakarta EE 8 to maintain compatibility with Java version 11 or greater. The recipe will add a JAX-WS run-time, in `compileOnly`+`testImplementation` configurations, to any project that has a transitive dependency on the JAX-WS API. **The resulting dependencies still use the `javax` namespace, despite the move to the Jakarta artifact**._

## Recipe source

Expand All @@ -12,14 +12,13 @@ _Update Gradle build files to use the latest JAX-WS runtime from Jakarta EE 8 to
* artifactId: rewrite-migrate-java
* version: 2.3.0

## Usage

This recipe has no required configuration options. It can be activated by adding a dependency on `org.openrewrite.recipe:rewrite-migrate-java:2.3.0` in your build file or by running a shell command (in which case no build changes are needed):
## Usage

This recipe has no required configuration options. It can be activated by adding a dependency on `org.openrewrite.recipe:rewrite-migrate-java:2.3.0` in your build file or by running a shell command (in which case no build changes are needed):
{% tabs %}
{% tab title="Gradle" %}
1. Add the following to your `build.gradle` file:

{% code title="build.gradle" %}
```groovy
plugins {
Expand All @@ -39,13 +38,11 @@ dependencies {
}
```
{% endcode %}

2. Run `gradle rewriteRun` to run the recipe.
{% endtab %}

{% tab title="Gradle init script" %}
1. Create a file named `init.gradle` in the root of your project.

{% code title="init.gradle" %}
```groovy
initscript {
Expand All @@ -72,13 +69,10 @@ rootProject {
}
```
{% endcode %}

2. Run `gradle --init-script init.gradle rewriteRun` to run the recipe.
{% endtab %}

{% tab title="Maven POM" %}
1. Add the following to your `pom.xml` file:

{% code title="pom.xml" %}
```xml
<project>
Expand Down Expand Up @@ -106,20 +100,20 @@ rootProject {
</project>
```
{% endcode %}

2. Run `mvn rewrite:run` to run the recipe.
{% endtab %}

{% tab title="Maven Command Line" %}
{% code title="shell" %}
You will need to have [Maven](https://maven.apache.org/download.cgi) installed on your machine before you can run the following command.

```shell
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE \
-Drewrite.activeRecipes=org.openrewrite.java.migrate.javax.AddJaxwsRuntime$AddJaxwsRuntimeGradle
```
{% endcode %}
{% endtab %}

{% tab title="Moderne CLI" %}
You will need to have configured the [Moderne CLI](https://docs.moderne.io/moderne-cli/cli-intro) on your machine before you can run the following command.

Expand All @@ -133,7 +127,7 @@ mod run . --recipe AddJaxwsRuntime$AddJaxwsRuntimeGradle

## See how this recipe works across multiple open-source repositories

[![Moderne Link Image](../../../../../.gitbook/assets/ModerneRecipeButton.png)](https://app.moderne.io/recipes/org.openrewrite.java.migrate.javax.AddJaxwsRuntime$AddJaxwsRuntimeGradle)
[![Moderne Link Image](/.gitbook/assets/ModerneRecipeButton.png)](https://app.moderne.io/recipes/org.openrewrite.java.migrate.javax.AddJaxwsRuntime$AddJaxwsRuntimeGradle)

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Expand Down
Loading

0 comments on commit 92f1470

Please sign in to comment.