Skip to content

Commit 87f3864

Browse files
authored
Merge branch 'main' into feature/733-move_superJDK25
2 parents d69ad7d + db99c93 commit 87f3864

File tree

288 files changed

+12994
-7091
lines changed

Some content is hidden

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

288 files changed

+12994
-7091
lines changed

.claude/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(./gradlew test:*)",
5+
"Bash(find:*)",
6+
"WebFetch(domain:github.com)",
7+
"Bash(git checkout:*)",
8+
"Bash(git add:*)",
9+
"Bash(git commit:*)"
10+
],
11+
"deny": []
12+
}
13+
}

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ 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-
ossrh_username: ${{ secrets.OSSRH_USERNAME }}
27-
ossrh_token: ${{ secrets.OSSRH_TOKEN }}
26+
sonatype_username: ${{ secrets.SONATYPE_USERNAME }}
27+
sonatype_token: ${{ secrets.SONATYPE_TOKEN}}
2828
ossrh_signing_key: ${{ secrets.OSSRH_SIGNING_KEY }}
2929
ossrh_signing_password: ${{ secrets.OSSRH_SIGNING_PASSWORD }}
3030
OPS_GITHUB_ACTIONS_WEBHOOK: ${{ secrets.OPS_GITHUB_ACTIONS_WEBHOOK }}

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: openrewrite/gh-automation/.github/workflows/publish-gradle.yml@main
1717
secrets:
1818
gradle_enterprise_access_key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
19-
ossrh_username: ${{ secrets.OSSRH_USERNAME }}
20-
ossrh_token: ${{ secrets.OSSRH_TOKEN }}
19+
sonatype_username: ${{ secrets.SONATYPE_USERNAME }}
20+
sonatype_token: ${{ secrets.SONATYPE_TOKEN}}
2121
ossrh_signing_key: ${{ secrets.OSSRH_SIGNING_KEY }}
2222
ossrh_signing_password: ${{ secrets.OSSRH_SIGNING_PASSWORD }}

.github/workflows/sdkman-candidates.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v5
1616
with:
1717
fetch-depth: 0
1818

build.gradle.kts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ group = "org.openrewrite.recipe"
77
description = "Migrate to later Java versions. Automatically."
88

99
recipeDependencies {
10-
parserClasspath("javax.persistence:javax.persistence-api:2.2")
1110
parserClasspath("jakarta.enterprise:jakarta.enterprise.cdi-api:3.0.0-M4")
11+
parserClasspath("jakarta.inject:jakarta.inject-api:2.0.1")
12+
parserClasspath("jakarta.servlet:jakarta.servlet-api:6.0.0")
13+
parserClasspath("javax.persistence:javax.persistence-api:2.2")
1214
parserClasspath("org.glassfish:javax.servlet:3.0")
15+
parserClasspath("javax.annotation:javax.annotation-api:1.3.2")
16+
parserClasspath("com.google.guava:guava:33.4.8-jre")
17+
parserClasspath("com.google.errorprone:error_prone_core:2.+")
1318
}
1419

