Skip to content

Commit 1b180b5

Browse files
authored
Merge branch 'main' into java_toolchain_21
2 parents 393d038 + 714c0d0 commit 1b180b5

File tree

187 files changed

+4312
-4593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+4312
-4593
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ jobs:
2323
uses: openrewrite/gh-automation/.github/workflows/ci-gradle.yml@main
2424
secrets:
2525
gradle_enterprise_access_key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
26-
gradle_enterprise_cache_username: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
27-
gradle_enterprise_cache_password: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
2826
ossrh_username: ${{ secrets.OSSRH_USERNAME }}
2927
ossrh_token: ${{ secrets.OSSRH_TOKEN }}
3028
ossrh_signing_key: ${{ secrets.OSSRH_SIGNING_KEY }}

.github/workflows/comment-pr.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: comment-pr
2+
3+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
4+
on:
5+
workflow_run:
6+
workflows: ["receive-pr"]
7+
types:
8+
- completed
9+
10+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
11+
# Since this pull request has write permissions on the target repo, we should **NOT** execute any untrusted code.
12+
jobs:
13+
post-suggestions:
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
uses: openrewrite/gh-automation/.github/workflows/comment-pr.yml@main

.github/workflows/receive-pr.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: receive-pr
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: '${{ github.workflow }} @ ${{ github.ref }}'
11+
cancel-in-progress: true
12+
13+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
14+
# Since this pull request receives untrusted code, we should **NOT** have any secrets in the environment.
15+
jobs:
16+
upload-patch:
17+
uses: openrewrite/gh-automation/.github/workflows/receive-pr.yml@main

