Skip to content

Commit

Permalink
recipes for build and plugin upgrade (#476)
Browse files Browse the repository at this point in the history
* recipes for build and plugin upgrade

* added UpgradePluginsForJava11 to list

* Update java-version-21.yml

* Update src/main/resources/META-INF/rewrite/java-version-11.yml

Co-authored-by: Tim te Beek <[email protected]>

* Update src/main/resources/META-INF/rewrite/java-version-17.yml

Co-authored-by: Tim te Beek <[email protected]>

---------

Co-authored-by: Tim te Beek <[email protected]>
  • Loading branch information
cjobinabo and timtebeek authored May 19, 2024
1 parent 30d037d commit 64f8669
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 28 deletions.
34 changes: 26 additions & 8 deletions src/main/resources/META-INF/rewrite/java-version-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,43 @@ recipeList:
- org.openrewrite.java.migrate.javax.JavaxXmlStreamAPIs
- org.openrewrite.java.migrate.cobertura.RemoveCoberturaMavenPlugin
- org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion
- org.openrewrite.java.migrate.UpgradeJavaVersion:
version: 11
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.apache.maven.plugins
artifactId: maven-compiler-plugin
newVersion: 3.6.2
- org.openrewrite.java.migrate.UpgradeBuildToJava11
# Disabled due to null safety issues in the current implementation
# https://github.com/openrewrite/rewrite-migrate-java/issues/250
# - org.openrewrite.java.migrate.util.JavaUtilAPIs
- org.openrewrite.java.migrate.util.OptionalNotPresentToIsEmpty
- org.openrewrite.java.migrate.util.OptionalNotEmptyToIsPresent
- org.openrewrite.java.migrate.util.OptionalStreamRecipe
- org.openrewrite.github.SetupJavaUpgradeJavaVersion:
minimumJavaMajorVersion: 11
- org.openrewrite.java.migrate.InternalBindContextFactory
- org.openrewrite.java.migrate.RemovedSecurityManagerMethods
- org.openrewrite.java.migrate.UpgradePluginsForJava11

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.UpgradeBuildToJava11
displayName: Upgrade build to Java 11
description: Updates build files to use Java 11 as the target/source.
tags:
- java11
recipeList:
- org.openrewrite.java.migrate.UpgradeJavaVersion:
version: 11
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.UpgradePluginsForJava11
displayName: Upgrade plugins to Java 11 compatible versions
description: Updates plugins to version compatible with Java 11.
tags:
- java11
recipeList:
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.apache.maven.plugins
artifactId: maven-compiler-plugin
newVersion: 3.6.2
- org.openrewrite.github.SetupJavaUpgradeJavaVersion:
minimumJavaMajorVersion: 11
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.javax.AddJaxbDependencies
displayName: Add explicit JAXB dependencies
description: >
Expand Down
45 changes: 32 additions & 13 deletions src/main/resources/META-INF/rewrite/java-version-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ tags:
- java17
recipeList:
- org.openrewrite.java.migrate.Java8toJava11
- org.openrewrite.java.migrate.UpgradeJavaVersion:
version: 17
- org.openrewrite.java.migrate.UpgradeBuildToJava17
- org.openrewrite.java.migrate.lang.StringFormatted
- org.openrewrite.github.SetupJavaUpgradeJavaVersion:
minimumJavaMajorVersion: 17
- org.openrewrite.gradle.UpdateGradleWrapper:
version: 7.3
addIfMissing: false
- org.openrewrite.staticanalysis.InstanceOfPatternMatch
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: java.lang.Runtime traceInstructions(boolean)
Expand All @@ -45,6 +39,37 @@ recipeList:
- org.openrewrite.java.migrate.DeprecatedLogRecordThreadID
- org.openrewrite.java.migrate.RemovedLegacySunJSSEProviderName
- org.openrewrite.java.migrate.Jre17AgentMainPreMainPublic
- org.openrewrite.java.migrate.DeprecatedCountStackFramesMethod
- org.openrewrite.java.migrate.RemovedZipFinalizeMethods
- org.openrewrite.java.migrate.RemovedSSLSessionGetPeerCertificateChainMethodImpl
- org.openrewrite.java.migrate.SunNetSslPackageUnavailable
- org.openrewrite.java.migrate.RemovedRMIConnectorServerCredentialTypesConstant
- org.openrewrite.java.migrate.RemovedFileIOFinalizeMethods
- org.openrewrite.java.migrate.UpgradePluginsForJava17

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.UpgradeBuildToJava17
displayName: Upgrade build to Java 17
description: Updates build files to use Java 17 as the target/source.
tags:
- java17
recipeList:
- org.openrewrite.java.migrate.UpgradeJavaVersion:
version: 17
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.UpgradePluginsForJava17
displayName: Upgrade plugins to Java 17 compatible versions
description: Updates plugins to version compatible with Java 17.
tags:
- java17
recipeList:
- org.openrewrite.github.SetupJavaUpgradeJavaVersion:
minimumJavaMajorVersion: 17
- org.openrewrite.gradle.UpdateGradleWrapper:
version: 7.3
addIfMissing: false
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.apache.maven.plugins
artifactId: maven-checkstyle-plugin
Expand All @@ -53,12 +78,6 @@ recipeList:
groupId: com.sonatype.clm
artifactId: clm-maven-plugin
newVersion: 2.47.6-01
- org.openrewrite.java.migrate.DeprecatedCountStackFramesMethod
- org.openrewrite.java.migrate.RemovedZipFinalizeMethods
- org.openrewrite.java.migrate.RemovedSSLSessionGetPeerCertificateChainMethodImpl
- org.openrewrite.java.migrate.SunNetSslPackageUnavailable
- org.openrewrite.java.migrate.RemovedRMIConnectorServerCredentialTypesConstant
- org.openrewrite.java.migrate.RemovedFileIOFinalizeMethods
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.DeprecatedJavaxSecurityCert
Expand Down
44 changes: 37 additions & 7 deletions src/main/resources/META-INF/rewrite/java-version-21.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2023 the original author or authors.
# Copyright 2024 the original author or authors.
# <p>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,15 +25,34 @@ tags:
- java21
recipeList:
- org.openrewrite.java.migrate.UpgradeToJava17
- org.openrewrite.java.migrate.UpgradeJavaVersion:
version: 21
- org.openrewrite.java.migrate.UpgradeBuildToJava21
- org.openrewrite.java.migrate.RemoveIllegalSemicolons
- org.openrewrite.java.migrate.lang.ThreadStopUnsupported
- org.openrewrite.java.migrate.net.URLConstructorsToURIRecipes
- org.openrewrite.java.migrate.util.SequencedCollection
- org.openrewrite.java.migrate.util.UseLocaleOf
- org.openrewrite.staticanalysis.ReplaceDeprecatedRuntimeExecMethods
- org.openrewrite.github.SetupJavaUpgradeJavaVersion
- org.openrewrite.java.migrate.UpgradePluginsForJava21

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.UpgradeBuildToJava21
displayName: Upgrade build to Java 21
description: Updates build files to use Java 21 as the target/source.
tags:
- java21
recipeList:
- org.openrewrite.java.migrate.UpgradeJavaVersion:
version: 21
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.UpgradePluginsForJava21
displayName: Upgrade plugins to Java 21 compatible versions
description: Updates plugins and dependencies to version compatible with Java 21.
tags:
- java21
recipeList:
# GitHub Actions bump needs Gradle Wrapper bump too https://docs.gradle.org/current/userguide/compatibility.html#java
- org.openrewrite.gradle.UpdateGradleWrapper:
version: 8.5
Expand All @@ -55,7 +74,6 @@ recipeList:
groupId: org.modelmapper
artifactId: modelmapper
newVersion: 3.2.x

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.util.SequencedCollection
Expand All @@ -77,6 +95,18 @@ recipeList:
- org.openrewrite.java.ChangeMethodName:
methodPattern: java.util.NavigableSet descendingSet()
newMethodName: reversed
# XXX convert additional patterns to sequenced collections
# list.listIterator() -> ???
# list.listIterator(int) -> ???
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.RemovedSubjectMethods
displayName: Adopt `javax.security.auth.Subject.current()` and `javax.security.auth.Subject.callAs()` methods`
description: Replaces the `javax.security.auth.Subject.getSubject()` and `javax.security.auth.Subject.doAs()` methods
with `javax.security.auth.Subject.current()` and `javax.security.auth.Subject.callAs()`.
tags:
- java21
recipeList:
- org.openrewrite.java.ChangeMethodName:
methodPattern: javax.security.auth.Subject getSubject()
newMethodName: current
- org.openrewrite.java.ChangeMethodName:
methodPattern: javax.security.auth.Subject callAs()
newMethodName: doAs

0 comments on commit 64f8669

Please sign in to comment.