Skip to content

Commit

Permalink
Merge branch 'main' into feature/3156_Lombok_UtilityClass
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Nov 22, 2023
2 parents 15fe027 + aa84b61 commit f1fcd25
Show file tree
Hide file tree
Showing 560 changed files with 27,254 additions and 6,473 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# These are explicitly windows files and should use crlf
*.bat text eol=crlf
*.cmd text eol=crlf

# These files are text and should be normalized (Convert crlf => lf)
*.bash text eol=lf
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/ci-early-access.yml

This file was deleted.

35 changes: 2 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ concurrency:
jobs:
build:
uses: openrewrite/gh-automation/.github/workflows/ci-gradle.yml@main
with:
java_version: 21
secrets:
gradle_enterprise_access_key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
gradle_enterprise_cache_username: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
Expand All @@ -27,36 +29,3 @@ jobs:
ossrh_token: ${{ secrets.OSSRH_TOKEN }}
ossrh_signing_key: ${{ secrets.OSSRH_SIGNING_KEY }}
ossrh_signing_password: ${{ secrets.OSSRH_SIGNING_PASSWORD }}
# test-downstream:
# needs: build
# strategy:
# fail-fast: false
# matrix:
# repository: [ rewrite-java-security , rewrite-spring, rewrite-migrate-java ]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# path: rewrite
# fetch-depth: 0
# - name: Checkout ${{ matrix.repository }} repo
# uses: actions/checkout@v3
# with:
# repository: openrewrite/${{ matrix.repository }}
# path: ${{ matrix.repository }}
# fetch-depth: 0
# - name: Setup Java
# uses: actions/[email protected]
# with:
# distribution: temurin
# java-version: 17
# - name: Build
# uses: gradle/gradle-build-action@v2
# with:
# arguments: --console=plain --info --stacktrace --warning-mode=all --no-daemon --include-build ../rewrite build
# build-root-directory: ${{ matrix.repository }}
# env:
# GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
# GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
# GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
[![ci](https://github.com/openrewrite/rewrite/actions/workflows/ci.yml/badge.svg)](https://github.com/openrewrite/rewrite/actions/workflows/ci.yml)
[![Apache 2.0](https://img.shields.io/github/license/openrewrite/rewrite.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Maven Central](https://img.shields.io/maven-central/v/org.openrewrite/rewrite-java.svg)](https://mvnrepository.com/artifact/org.openrewrite/rewrite-java)
[![Revved up by Gradle Enterprise](https://img.shields.io/badge/Revved%20up%20by-Gradle%20Enterprise-06A0CE?logo=Gradle&labelColor=02303A)](https://ge.openrewrite.org/scans)
[![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://ge.openrewrite.org/scans)
[![Contributing Guide](https://img.shields.io/badge/Contributing-Guide-informational)](https://github.com/openrewrite/.github/blob/main/CONTRIBUTING.md)
</div>

## More tech. Less debt.

The OpenRewrite project is a mass source code refactoring ecosystem. Reduce 1000s of hours of static code analysis fixes to minutes. Turn a four month migration project into four hours of work. Patch security vulnerabilities across 100s of repositories at once. OpenRewrite automates code refactoring and remediation tasks for you, enabling developers to deliver more business.
The OpenRewrite project is a mass source code refactoring ecosystem. Reduce 1000s of hours of static code analysis fixes to minutes. Turn a four-month migration project into four hours of work. Patch security vulnerabilities across 100s of repositories at once. OpenRewrite automates code refactoring and remediation tasks for you, enabling developers to deliver more business value.

Start with our [quickstart guide](https://docs.openrewrite.org/running-recipes/getting-started) and let OpenRewrite start handling the boring parts of software development for you. Full documentation available at [docs.openrewrite.org](https://docs.openrewrite.org/).

Expand All @@ -29,7 +29,7 @@ See this [doc page](https://docs.openrewrite.org/reference/building-openrewrite-

## Refactoring at scale with Moderne

OpenRewrite's refactoring engine and recipes will always be open source. Build tool plugins like [OpenRewrite Gradle Plugin](https://docs.openrewrite.org/reference/gradle-plugin-configuration) and [OpenRewrite Maven Plugin](https://docs.openrewrite.org/reference/rewrite-maven-plugin) help you run these recipes on one repository at a time. Moderne is a complementary product that executes OpenRewrite recipes at scale on hundreds of millions of lines of code and enables mass committing of results. Moderne freely runs a [public service](https://public.moderne.io) for the benefit of thousands of open source projects.
OpenRewrite's refactoring engine and recipes will always be open source. Build tool plugins like [OpenRewrite Gradle Plugin](https://docs.openrewrite.org/reference/gradle-plugin-configuration) and [OpenRewrite Maven Plugin](https://docs.openrewrite.org/reference/rewrite-maven-plugin) help you run these recipes on one repository at a time. Moderne is a complementary product that executes OpenRewrite recipes at scale on hundreds of millions of lines of code and enables mass-committing of results. Moderne freely runs a [public service](https://public.moderne.io) for the benefit of thousands of open source projects.

[![Moderne](./doc/video_preview.png)](https://youtu.be/Mq6bKAeGCz0)

Expand Down
11 changes: 0 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
plugins {
id("org.openrewrite.build.root") version("latest.release")
id("org.openrewrite.build.java-base") version("latest.release")
id("org.openrewrite.rewrite") version("latest.release")
}

repositories {
mavenCentral()
}

dependencies {
rewrite(project(":rewrite-core"))
}

rewrite {
failOnDryRunResults = true
activeRecipe("org.openrewrite.self.Rewrite")
}


allprojects {
group = "org.openrewrite"
description = "Eliminate tech-debt. Automatically."
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 22 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
1 change: 1 addition & 0 deletions rewrite-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
}

dependencies {
// Pin to 5.x for Java 8, as 6.x requires Java 11
compileOnly("org.eclipse.jgit:org.eclipse.jgit:5.13.+")

implementation("org.openrewrite.tools:java-object-diff:latest.release")
Expand Down
3 changes: 3 additions & 0 deletions rewrite-core/openrewrite.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"type": "boolean",
"default": false
},
"preconditions": {
"$ref": "#/$defs/recipeList"
},
"recipeList": {
"$ref": "#/$defs/recipeList"
}
Expand Down
25 changes: 16 additions & 9 deletions rewrite-core/src/main/java/org/openrewrite/Checksum.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import lombok.Value;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.ipc.http.HttpSender;
import org.openrewrite.remote.Remote;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -84,29 +85,35 @@ public static Checksum fromUri(HttpSender httpSender, URI uri, String algorithm)
}
}

public static SourceFile md5(SourceFile sourceFile) {
return checksum(sourceFile, "MD5");
public static SourceFile md5(SourceFile sourceFile, ExecutionContext ctx) {
return checksum(sourceFile, "MD5", ctx);
}

public static SourceFile sha256(SourceFile sourceFile) {
return checksum(sourceFile, "SHA-256");
public static SourceFile sha256(SourceFile sourceFile, ExecutionContext ctx) {
return checksum(sourceFile, "SHA-256", ctx);
}

public static SourceFile checksum(SourceFile sourceFile, @Nullable String algorithm) {
public static SourceFile checksum(SourceFile sourceFile, @Nullable String algorithm, ExecutionContext ctx) {
if(algorithm == null) {
return sourceFile;
}

try {
MessageDigest md = MessageDigest.getInstance(algorithm);
try (InputStream is = Files.newInputStream(sourceFile.getSourcePath());
DigestInputStream dis = new DigestInputStream(is, md)) {
InputStream is;
if (sourceFile instanceof Remote) {
is = ((Remote) sourceFile).getInputStream(ctx);
} else {
is = Files.newInputStream(sourceFile.getSourcePath());
}

try (DigestInputStream dis = new DigestInputStream(is, md)) {
//noinspection StatementWithEmptyBody
while (dis.read() != -1) {
// read decorated stream to EOF
// read stream to EOF
}
return sourceFile.withChecksum(new Checksum(algorithm, md.digest()));
}
return sourceFile.withChecksum(new Checksum(algorithm, md.digest()));
} catch (NoSuchAlgorithmException | IOException e) {
throw new IllegalArgumentException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public interface ExecutionContext {
String CURRENT_RECIPE = "org.openrewrite.currentRecipe";
String DATA_TABLES = "org.openrewrite.dataTables";
String RUN_TIMEOUT = "org.openrewrite.runTimeout";
String REQUIRE_PRINT_EQUALS_INPUT = "org.openrewrite.requirePrintEqualsInput";

@Incubating(since = "7.20.0")
default ExecutionContext addObserver(TreeObserver.Subscription observer) {
Expand Down
Loading

0 comments on commit f1fcd25

Please sign in to comment.