build.gradle.kts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies {
1616
testImplementation("org.projectlombok:lombok:latest.release")
1717

1818
annotationProcessor("org.openrewrite:rewrite-templating:$rewriteVersion")
19-
compileOnly("com.google.errorprone:error_prone_core:2.19.1:with-dependencies") {
19+
compileOnly("com.google.errorprone:error_prone_core:2.19.1") {
2020
exclude("com.google.auto.service", "auto-service-annotations")
2121
}
2222

@@ -27,14 +27,8 @@ dependencies {
2727
implementation("org.openrewrite.recipe:rewrite-github-actions:$rewriteVersion")
2828
implementation("org.openrewrite.recipe:rewrite-java-dependencies:$rewriteVersion")
2929
implementation("org.openrewrite.recipe:rewrite-static-analysis:$rewriteVersion")
30-
implementation("org.openrewrite.gradle.tooling:model:$rewriteVersion")
3130
implementation("org.openrewrite:rewrite-templating:$rewriteVersion")
3231

33-
implementation("commons-io:commons-io:2.+")
34-
implementation("org.apache.commons:commons-lang3:3.+")
35-
implementation("org.apache.maven.shared:maven-shared-utils:3.+")
36-
implementation("org.codehaus.plexus:plexus-utils:3.+")
37-
3832
runtimeOnly("org.openrewrite:rewrite-java-8")
3933
runtimeOnly("org.openrewrite:rewrite-java-11")
4034
runtimeOnly("org.openrewrite:rewrite-java-17")
@@ -47,12 +41,11 @@ dependencies {
4741

4842
testImplementation("org.openrewrite:rewrite-test")
4943
testImplementation("org.openrewrite:rewrite-java-tck")
44+
testImplementation("org.openrewrite.gradle.tooling:model:$rewriteVersion")
5045

5146
testImplementation("org.assertj:assertj-core:latest.release")
5247

53-
testImplementation("com.google.guava:guava:29.0-jre")
54-
55-
testImplementation("commons-codec:commons-codec:1.+")
48+
testImplementation("com.google.guava:guava:33.0.0-jre")
5649

5750
testRuntimeOnly("com.fasterxml.jackson.datatype:jackson-datatype-jsr353")
5851
testRuntimeOnly("com.fasterxml.jackson.core:jackson-core")

gradle/wrapper/gradle-wrapper.jar

-9 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

gradlew.bat

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
4343
%JAVA_EXE% -version >NUL 2>&1
4444
if %ERRORLEVEL% equ 0 goto execute
4545

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5151

5252
goto fail
5353

@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5757

5858
if exist "%JAVA_EXE%" goto execute
5959

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6565

6666
goto fail
6767

settings.gradle.kts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,12 @@ plugins {
88
gradleEnterprise {
99
val isCiServer = System.getenv("CI")?.equals("true") ?: false
1010
server = "https://ge.openrewrite.org/"
11-
val gradleCacheRemoteUsername: String? = System.getenv("GRADLE_ENTERPRISE_CACHE_USERNAME")
12-
val gradleCacheRemotePassword: String? = System.getenv("GRADLE_ENTERPRISE_CACHE_PASSWORD")
1311

1412
buildCache {
15-
remote(HttpBuildCache::class) {
16-
url = uri("https://ge.openrewrite.org/cache/")
17-
isPush = isCiServer
18-
if (!gradleCacheRemoteUsername.isNullOrBlank() && !gradleCacheRemotePassword.isNullOrBlank()) {
19-
credentials {
20-
username = gradleCacheRemoteUsername
21-
password = gradleCacheRemotePassword
22-
}
23-
}
13+
remote(gradleEnterprise.buildCache) {
14+
isEnabled = true
15+
val accessKey = System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY")
16+
isPush = isCiServer && !accessKey.isNullOrBlank()
2417
}
2518
}
2619

src/main/java/org/openrewrite/java/migrate/AddSuppressionForIllegalReflectionWarningsPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@Incubating(since = "0.2.0")
3333
@Getter
3434
@RequiredArgsConstructor
35-
@EqualsAndHashCode(callSuper = true)
35+
@EqualsAndHashCode(callSuper = false)
3636
public class AddSuppressionForIllegalReflectionWarningsPlugin extends Recipe {
3737

3838
private static final XPathMatcher PACKAGING_MATCHER = new XPathMatcher("/project/packaging");

src/main/java/org/openrewrite/java/migrate/BeanDiscovery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.util.regex.Pattern;
3030

3131
@Value
32-
@EqualsAndHashCode(callSuper = true)
32+
@EqualsAndHashCode(callSuper = false)
3333
public class BeanDiscovery extends Recipe {
3434

3535
private static final XPathMatcher BEANS_MATCHER = new XPathMatcher("/beans");

src/main/java/org/openrewrite/java/migrate/BeansXmlNamespace.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import static java.util.stream.Collectors.toMap;
2929

3030
@Value
31-
@EqualsAndHashCode(callSuper = true)
31+
@EqualsAndHashCode(callSuper = false)
3232
public class BeansXmlNamespace extends Recipe {
3333

3434
private static final XPathMatcher BEANS_MATCHER = new XPathMatcher("/beans");

src/main/java/org/openrewrite/java/migrate/CastArraysAsListToList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
5252

5353
private static class CastArraysAsListToListVisitor extends JavaVisitor<ExecutionContext> {
5454
@Override
55-
public J visitTypeCast(J.TypeCast typeCast, ExecutionContext executionContext) {
56-
J j = super.visitTypeCast(typeCast, executionContext);
55+
public J visitTypeCast(J.TypeCast typeCast, ExecutionContext ctx) {
56+
J j = super.visitTypeCast(typeCast, ctx);
5757
if (!(j instanceof J.TypeCast) || !(((J.TypeCast) j).getType() instanceof JavaType.Array)) {
5858
return j;
5959
}

src/main/java/org/openrewrite/java/migrate/ChangeMethodInvocationReturnType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import static java.util.Collections.emptyList;
3333

3434
@Value
35-
@EqualsAndHashCode(callSuper = true)
35+
@EqualsAndHashCode(callSuper = false)
3636
public class ChangeMethodInvocationReturnType extends Recipe {
3737

3838
@Option(displayName = "Method pattern",

src/main/java/org/openrewrite/java/migrate/DontOverfetchDto.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@
4141
public class DontOverfetchDto extends Recipe {
4242

4343
@Option(displayName = "DTO type",
44-
description = "The fully qualified name of the DTO.")
44+
description = "The fully qualified name of the DTO.",
45+
example = "animals.Dog")
4546
String dtoType;
4647

4748
@Option(displayName = "Data element",
48-
description = "Replace the DTO as a method parameter when only this data element is used.")
49+
description = "Replace the DTO as a method parameter when only this data element is used.",
50+
example = "name")
4951
String dtoDataElement;
5052

5153
@Override
@@ -93,7 +95,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
9395
.withVariables(ListUtils.map(v.getVariables(), nv -> {
9496
JavaType.Variable fieldType = nv.getName().getFieldType();
9597
return nv
96-
.withName(nv.getName().withSimpleName(dtoDataElement))
98+
.withName(nv.getName().withSimpleName(dtoDataElement).withType(memberType))
9799
.withType(memberType)
98100
.withVariableType(fieldType
99101
.withName(dtoDataElement).withOwner(memberType));

src/main/java/org/openrewrite/java/migrate/JpaCacheProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import static org.openrewrite.xml.FilterTagChildrenVisitor.filterTagChildren;
3434

3535
@Value
36-
@EqualsAndHashCode(callSuper = true)
36+
@EqualsAndHashCode(callSuper = false)
3737
public class JpaCacheProperties extends Recipe {
3838
@Override
3939
public String getDisplayName() {

src/main/java/org/openrewrite/java/migrate/MavenUtils.java

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.openrewrite.java.migrate;
17+
18+
import org.openrewrite.ExecutionContext;
19+
import org.openrewrite.Preconditions;
20+
import org.openrewrite.Recipe;
21+
import org.openrewrite.TreeVisitor;
22+
import org.openrewrite.java.JavaIsoVisitor;
23+
import org.openrewrite.java.search.UsesJavaVersion;
24+
import org.openrewrite.java.tree.J;
25+
26+
public class RemoveIllegalSemicolons extends Recipe {
27+
@Override
28+
public String getDisplayName() {
29+
return "Remove illegal semicolons";
30+
}
31+
32+
@Override
33+
public String getDescription() {
34+
//language=markdown
35+
return "Remove semicolons after package declarations and imports, no longer accepted in Java 21 as of " +
36+
"[JDK-8027682](https://bugs.openjdk.org/browse/JDK-8027682).";
37+
}
38+
39+
@Override
40+
public TreeVisitor<?, ExecutionContext> getVisitor() {
41+
return Preconditions.check(new UsesJavaVersion<>(21), new JavaIsoVisitor<ExecutionContext>() {
42+
@Override
43+
public J.Import visitImport(J.Import _import, ExecutionContext ctx) {
44+
J.Import im = super.visitImport(_import, ctx);
45+
if (im.getPrefix().getWhitespace().contains(";")) {
46+
im = im.withPrefix(im.getPrefix()
47+
.withWhitespace(im.getPrefix().getWhitespace()
48+
.replaceAll("\\s*;(\\R*)\\s*", "$1")));
49+
}
50+
return im;
51+
}
52+
});
53+
}
54+
}

src/main/java/org/openrewrite/java/migrate/RemoveMethodInvocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.openrewrite.staticanalysis.RemoveMethodCallVisitor;
2727

2828
@Value
29-
@EqualsAndHashCode(callSuper = true)
29+
@EqualsAndHashCode(callSuper = false)
3030
public class RemoveMethodInvocation extends Recipe {
3131
@Option(displayName = "Method Pattern",
3232
description = "A method pattern for matching required method definition.",

src/main/java/org/openrewrite/java/migrate/ReplaceStringLiteralValue.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.openrewrite.java.tree.JavaType;
3030

3131
@Value
32-
@EqualsAndHashCode(callSuper = true)
32+
@EqualsAndHashCode(callSuper = false)
3333
public class ReplaceStringLiteralValue extends Recipe {
3434

3535
@Option(displayName = "Old literal `String` value",
@@ -63,6 +63,7 @@ public String getDescription() {
6363
@Override
6464
public TreeVisitor<?, ExecutionContext> getVisitor() {
6565
return new JavaIsoVisitor<ExecutionContext>() {
66+
@Override
6667
public J.Literal visitLiteral(J.Literal literal, ExecutionContext ctx) {
6768
J.Literal l = super.visitLiteral(literal, ctx);
6869
if (l.getType() != JavaType.Primitive.String || !oldLiteralValue.equals(literal.getValue())) {

0 commit comments

Comments
 (0)