1520
val rewriteVersion = rewriteRecipe.rewriteVersion.get()
@@ -44,21 +49,17 @@ dependencies {
4449

4550
runtimeOnly("tech.picnic.error-prone-support:error-prone-contrib:latest.release:recipes")
4651

47-
testImplementation("org.junit.jupiter:junit-jupiter-api:latest.release")
48-
testImplementation("org.junit.jupiter:junit-jupiter-params:latest.release")
52+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.+")
53+
testImplementation("org.junit.jupiter:junit-jupiter-params:5.+")
4954
testImplementation("org.junit-pioneer:junit-pioneer:2.0.0")
50-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:latest.release")
55+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.13.3")
5156

5257
testImplementation("org.openrewrite:rewrite-test")
5358
testImplementation("org.openrewrite:rewrite-kotlin")
5459
testImplementation("org.openrewrite.gradle.tooling:model:$rewriteVersion")
5560

5661
testImplementation("org.assertj:assertj-core:latest.release")
5762

58-
testImplementation("com.google.guava:guava:33.0.0-jre")
59-
testImplementation("joda-time:joda-time:2.12.3")
60-
testImplementation("org.threeten:threeten-extra:1.8.0")
61-
6263
testRuntimeOnly("com.fasterxml.jackson.datatype:jackson-datatype-jsr353")
6364
testRuntimeOnly("com.fasterxml.jackson.core:jackson-core")
6465
testRuntimeOnly("com.fasterxml.jackson.core:jackson-databind")
@@ -74,6 +75,7 @@ dependencies {
7475
testRuntimeOnly("com.google.code.findbugs:jsr305:3.0.2")
7576
testRuntimeOnly("javax.mail:mail:1.4.7")
7677
testRuntimeOnly("javax.mail:javax.mail-api:1.6.2")
78+
testRuntimeOnly("javax.servlet:javax.servlet-api:4.0.1")
7779
testRuntimeOnly("javax.ws.rs:javax.ws.rs-api:2.1.1")
7880
testRuntimeOnly(gradleApi())
7981
}
@@ -85,3 +87,7 @@ tasks.withType(Javadoc::class.java) {
8587
tasks.test {
8688
maxHeapSize = "2g" // Set max heap size to 2GB or adjust as necessary
8789
}
90+
91+
tasks.withType<JavaCompile> {
92+
options.compilerArgs.add("-Arewrite.javaParserClasspathFrom=resources")
93+
}

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=61ad310d3c7d3e5da131b76bbf22b5a4c0786e9d892dae8c1658d4b484de3caa
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
3+
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
* This imperative recipe will add the jdeprscan plugin to a maven project. In the case of a multi-module project,
3030
* this recipe will attempt to add the plugin to only the top level project.
3131
*/
32+
@Getter
3233
@Incubating(since = "0.2.0")
3334
@RequiredArgsConstructor
34-
@Getter
3535
public class AddJDeprScanPlugin extends Recipe {
3636

3737
@Option(displayName = "release", description = "Specifies the Java SE release that provides the set of deprecated APIs for scanning.", required = false, example = "11")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
import static org.openrewrite.java.tree.J.ClassDeclaration.Kind.Type.Interface;
2929

30-
@Value
3130
@EqualsAndHashCode(callSuper = false)
31+
@Value
3232
public class AddMissingMethodImplementation extends Recipe {
3333

3434
@Option(displayName = "Fully qualified class name",
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Copyright 2025 the original author or authors.
3+
* <p>
4+
* Licensed under the Moderne Source Available License (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://docs.moderne.io/licensing/moderne-source-available-license
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.*;
19+
import org.openrewrite.internal.ListUtils;
20+
import org.openrewrite.java.JavaVisitor;
21+
import org.openrewrite.java.search.FindAnnotations;
22+
import org.openrewrite.java.search.UsesType;
23+
import org.openrewrite.java.tree.J;
24+
import org.openrewrite.java.tree.Space;
25+
import org.openrewrite.marker.Markers;
26+
import org.openrewrite.xml.XPathMatcher;
27+
import org.openrewrite.xml.XmlVisitor;
28+
import org.openrewrite.xml.tree.Xml;
29+
30+
import java.util.HashSet;
31+
import java.util.Set;
32+
33+
import static java.util.Collections.emptyList;
34+
35+
public class AddStaticVariableOnProducerSessionBean extends ScanningRecipe<Set<String>> {
36+
37+
private static final XPathMatcher EJB_PATH = new XPathMatcher("ejb-jar/enterprise-beans/session");
38+
39+
@Override
40+
public String getDisplayName() {
41+
return "Adds `static` modifier to `@Produces` fields that are in session beans";
42+
}
43+
44+
@Override
45+
public String getDescription() {
46+
return "Ensures that the fields annotated with `@Produces` which is inside the session bean (`@Stateless`, `@Stateful`, or `@Singleton`) are declared `static`.";
47+
}
48+
49+
@Override
50+
public Set<String> getInitialValue(ExecutionContext ctx) {
51+
// Class names of session beans found in XML
52+
return new HashSet<>();
53+
}
54+
55+
@Override
56+
public TreeVisitor<?, ExecutionContext> getScanner(Set<String> acc) {
57+
return Preconditions.check(
58+
new FindSourceFiles("**/ejb-jar.xml"),
59+
new XmlVisitor<ExecutionContext>() {
60+
@Override
61+
public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) {
62+
if (EJB_PATH.matches(getCursor())) {
63+
Xml.Tag ejbClassTag = tag.getChild("ejb-class").orElse(null);
64+
Xml.Tag sessionTag = tag.getChild("session-type").orElse(null);
65+
if (ejbClassTag != null && sessionTag != null) {
66+
String className = ejbClassTag.getValue().orElse(null);
67+
String sessionType = sessionTag.getValue().orElse(null);
68+
if (className != null &&
69+
("Singleton".equalsIgnoreCase(sessionType) ||
70+
"Stateless".equalsIgnoreCase(sessionType) ||
71+
"Stateful".equalsIgnoreCase(sessionType))) {
72+
acc.add(className);
73+
}
74+
}
75+
}
76+
return super.visitTag(tag, ctx);
77+
}
78+
});
79+
}
80+
81+
@Override
82+
public TreeVisitor<?, ExecutionContext> getVisitor(Set<String> acc) {
83+
return Preconditions.check(
84+
new UsesType<>("jakarta.enterprise.inject.Produces", false),
85+
new JavaVisitor<ExecutionContext>() {
86+
@Override
87+
public J visitVariableDeclarations(J.VariableDeclarations multiVariable, ExecutionContext ctx) {
88+
if (!multiVariable.hasModifier(J.Modifier.Type.Static) &&
89+
hasAnnotation(multiVariable, "@jakarta.enterprise.inject.Produces") &&
90+
(isInSessionBean() || isInXml())) {
91+
return multiVariable.withModifiers(ListUtils.concat(multiVariable.getModifiers(),
92+
new J.Modifier(Tree.randomId(), Space.SINGLE_SPACE, Markers.EMPTY, null, J.Modifier.Type.Static, emptyList())));
93+
}
94+
return multiVariable;
95+
}
96+
97+
private boolean isInSessionBean() {
98+
J.ClassDeclaration parentClass = getCursor().firstEnclosing(J.ClassDeclaration.class);
99+
if (parentClass == null) {
100+
return false;
101+
}
102+
return hasAnnotation(parentClass, "@jakarta.ejb.Singleton") ||
103+
hasAnnotation(parentClass, "@jakarta.ejb.Stateful") ||
104+
hasAnnotation(parentClass, "@jakarta.ejb.Stateless");
105+
}
106+
107+
private boolean isInXml() {
108+
J.ClassDeclaration parentClass = getCursor().firstEnclosing(J.ClassDeclaration.class);
109+
if (parentClass != null && parentClass.getType() != null) {
110+
return acc.contains(parentClass.getType().getFullyQualifiedName());
111+
}
112+
return false;
113+
}
114+
115+
private boolean hasAnnotation(J j, String annotationPattern) {
116+
return !FindAnnotations.find(j, annotationPattern).isEmpty();
117+
}
118+
}
119+
);
120+
}
121+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
* This imperative recipe will add the maven jar plugin to a maven project. The maven jar plugin will be configured to suppress
3131
* Illegal Reflection Warnings. In the case of a multi-module project, this recipe will attempt to add the plugin to only the top level project.
3232
*/
33-
@Incubating(since = "0.2.0")
33+
@EqualsAndHashCode(callSuper = false)
3434
@Getter
35+
@Incubating(since = "0.2.0")
3536
@RequiredArgsConstructor
36-
@EqualsAndHashCode(callSuper = false)
3737
public class AddSuppressionForIllegalReflectionWarningsPlugin extends Recipe {
3838

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

0 commit comments

Comments
 (0)