diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ec360d308..0199a74bc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,8 @@ on: branches: - main workflow_dispatch: {} + schedule: + - cron: 0 16 * * * concurrency: group: ci-${{ github.ref }} diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml deleted file mode 100644 index 0622f10f59..0000000000 --- a/.github/workflows/nightly-ci.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: nightly-ci - -on: - schedule: - - cron: 0 16 * * * - -concurrency: - group: ci-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - uses: openrewrite/gh-automation/.github/workflows/ci-gradle.yml@main - with: - java_version: | - 25 - 21 - secrets: - gradle_enterprise_access_key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - sonatype_username: ${{ secrets.SONATYPE_USERNAME }} - sonatype_token: ${{ secrets.SONATYPE_TOKEN}} - ossrh_signing_key: ${{ secrets.OSSRH_SIGNING_KEY }} - ossrh_signing_password: ${{ secrets.OSSRH_SIGNING_PASSWORD }} - OPS_GITHUB_ACTIONS_WEBHOOK: ${{ secrets.OPS_GITHUB_ACTIONS_WEBHOOK }} - node_auth_token: ${{ secrets.NPM_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index a95732cd6a..7e209f5939 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,13 @@ plugins { - id("org.openrewrite.build.root") version("latest.release") - id("org.openrewrite.build.java-base") version("latest.release") - id("org.owasp.dependencycheck") version("latest.release") + id("org.openrewrite.build.root") version "latest.release" + id("org.openrewrite.build.java-base") version "latest.release" + id("org.owasp.dependencycheck") version "latest.release" } configure { analyzers.assemblyEnabled = false - analyzers.nodeAuditEnabled = false - analyzers.nodeEnabled = false + analyzers.nodeAudit { enabled = false } + analyzers.nodePackage { enabled = false } failBuildOnCVSS = System.getenv("FAIL_BUILD_ON_CVSS")?.toFloatOrNull() ?: 9.0F format = System.getenv("DEPENDENCY_CHECK_FORMAT") ?: "HTML" nvd.apiKey = System.getenv("NVD_API_KEY") diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 78cb6e16a4..2e1113280e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/recipes.csv b/recipes.csv deleted file mode 100644 index a829c62516..0000000000 --- a/recipes.csv +++ /dev/null @@ -1,98 +0,0 @@ -name,displayName,description,category1,category2,category3,category4,option1Name,option1DisplayName,option1Description,option2Name,option2DisplayName,option2Description,option3Name,option3DisplayName,option3Description,option4Name,option4DisplayName,option4Description,option5Name,option5DisplayName,option5Description,option6Name,option6DisplayName,option6Description,ecosystem,packageName,version -org.openrewrite.java.AddCommentToImport,Add comment to import statement,Add a comment to an import statement in a Java source file.,Java,Openrewrite,Org,,comment,Comment,The comment to add.,typePattern,Type pattern,A type pattern that is used to find matching imports uses.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.AddCommentToMethod,Add comment to method declarations,Add a comment to method declarations in a Java source file.,Java,Openrewrite,Org,,comment,Comment,The comment to add.,methodPattern,Method pattern,"A pattern to match methods to add the comment to. A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method declarations. For example, to find all method declarations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",isMultiline,Multiline,Comments use by default single line // but they can use multiline /* */.,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.AddCommentToMethodInvocations,Add comment to method invocations,Add a comment to method invocations in a Java source file.,Java,Openrewrite,Org,,comment,Comment,The comment to add.,methodPattern,Method pattern,"A pattern to match methods to add the comment to. A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.AddLicenseHeader,Add license header,Adds license headers to Java source files when missing. Does not override existing license headers.,Java,Openrewrite,Org,,licenseText,License text,The license header text without the block comment. May contain ${CURRENT_YEAR} property.,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.AddLiteralMethodArgument,Add a literal method argument,Add a literal `String` or `int` argument to method invocations.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",argumentIndex,Argument index,A zero-based index that indicates which argument will be added as null to the method invocation.,literal,Literal,The literal value that we add the argument for.,primitiveType,Parameter type,The type of the parameter that we add the argument for. Defaults to `String`.,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.AddMethodParameter,Add method parameter to a method declaration,Adds a new method parameter to an existing method declaration.,Java,Openrewrite,Org,,methodPattern,Method pattern,A method pattern that is used to find the method declarations to modify.,parameterType,Parameter type,The type of the parameter that gets added.,parameterName,Parameter name,The name of the parameter that gets added.,parameterIndex,Parameter index,A zero-based index that indicates the position at which the parameter will be added. At the end by default.,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.AddNullMethodArgument,Add a `null` method argument,Add a `null` argument to method invocations.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",argumentIndex,Argument index,A zero-based index that indicates which argument will be added as null to the method invocation.,parameterType,Parameter type,The type of the parameter that we add the argument for.,parameterName,Parameter name,The name of the parameter that we add the argument for.,explicitCast,Explicit cast,Explicitly cast the argument to the parameter type. Useful if the method is overridden with another type.,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.AddOrUpdateAnnotationAttribute,Add or update annotation attribute,"Some annotations accept arguments. This recipe sets an existing argument to the specified value, or adds the argument if it is not already set.",Java,Openrewrite,Org,,annotationType,Annotation type,The fully qualified name of the annotation.,attributeName,Attribute name,The name of attribute to change. If omitted defaults to 'value'.,attributeValue,Attribute value,"The value to set the attribute to. If the attribute is an array, provide values separated by comma to add multiple attributes at once. Set to `null` to remove the attribute.",oldAttributeValue,Old Attribute value,"The current value of the attribute, this can be used to filter where the change is applied. Set to `null` for wildcard behavior.",addOnly,Add only,"If `true`, disables upgrading existing annotation attribute values, thus the recipe will only add the attribute if it does not already exist. If omitted or `false`, the recipe adds the attribute if missing or updates its value if present.",appendArray,Append array,"If the attribute is an array and attribute is present, setting this option to `true` will append the value(s). Duplicate values will not be added. If omitted or `false`, the recipe will replace the existing value(s) with the new value(s).",maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeAnnotationAttributeName,Change annotation attribute name,Some annotations accept arguments. This recipe renames an existing attribute.,Java,Openrewrite,Org,,annotationType,Annotation Type,The fully qualified name of the annotation.,oldAttributeName,Old attribute name,The name of attribute to change.,newAttributeName,New attribute name,The new attribute name to use.,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeMethodAccessLevel,Change method access level,"Change the access level (public, protected, private, package private) of a method.",Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",newAccessLevel,New access level,New method access level to apply to the method.,matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeMethodInvocationReturnType,Change method invocation return type,Changes the return type of a method invocation.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",newReturnType,New method invocation return type,The fully qualified new return type of method invocation.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeMethodName,Change method name,Rename a method.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",newMethodName,New method name,The method name that will replace the existing name.,matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",ignoreDefinition,Ignore type definition,When set to `true` the definition of the old type will be left untouched. This is useful when you're replacing usage of a class but don't want to rename it.,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeMethodTargetToStatic,Change method target to static,Change method invocations to static method calls.,Java,Openrewrite,Org,,methodPattern,Method pattern,"The original method call may or may not be a static method invocation. A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",fullyQualifiedTargetTypeName,Fully-qualified target type name,A fully-qualified class name of the type upon which the static method is defined.,returnType,Return type after change,"Sometimes changing the target type also changes the return type. In the Guava example, changing from `ImmutableSet#of(..)` to `Set#of(..)` widens the return type from Guava's `ImmutableSet` to just `java.util.Set`.",matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",matchUnknownTypes,Match unknown types,"When enabled, include method invocations which appear to match if full type information is missing. Using matchUnknownTypes can improve recipe resiliency for an AST with missing type information, but also increases the risk of false-positive matches on unrelated method invocations.",,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeMethodTargetToVariable,Change method target to variable,Change method invocations to method calls on a variable.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",variableName,Variable name,Name of variable to use as target for the modified method invocation.,variableType,Variable type,Type attribution to use for the return type of the modified method invocation.,matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangePackage,Rename package name,"A recipe that will rename a package name in package statements, imports, and fully-qualified types.",Java,Openrewrite,Org,,oldPackageName,Old package name,The package name to replace.,newPackageName,New package name,New package name to replace the old package name with.,recursive,Recursive,Recursively change subpackage names,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangePackageInStringLiteral,Rename package name in String literals,A recipe that will rename a package name in String literals.,Java,Openrewrite,Org,,oldPackageName,Old package name,The package name to replace.,newPackageName,New package name,New package name to replace the old package name with.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeStaticFieldToMethod,Change static field access to static method access,Migrate accesses to a static field to invocations of a static method.,Java,Openrewrite,Org,,oldClassName,Old class name,The fully qualified name of the class containing the field to replace.,oldFieldName,Old field name,The simple name of the static field to replace.,newClassName,New class name,The fully qualified name of the class containing the method to use. Leave empty to keep the same class.,newTarget,New field target,An optional method target that can be used to specify a static field within the new class.,newMethodName,New method name,The simple name of the method to use. The method must be static and have no arguments.,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeType,Change type,Change a given type to another.,Java,Openrewrite,Org,,oldFullyQualifiedTypeName,Old fully-qualified type name,Fully-qualified class name of the original type.,newFullyQualifiedTypeName,New fully-qualified type name,"Fully-qualified class name of the replacement type, or the name of a primitive such as ""int"". The `OuterClassName$NestedClassName` naming convention should be used for nested classes.",ignoreDefinition,Ignore type definition,When set to `true` the definition of the old type will be left untouched. This is useful when you're replacing usage of a class but don't want to rename it.,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ChangeTypeInStringLiteral,Change type in String literals,Change a given type to another when used in a String literal.,Java,Openrewrite,Org,,oldFullyQualifiedTypeName,Old fully-qualified type name,Fully-qualified class name of the original type.,newFullyQualifiedTypeName,New fully-qualified type name,"Fully-qualified class name of the replacement type, or the name of a primitive such as ""int"". The `OuterClassName$NestedClassName` naming convention should be used for nested classes.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.DeleteMethodArgument,Delete method argument,Delete an argument from method invocations.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",argumentIndex,Argument index,A zero-based index that indicates which argument will be removed from the method invocation.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.InlineMethodCalls,Inline method calls,"Inline method calls using a template replacement pattern. Supports both method invocations and constructor calls, with optional imports.",Java,Openrewrite,Org,,methodPattern,Method pattern,A method pattern that is used to find matching method invocations.,replacement,Replacement template,The replacement template for the method invocation. Parameters can be referenced using their names from the original method.,imports,Imports,List of regular imports to add when the replacement is made.,staticImports,Static imports,List of static imports to add when the replacement is made.,classpathFromResources,Classpath from resources,List of paths to JAR files on the classpath for parsing the replacement template.,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.NoStaticImport,Remove static import,"Removes static imports and replaces them with qualified references. For example, `emptyList()` becomes `Collections.emptyList()`.",Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.OrderImports,Order imports,"Groups and orders import statements. If a [style has been defined](https://docs.openrewrite.org/concepts-and-explanations/styles), this recipe will order the imports according to that style. If no style is detected, this recipe will default to ordering imports in the same way that IntelliJ IDEA does.",Java,Openrewrite,Org,,removeUnused,Remove unused,Remove unnecessary imports.,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.RandomizeId,Randomize tree IDs,Scramble the IDs. This was intended as a utility to test _en masse_ different techniques for UUID generation and compare their relative performance outside a microbenchmark.,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.RecipeMarkupDemonstration,Demonstrate rendering of `Markup` markers,Tooling may decide to elide or display differently markup of different levels.,Java,Openrewrite,Org,,level,Level,The `Markup#Level` to add.,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.RemoveAnnotation,Remove annotation,Remove matching annotations wherever they occur.,Java,Openrewrite,Org,,annotationPattern,Annotation pattern,"An annotation pattern, expressed as a method pattern.",,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.RemoveAnnotationAttribute,Remove annotation attribute,Some annotations accept arguments. This recipe removes an existing attribute.,Java,Openrewrite,Org,,annotationType,Annotation Type,The fully qualified name of the annotation.,attributeName,Attribute name,The name of attribute to remove.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.RemoveImplements,Remove interface implementations,Removes `implements` clauses from classes implementing the specified interface. Removes `@Overrides` annotations from methods which no longer override anything.,Java,Openrewrite,Org,,interfaceType,Interface type,The fully qualified name of the interface to remove.,filter,Filter,Only apply the interface removal to classes with fully qualified names that begin with this filter. `null` or empty matches all classes.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.RemoveMethodInvocations,Remove method invocations,Remove method invocations if syntactically safe.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A pattern to match method invocations for removal. A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.RemoveObjectsIsNull,Transform calls to `Objects.isNull(..)` and `Objects.nonNull(..)`,Replace calls to `Objects.isNull(..)` and `Objects.nonNull(..)` with a simple null check. Using these methods outside of stream predicates is not idiomatic.,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.RemoveUnusedImports,Remove unused imports,"Remove imports for types that are not referenced. As a precaution against incorrect changes no imports will be removed from any source where unknown types are referenced. The most common cause of unknown types is the use of annotation processors not supported by OpenRewrite, such as lombok.",Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ReorderMethodArguments,Reorder method arguments,Reorder method arguments into the specified order.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",newParameterNames,New parameter names,An array of parameter names that indicates the new order in which those arguments should be arranged.,oldParameterNames,Old parameter names,"If the original method signature is not type-attributed, this is an optional list that indicates the original order in which the arguments were arranged.",ignoreDefinition,Ignore type definition,When set to `true` the definition of the old type will be left untouched. This is useful when you're replacing usage of a class but don't want to rename it.,matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ReplaceAnnotation,Replace annotation,Replace an Annotation with another one if the annotation pattern matches. Only fixed parameters can be set in the replacement.,Java,Openrewrite,Org,,annotationPatternToReplace,Annotation to replace,"An annotation matcher, expressed as a method pattern to replace.",annotationTemplateToInsert,Annotation template to insert,"An annotation template to add instead of original one, will be parsed with `JavaTemplate`.",classpathResourceName,Classpath resource,If the annotation's type is defined by a jar within the META-INF/rewrite/classpath directory provide its name here so that it can be loaded. When this parameter is not passed the runtime classpath of the recipe is provided to the parser producing the new annotation. This is necessary when the annotation is not on the runtime classpath of the recipe and isn't in the Java standard library.,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ReplaceConstant,Replace constant with literal value,Replace a named constant with a literal value when you wish to remove the old constant. A `String` literal must include escaped quotes.,Java,Openrewrite,Org,,owningType,Owning type of the constant,The target type in which the constant to be replaced is defined.,constantName,Constant name,The name of the constant field to replace.,literalValue,Literal value,The literal value to replace.,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ReplaceConstantWithAnotherConstant,Replace constant with another constant,"Replace a constant with another constant, adding/removing import on class if needed.",Java,Openrewrite,Org,,existingFullyQualifiedConstantName,Fully qualified name of the constant to replace,,fullyQualifiedConstantName,Fully qualified name of the constant to use in place of existing constant,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ReplaceMethodInvocationWithConstant,Replace method invocation with constant,Replace all method invocations matching the method pattern with the specified constant.,Java,Openrewrite,Org,,methodPattern,Method pattern,"A pattern to match method invocations to replace. A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",replacement,Replacement,The constant to replace the method invocation with.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ReplaceStringLiteralValue,Replace `String` literal,Replace the value of a complete `String` literal.,Java,Openrewrite,Org,,oldLiteralValue,Old literal `String` value,The `String` value to replace.,newLiteralValue,New literal `String` value,The `String` value to replace with.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ReplaceStringLiteralWithConstant,Replace String literal with constant,"Replace String literal with constant, adding import on class if needed.",Java,Openrewrite,Org,,literalValue,String literal value to replace,"The literal that is to be replaced. If not configured, the value of the specified constant will be used by default.",fullyQualifiedConstantName,Fully qualified name of the constant to use in place of String literal,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ShortenFullyQualifiedTypeReferences,Add imports for fully qualified references to types,"Any fully qualified references to Java types will be replaced with corresponding simple names and import statements, provided that it doesn't result in any conflicts with other imports or types declared in the local compilation unit.",Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.SimplifyMethodChain,Simplify a call chain,Simplify `a.b().c()` to `a.d()`.,Java,Openrewrite,Org,,methodPatternChain,Method pattern chain,A list of method patterns that are called in sequence,newMethodName,New method name,The method name that will replace the existing name. The new method name target is assumed to have the same arguments as the last method in the chain.,matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.SimplifySingleElementAnnotation,Simplify single-element annotation,"This recipe will remove the attribute `value` on single-element annotations. According to JLS, a _single-element annotation_, is a shorthand designed for use with single-element annotation types.",Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.UpdateSourcePositions,Update source positions,Calculate start position and length for every LST element.,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.UseStaticImport,Use static import,"Removes unnecessary receiver types from static method invocations. For example, `Collections.emptyList()` becomes `emptyList()`.",Java,Openrewrite,Org,,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.CreateEmptyJavaClass,Create Java class,"Create a new, empty Java class.",Java,Openrewrite,Org,,sourceRoot,Source root,The source root of the new class file.,packageName,Package name,The package of the new class.,modifier,Modifier,The class modifier.,className,Class name,File path of new file.,overwriteExisting,Overwrite existing file,"If there is an existing file, should it be overwritten.",relativePath,Relative directory path,Directory path of new class.,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.AddApache2LicenseHeader,Add ASLv2 license header,Adds the Apache Software License Version 2.0 to Java source files which are missing a license header.,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,,yaml,maven-rewrite-yaml:org.openrewrite:rewrite-core:8.64.0-SNAPSHOT!/META-INF/rewrite/apache-license-header.yml,8.64.0-SNAPSHOT -org.openrewrite.java.ai.ClassDefinitionLength,Calculate token length of classes,Locates class definitions and predicts the number of token in each.,AI tools,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.ai.MethodDefinitionLength,Calculate token length of method definitions,Locates method definitions and predicts the number of token in each.,AI tools,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.AutoFormat,Format Java code,Format Java code using a standard comprehensive set of Java formatting recipes.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.BlankLines,Blank lines,Add and/or remove blank lines.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.EmptyNewlineAtEndOfFile,End files with a single newline,Some tools work better when files end with an empty line.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.MethodParamPad,Method parameter padding,"Fixes whitespace padding between the identifier of a method definition or method invocation and the left parenthesis of the parameter list. For example, when configured to remove spacing, `someMethodInvocation (x);` becomes `someMethodInvocation(x)`.",Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.NoWhitespaceAfter,No whitespace after,"Removes unnecessary whitespace appearing after a token. A linebreak after a token is allowed unless `allowLineBreaks` is set to `false`, in which case it will be removed.",Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.NoWhitespaceBefore,No whitespace before,Removes unnecessary whitespace preceding a token. A linebreak before a token will be removed unless `allowLineBreaks` is set to `true`.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.NormalizeFormat,Normalize format,Move whitespace to the outermost LST element possible.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.NormalizeLineBreaks,Normalize line breaks,Consistently use either Windows style (CRLF) or Linux style (LF) line breaks. If no `GeneralFormatStyle` is specified this will use whichever style of line endings are more common.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.NormalizeTabsOrSpaces,Normalize to tabs or spaces,Consistently use either tabs or spaces in indentation.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.PadEmptyForLoopComponents,Pad empty `for` loop components,Fixes padding on empty `for` loop iterators and initializers to match Checkstyle policies.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.RemoveTrailingWhitespace,Remove trailing whitespace,Remove any extra trailing whitespace from the end of each line.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.SingleLineComments,Single line comments begin with a whitespace,Write `// hi` instead of `//hi`.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.Spaces,Spaces,Format whitespace in Java code.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.TabsAndIndents,Tabs and indents,Format tabs and indents in Java code.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.TypecastParenPad,Typecast parentheses padding,"Fixes whitespace padding between a typecast type identifier and the enclosing left and right parenthesis. For example, when configured to remove spacing, `( int ) 0L;` becomes `(int) 0L;`.",Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.format.WrappingAndBraces,Wrapping and braces,Format line wraps and braces in Java code.,Format,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.DoesNotUseType,Check whether a type is **not** in use,Useful as a precondition to skip over compilation units using the argument type.,Search,Java,Openrewrite,Org,fullyQualifiedTypeName,Fully-qualified type name,"A fully-qualified type name, that is used to find matching type references. Supports glob expressions. `java..*` finds every type from every subpackage of the `java` package.",includeImplicit,Include implicit type references,"Whether to include implicit type references, such as those in method signatures.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindAnnotations,Find annotations,Find all annotations matching the annotation pattern.,Search,Java,Openrewrite,Org,annotationPattern,Annotation pattern,"An annotation pattern, expressed as a method pattern.",matchMetaAnnotations,Match on meta annotations,"When enabled, matches on meta annotations of the annotation pattern.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindClassHierarchy,Find class hierarchy,"Discovers all class declarations within a project, recording which files they appear in, their superclasses, and interfaces. That information is then recorded in a data table.",Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindComments,Find within comments and literals,"Find regular expression matches within comments and literals. ""Literals"" includes string literals, character literals, and numeric literals.",Search,Java,Openrewrite,Org,patterns,Text patterns,A list of regular expressions to search for.,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindCompileErrors,Find compile errors,Compile errors result in a particular LST structure that can be searched for.,Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindDeprecatedClasses,Find uses of deprecated classes,"Find uses of deprecated classes, optionally ignoring those classes that are inside deprecated scopes.",Search,Java,Openrewrite,Org,typePattern,Type pattern,A type pattern that is used to find matching classes.,matchInherited,Match inherited,"When enabled, find types that inherit from a deprecated type.",ignoreDeprecatedScopes,Ignore deprecated scopes,"When a deprecated type is used in a deprecated method or class, ignore it.",,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindDeprecatedFields,Find uses of deprecated fields,Find uses of deprecated fields in any API.,Search,Java,Openrewrite,Org,typePattern,Type pattern,A type pattern that is used to find matching field uses.,matchInherited,Match inherited,"When enabled, find types that inherit from a deprecated type.",ignoreDeprecatedScopes,Ignore deprecated scopes,"When a deprecated method is used in a deprecated method or class, ignore it.",,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindDeprecatedMethods,Find uses of deprecated methods,Find uses of deprecated methods in any API.,Search,Java,Openrewrite,Org,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",ignoreDeprecatedScopes,Ignore deprecated scopes,When set to `true` deprecated methods used within deprecated methods or classes will be ignored.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindDeprecatedUses,"Find uses of deprecated classes, methods, and fields","Find deprecated uses of methods, fields, and types. Optionally ignore those classes that are inside deprecated scopes.",Search,Java,Openrewrite,Org,typePattern,Type pattern,A type pattern that is used to find deprecations from certain types.,matchInherited,Match inherited,"When enabled, find types that inherit from a deprecated type.",ignoreDeprecatedScopes,Ignore deprecated scopes,"When a deprecated type is used in a deprecated method or class, ignore it.",,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindEmptyClasses,Find empty classes,Find empty classes without annotations that do not implement an interface or extend a class.,Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindEmptyMethods,Find methods with empty bodies,Find methods with empty bodies and single public no arg constructors.,Search,Java,Openrewrite,Org,matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindFields,Find fields,Find uses of a field.,Search,Java,Openrewrite,Org,fullyQualifiedTypeName,Fully-qualified type name,"A fully-qualified Java type name, that is used to find matching fields.",matchInherited,Match inherited,"When enabled, find types that inherit from a deprecated type.",fieldName,Field name,The name of a field on the type.,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindFieldsOfType,Find fields of type,Finds declared fields matching a particular class name.,Search,Java,Openrewrite,Org,fullyQualifiedTypeName,Fully-qualified type name,"A fully-qualified Java type name, that is used to find matching fields.",matchInherited,Match inherited,"When enabled, find types that inherit from a deprecated type.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindImplementations,Find implementing classes,"Find class declarations which implement the specified type. If the specified type is a class, its subclasses will be matched. If the specified type is an interface, classes which implement it will be matched.",Search,Java,Openrewrite,Org,typeName,Type name,The fully qualified name to search for.,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindImports,Find source files with imports,"Locates source files that have imports matching the given type pattern, regardless of whether that import is used in the code.",Search,Java,Openrewrite,Org,typePattern,Type pattern,A type pattern that is used to find matching field uses.,matchInherited,Match inherited,"When enabled, find types that inherit from a deprecated type.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindLiterals,Find literals,Find literals matching a pattern.,Search,Java,Openrewrite,Org,pattern,Pattern,A regular expression pattern to match literals against.,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindMethodDeclaration,Find method declaration,Locates the declaration of a method.,Search,Java,Openrewrite,Org,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindMethods,Find method usages,Find method calls by pattern.,Search,Java,Openrewrite,Org,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindMissingTypes,Find missing type information on Java LSTs,This is a diagnostic recipe to highlight where LSTs are missing type attribution information.,Search,Java,Openrewrite,Org,checkDocumentation,Check documentation,When set to `true` any references in documentation (i.e. Javadoc for Java) will also be checked. Default is `false`.,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindRepeatableAnnotations,Find uses of `@Repeatable` annotations,Java 8 introduced the concept of `@Repeatable` annotations.,Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindTypes,Find types,Find type references by name.,Search,Java,Openrewrite,Org,fullyQualifiedTypeName,Fully-qualified type name,"A fully-qualified type name, that is used to find matching type references. Supports glob expressions. `java..*` finds every type from every subpackage of the `java` package.",checkAssignability,Check for assignability,"When enabled, find type references that are assignable to the provided type.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.HasBuildToolVersion,Find files with a particular build tool version,Finds Java source files built with a particular build tool. This is useful especially as a precondition for other recipes.,Search,Java,Openrewrite,Org,type,Build tool type,The build tool to search for.,version,Build tool version,An exact version number or node-style semver selector used to select the version number.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.HasJavaVersion,Find files compiled at a specific Java version,Finds Java source files matching a particular language level. This is useful especially as a precondition for other recipes.,Search,Java,Openrewrite,Org,version,Java version,An exact version number or node-style semver selector used to select the version number.,checkTargetCompatibility,Version check against target compatibility,The source and target compatibility versions can be different. This option allows you to check against the target compatibility version instead of the source compatibility version.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.HasMethod,Find files that have at least one use of a method,Marks files that have at least one occurrence of a method matching a pattern.,Search,Java,Openrewrite,Org,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.HasSourceSet,Find files in a source set,"Source sets are a way to organize your source code into logical groups. For example, Java projects commonly have a `main` source set for application code and a `test` source set for test code. This recipe will find all files in a given source set.",Search,Java,Openrewrite,Org,sourceSet,Source set,The source set to search for.,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.HasType,Find files that have at least one use of a type,"Marks files that have at least one occurrence of a type, even if the name of that type doesn't appear in the source code.",Search,Java,Openrewrite,Org,fullyQualifiedTypeName,Fully-qualified type name,"A fully-qualified type name, that is used to find matching type references. Supports glob expressions. `java..*` finds every type from every subpackage of the `java` package.",checkAssignability,Check for assignability,"When enabled, find type references that are assignable to the provided type.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.IsLikelyNotTest,Find files that are likely not tests,"Sources that do not contain indicators of being, or being exclusively for the use in tests. This recipe is simply a negation of the `org.openrewrite.java.search.IsLikelyTest` recipe.",Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.IsLikelyTest,Find sources that are likely tests,"Sources that contain indicators of being, or being exclusively for the use in tests. This recipe is not exhaustive, but is intended to be a good starting point for finding test sources. Looks at the source set name, and types in use; for example looks for uses of JUnit & TestNG annotations/assertions.",Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.ResultOfMethodCallIgnored,Result of method call ignored,Find locations where the result of the method call is being ignored.,Search,Java,Openrewrite,Org,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.ClasspathTypeCounts,Study the size of the classpath by source set,"Emit one data table row per source set in a project, with the number of types in the source set.",Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindDistinctMethods,Find distinct methods in use,"A sample of every distinct method in use in a repository. The code sample in the method calls data table will be a representative use of the method, though there may be many other such uses of the method.",Search,Java,Openrewrite,Org,methodPattern,Method pattern,"A [method pattern](https://docs.openrewrite.org/reference/method-patterns) is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: `com.google.common..*#*(..)`.

The pattern format is `#()`.

`..*` includes all subpackages of `com.google.common`.
`*(..)` matches any method name with any number of arguments.

For more specific queries, like Guava's `ImmutableMap`, use `com.google.common.collect.ImmutableMap#*(..)` to narrow down the results.",matchOverrides,Match on overrides,"When enabled, find methods that are overrides of the method pattern.",,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindTypeMappings,Find type mappings,Study the frequency of `J` types and their `JavaType` type attribution.,Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.HasMinimumJavaVersion,Find the oldest Java version in use,"The oldest Java version in use is the lowest Java version in use in any source set of any subproject of a repository. It is possible that, for example, the main source set of a project uses Java 8, but a test source set uses Java 17. In this case, the oldest Java version in use is Java 8.",Search,Java,Openrewrite,Org,version,Java version,An exact version number or node-style semver selector used to select the version number.,checkTargetCompatibility,Version check against target compatibility,The source and target compatibility versions can be different. This option allows you to check against the target compatibility version instead of the source compatibility version.,,,,,,,,,,,,,maven,org.openrewrite:rewrite-core,8.64.0-SNAPSHOT -org.openrewrite.java.search.FindSecrets,Find plain text secrets,Find secrets stored in plain text in code.,Search,Java,Openrewrite,Org,,,,,,,,,,,,,,,,,,,yaml,maven-rewrite-yaml:org.openrewrite:rewrite-core:8.64.0-SNAPSHOT!/META-INF/rewrite/find-plaintext-secrets.yml,8.64.0-SNAPSHOT diff --git a/rewrite-bom/build.gradle.kts b/rewrite-bom/build.gradle.kts index 9ec69a32d7..031ac01148 100644 --- a/rewrite-bom/build.gradle.kts +++ b/rewrite-bom/build.gradle.kts @@ -17,11 +17,3 @@ dependencies { .forEach { api(it) } } } - -publishing { - publications { - named("nebula", MavenPublication::class.java) { - from(components["javaPlatform"]) - } - } -} diff --git a/rewrite-core/build.gradle.kts b/rewrite-core/build.gradle.kts index aa9d31452d..a4436928d6 100644 --- a/rewrite-core/build.gradle.kts +++ b/rewrite-core/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { testImplementation("org.assertj:assertj-core:latest.release") testImplementation(project(":rewrite-test")) + testRuntimeOnly("org.junit.platform:junit-platform-launcher") } tasks.withType { diff --git a/rewrite-gradle-tooling-model/model/build.gradle.kts b/rewrite-gradle-tooling-model/model/build.gradle.kts index a45722449a..49913559ef 100644 --- a/rewrite-gradle-tooling-model/model/build.gradle.kts +++ b/rewrite-gradle-tooling-model/model/build.gradle.kts @@ -40,11 +40,6 @@ dependencies { testImplementation("com.fasterxml.jackson.core:jackson-databind") testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-smile") - testImplementation("org.assertj:assertj-core:3.+") - testImplementation(platform("org.junit:junit-bom:5.13.3")) - testImplementation("org.junit.jupiter:junit-jupiter-api") - testImplementation("org.junit.jupiter:junit-jupiter-params") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") "pluginLocalTestClasspath"(project(":rewrite-gradle-tooling-model:plugin")) } @@ -52,6 +47,12 @@ tasks.named("compileJava").configure { options.release.set(8) } +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + val testGradle4 = tasks.register("testGradle4") { systemProperty("org.openrewrite.test.gradleVersion", "4.10") systemProperty("jarLocationForTest", tasks.named("jar").get().archiveFile.get().asFile.absolutePath) diff --git a/rewrite-gradle-tooling-model/model/src/main/java/org/openrewrite/gradle/toolingapi/OpenRewriteModelImpl.java b/rewrite-gradle-tooling-model/model/src/main/java/org/openrewrite/gradle/toolingapi/OpenRewriteModelImpl.java index bd82fd7724..a3307a287d 100644 --- a/rewrite-gradle-tooling-model/model/src/main/java/org/openrewrite/gradle/toolingapi/OpenRewriteModelImpl.java +++ b/rewrite-gradle-tooling-model/model/src/main/java/org/openrewrite/gradle/toolingapi/OpenRewriteModelImpl.java @@ -21,7 +21,7 @@ import java.io.Serializable; @Value -public class OpenRewriteModelImpl implements Serializable { +public class OpenRewriteModelImpl implements OpenRewriteModelProxy, Serializable { byte[] gradleProjectBytes; byte @Nullable [] gradleSettingsBytes; diff --git a/rewrite-gradle/build.gradle.kts b/rewrite-gradle/build.gradle.kts index 391103e3cb..a2f38a24df 100644 --- a/rewrite-gradle/build.gradle.kts +++ b/rewrite-gradle/build.gradle.kts @@ -79,6 +79,12 @@ dependencies { } +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + tasks.withType().configureEach { dependsOn(pluginLocalTestClasspath) systemProperty("org.openrewrite.gradle.local.use-embedded-classpath", pluginLocalTestClasspath.files.find { it.name == "test-manifest.txt" }!!.path) diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/versions.csv b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/versions.csv index 478a9818c3..0bf7be7fbe 100644 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/versions.csv +++ b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/versions.csv @@ -1,9 +1,12 @@ -version,gradlew,gradlewBatTemplate -9.3.0-20251015002136+0000,58fa5370,59596926 +version,gradlew,gradlewBat +9.3.0-20251029004548+0000,58fa5370,59596926 +9.2.0,665958e3,9af86e4b +9.2.0-rc-3,58fa5370,59596926 +9.2.0-rc-2,58fa5370,59596926 9.2.0-rc-1,58fa5370,59596926 9.2.0-milestone-2,58fa5370,59596926 9.2.0-milestone-1,58fa5370,59596926 -9.2.0-20251014014930+0000,58fa5370,59596926 +9.2.0-20251028012738+0000,58fa5370,59596926 9.1.0,665958e3,9af86e4b 9.1.0-rc-4,58fa5370,59596926 9.1.0-rc-3,58fa5370,59596926 @@ -194,13 +197,13 @@ version,gradlew,gradlewBatTemplate 6.7-rc-5,bac56609,e19346b5 6.6.1,dd036b7c,16404bda 6.6,dd036b7c,16404bda -6.6-rc-4,bac56609,b8ca22c +6.6-rc-4,bac56609,e19346b5 6.6-rc-3,bac56609,b8ca22c 6.6-rc-2,bac56609,b8ca22c 6.6-rc-1,bac56609,b8ca22c 6.6-rc-6,bac56609,e19346b5 6.6-rc-5,bac56609,e19346b5 -6.6-milestone-3,bac56609,b8ca22c +6.6-milestone-3,970c6689,b8ca22c 6.6-milestone-2,bac56609,b8ca22c 6.6-milestone-1,970c6689,b8ca22c 6.5.1,cf166bfc,2e27a751 @@ -352,7 +355,7 @@ version,gradlew,gradlewBatTemplate 3.0,add6bffe,f9e3a413 3.0-rc-2,add6bffe,f9e3a413 3.0-rc-1,add6bffe,f9e3a413 -3.0-milestone-2,add6bffe,f9e3a413 +3.0-milestone-2,add6bffe,3c3cfe8 3.0-milestone-1,add6bffe,3c3cfe8 2.14.1,4d0a84af,3c3cfe8 2.14.1-rc-2,4d0a84af,3c3cfe8 @@ -452,7 +455,7 @@ version,gradlew,gradlewBatTemplate 1.0-rc-2,ce5191e8,b3a0cfef 1.0-rc-3,ce5191e8,b3a0cfef 1.0-rc-1,ce5191e8,b3a0cfef -1.0-milestone-7,ca7f855d,b3a0cfef +1.0-milestone-7,7c3190ce,b3a0cfef 1.0-milestone-8,7c3190ce,b3a0cfef 1.0-milestone-9,7c3190ce,b3a0cfef 1.0-milestone-5,ca7f855d,b3a0cfef diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/16404bda.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/16404bda.txt deleted file mode 100644 index 107acd32c4..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/16404bda.txt +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/2e27a751.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/2e27a751.txt deleted file mode 100644 index 5093609d51..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/2e27a751.txt +++ /dev/null @@ -1,104 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/47ec8629.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/47ec8629.txt deleted file mode 100644 index 9991c50326..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/47ec8629.txt +++ /dev/null @@ -1,100 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem http://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/5211869c.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/5211869c.txt deleted file mode 100644 index 9618d8d960..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/5211869c.txt +++ /dev/null @@ -1,100 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/5e608638.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/5e608638.txt deleted file mode 100644 index 9d21a21834..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/5e608638.txt +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -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% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/937e772a.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/937e772a.txt deleted file mode 100644 index 25da30dbde..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/937e772a.txt +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -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% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/a43e7a0f.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/a43e7a0f.txt deleted file mode 100644 index db3a6ac207..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/a43e7a0f.txt +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -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% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH= - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/b1366393.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/b1366393.txt deleted file mode 100644 index f127cfd49d..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/b1366393.txt +++ /dev/null @@ -1,91 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/d0586e24.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/d0586e24.txt deleted file mode 100644 index 93e3f59f13..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/d0586e24.txt +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -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% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/e6a8a698.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/e6a8a698.txt deleted file mode 100644 index 6d57edc706..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/e6a8a698.txt +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/fd89a73a.txt b/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/fd89a73a.txt deleted file mode 100644 index 62bd9b9cce..0000000000 --- a/rewrite-gradle/src/main/resources/META-INF/rewrite/gradle-wrapper/windows/fd89a73a.txt +++ /dev/null @@ -1,103 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/rewrite-groovy/build.gradle.kts b/rewrite-groovy/build.gradle.kts index a5a5d5eb57..cf4ec2c97a 100644 --- a/rewrite-groovy/build.gradle.kts +++ b/rewrite-groovy/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + plugins { id("org.openrewrite.build.language-library") id("jvm-test-suite") @@ -33,6 +35,11 @@ testing { } } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} dependencies { api(project(":rewrite-java")) diff --git a/rewrite-java-tck/build.gradle.kts b/rewrite-java-tck/build.gradle.kts index 9b02f6423d..0c3bf70b2d 100644 --- a/rewrite-java-tck/build.gradle.kts +++ b/rewrite-java-tck/build.gradle.kts @@ -14,7 +14,7 @@ dependencies { if (System.getProperty("idea.active") != null || System.getProperty("idea.sync.active") != null) { // so we can run tests in the IDE with the IntelliJ IDEA runner - runtimeOnly(project(":rewrite-java-25")) + runtimeOnly(project(":rewrite-java-21")) } } diff --git a/rewrite-java-test/build.gradle.kts b/rewrite-java-test/build.gradle.kts index 6d8056c211..aa1849d6a1 100644 --- a/rewrite-java-test/build.gradle.kts +++ b/rewrite-java-test/build.gradle.kts @@ -24,11 +24,10 @@ tasks.withType().configureEach { exclude("org/openrewrite/java/**") } -tasks.named("compileTestJava") { - sourceCompatibility = JavaVersion.VERSION_21.toString() - targetCompatibility = JavaVersion.VERSION_21.toString() - - options.release.set(null as Int?) // remove `--release 8` set in `org.openrewrite.java-base` +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } } tasks.withType().configureEach { diff --git a/rewrite-java/build.gradle.kts b/rewrite-java/build.gradle.kts index e21599f9e5..ebe9a0383d 100644 --- a/rewrite-java/build.gradle.kts +++ b/rewrite-java/build.gradle.kts @@ -77,6 +77,12 @@ dependencies { testRuntimeOnly("jakarta.validation:jakarta.validation-api:3.1.1") } +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + tasks.withType().configureEach { // generated ANTLR sources violate doclint (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") diff --git a/rewrite-javascript/rewrite/src/javascript/format.ts b/rewrite-javascript/rewrite/src/javascript/format.ts index 89cef9f9f6..39345fbdec 100644 --- a/rewrite-javascript/rewrite/src/javascript/format.ts +++ b/rewrite-javascript/rewrite/src/javascript/format.ts @@ -15,7 +15,7 @@ */ import {JS} from "./tree"; import {JavaScriptVisitor} from "./visitor"; -import {Comment, emptySpace, J, Statement} from "../java"; +import {Comment, J, Statement} from "../java"; import {Draft, produce} from "immer"; import {Cursor, isScope, Tree} from "../tree"; import { @@ -85,13 +85,6 @@ export class NormalizeWhitespaceVisitor

extends JavaScriptVisitor

{ } return super.postVisit(tree, p); } - - private concatenatePrefix(node: Draft, right: J.Space) { - // TODO look at https://github.com/openrewrite/rewrite/commit/990a366fab9e5656812d81d0eb15ecb6bfd2fde0#diff-ec2e977fe8f1e189735e71b817f8f1ebaf79c1490c0210652e8a559f7f7877de - // and possibly incorporate it here - some special logic needed to merge comments better (?) - node.prefix.comments = [...node.prefix.comments, ...right.comments]; - node.prefix.whitespace = node.prefix.whitespace + right.whitespace; - } } export class SpacesVisitor

extends JavaScriptVisitor

{ @@ -193,11 +186,6 @@ export class SpacesVisitor

extends JavaScriptVisitor

{ protected async visitClassDeclaration(classDecl: J.ClassDeclaration, p: P): Promise { const ret = await super.visitClassDeclaration(classDecl, p) as J.ClassDeclaration; - // TODO - // if (c.leadingAnnotations.length > 1) { - // c = {...c, leadingAnnotations: spaceBetweenAnnotations(c.leadingAnnotations)}; - // } - // TODO typeParameters - IntelliJ doesn't seem to provide a setting for angleBrackets spacing for Typescript (while it does for Java), // thus we either introduce our own setting or just enforce the natural spacing with no setting @@ -326,10 +314,6 @@ export class SpacesVisitor

extends JavaScriptVisitor

{ draft.parameters = await this.spaceBeforeContainer(draft.parameters, this.style.beforeParentheses.functionDeclarationParentheses); // TODO typeParameters handling - see visitClassDeclaration - // TODO - // if (m.leadingAnnotations.length > 1) { - // m = m.withLeadingAnnotations(this.spaceBetweenAnnotations(m.leadingAnnotations)); - // } }); } @@ -349,11 +333,6 @@ export class SpacesVisitor

extends JavaScriptVisitor

{ draft.arguments.elements[0] = await this.spaceAfterRightPadded(await this.spaceBeforeRightPaddedElement(draft.arguments.elements[0], this.style.within.functionCallParentheses), false); } // TODO typeParameters handling - see visitClassDeclaration - - // TODO - // m = m.getPadding().withArguments(spaceBefore(m.getPadding().getArguments(), style.getBeforeParentheses().getMethodCall())); - // if (m.getArguments().isEmpty() || m.getArguments()[0] instanceof J.Empty) { - // ... }); } @@ -445,6 +424,10 @@ export class SpacesVisitor

extends JavaScriptVisitor

{ } protected async visitVariable(variable: J.VariableDeclarations.NamedVariable, p: P): Promise { const ret = await super.visitVariable(variable, p) as J.VariableDeclarations.NamedVariable; + if (variable.initializer?.element?.kind == JS.Kind.StatementExpression + && (variable.initializer.element as JS.StatementExpression).statement.kind == J.Kind.MethodDeclaration) { + return ret; + } return produceAsync(ret, async draft => { if (draft.initializer) { draft.initializer.before.whitespace = this.style.aroundOperators.assignment ? " " : ""; @@ -582,20 +565,6 @@ export class WrappingAndBracesVisitor

extends JavaScriptVisitor

{ return super.postVisit(tree, p); } - public async visitStatement(statement: Statement, p: P): Promise { - const j = await super.visitStatement(statement, p) as Statement; - // TODO is it needed? - // const parent = this.cursor.parentTree()?.value; - // if (parent?.kind === J.Kind.Block && j.kind !== J.Kind.EnumValueSet) { - // if (!j.prefix.whitespace.includes("\n")) { - // return produce(j, draft => { - // draft.prefix.whitespace = "\n" + draft.prefix.whitespace; - // }); - // } - // } - return j; - } - protected async visitVariableDeclarations(multiVariable: J.VariableDeclarations, p: P): Promise { const v = await super.visitVariableDeclarations(multiVariable, p) as J.VariableDeclarations; const parent = this.cursor.parentTree()?.value; @@ -968,7 +937,11 @@ export class BlankLinesVisitor

extends JavaScriptVisitor

{ }); return super.visit(cu, p, cursor); } - if (tree.kind === J.Kind.MethodDeclaration) { + if (tree.kind === JS.Kind.StatementExpression && (tree as JS.StatementExpression).statement.kind == J.Kind.MethodDeclaration) { + tree = produce(tree as JS.StatementExpression, draft => { + this.ensurePrefixHasNewLine(draft); + }); + } else if (tree.kind === J.Kind.MethodDeclaration && this.cursor.value.kind != JS.Kind.StatementExpression) { tree = produce(tree as J.MethodDeclaration, draft => { this.ensurePrefixHasNewLine(draft); }); @@ -1060,8 +1033,6 @@ export class BlankLinesVisitor

extends JavaScriptVisitor

{ if (!draft.end.whitespace.includes("\n")) { draft.end.whitespace = draft.end.whitespace + "\n"; } - // TODO check if it's relevant to TS/JS - // draft.end = this.keepMaximumLines(draft.end, this.style.keepMaximum.beforeEndOfBlock); }); } @@ -1070,17 +1041,6 @@ export class BlankLinesVisitor

extends JavaScriptVisitor

{ this.keepMaximumBlankLines(e, this.style.keepMaximum.inCode); return e; } - // TODO check if it's relevant to TS/JS - // protected async visitNewClass(newClass: J.NewClass, p: P): Promise { - // const j = await super.visitNewClass(newClass, p) as J.NewClass; - // if (!j.body) return j; - // - // return produce(j, draft => { - // if (draft.body!.statements.length > 0) { - // draft.body!.statements[0] = this.minimumLines(draft.body!.statements[0].whitespace, this.style.minimum.afterFunction ?? 0); - // } - // }); - // } private keepMaximumBlankLines(node: Draft, max: number) { const whitespace = node.prefix.whitespace; @@ -1129,12 +1089,10 @@ export class BlankLinesVisitor

extends JavaScriptVisitor

{ } export class TabsAndIndentsVisitor

extends JavaScriptVisitor

{ - private readonly newline: string; private readonly singleIndent: string; constructor(private readonly tabsAndIndentsStyle: TabsAndIndentsStyle, private stopAfter?: Tree) { super(); - this.newline = "\n"; // TODO this should be configurable and come from some style too if (this.tabsAndIndentsStyle.useTabCharacter) { this.singleIndent = "\t"; @@ -1144,9 +1102,42 @@ export class TabsAndIndentsVisitor

extends JavaScriptVisitor

{ } protected async preVisit(tree: J, p: P): Promise { - const ret = await super.preVisit(tree, p); - let indentShouldIncrease = tree.kind === J.Kind.Block || tree.kind === J.Kind.Case; + let ret = await super.preVisit(tree, p)! as J; + + let indentShouldIncrease = + tree.kind === J.Kind.Block + || this.cursor.parent?.parent?.parent?.value.kind == J.Kind.Case + || (tree.kind === JS.Kind.StatementExpression && (tree as JS.StatementExpression).statement.kind == J.Kind.MethodDeclaration); + + const previousIndent = this.currentIndent; + + if (tree.kind === J.Kind.IfElse && this.cursor.getNearestMessage("else-indent") !== undefined) { + this.cursor.messages.set("indentToUse", this.cursor.getNearestMessage("else-indent")); + } else if (indentShouldIncrease) { + this.cursor.messages.set("indentToUse", this.currentIndent + this.singleIndent); + } + + if (tree.kind === J.Kind.IfElse && this.cursor.messages.get("else-indent") !== undefined) { + this.cursor.messages.set("indentToUse", this.cursor.messages.get("else-indent")); + this.cursor.messages.delete("else-indent"); + } + const relativeIndent: string = this.currentIndent; + + ret = produce(ret, draft => { + if (draft.prefix == undefined) { + draft.prefix = {kind: J.Kind.Space, comments: [], whitespace: ""}; + } + if (draft.prefix.whitespace.includes("\n")) { + draft.prefix.whitespace = this.combineIndent(draft.prefix.whitespace, relativeIndent); + } + if (draft.kind === J.Kind.Block) { + const block = draft as Draft as Draft; + const indentToUseInClosing = indentShouldIncrease ? previousIndent : relativeIndent; + block.end.whitespace = this.combineIndent(block.end.whitespace, indentToUseInClosing); + } + }); + indentShouldIncrease = false; // Increase indent for control structures with non-block bodies if (tree.kind === J.Kind.If) { const ifStmt = tree as J.If; @@ -1165,12 +1156,10 @@ export class TabsAndIndentsVisitor

extends JavaScriptVisitor

{ indentShouldIncrease = true; } } - - if (tree.kind === J.Kind.IfElse && this.cursor.getNearestMessage("else-indent") !== undefined) { - this.cursor.messages.set("indentToUse", this.cursor.getNearestMessage("else-indent")); - } else if (indentShouldIncrease) { + if (indentShouldIncrease) { this.cursor.messages.set("indentToUse", this.currentIndent + this.singleIndent); } + return ret; } @@ -1178,29 +1167,7 @@ export class TabsAndIndentsVisitor

extends JavaScriptVisitor

{ if (this.cursor?.getNearestMessage("stop") != null) { return tree as R; } - let ret = await super.visit(tree, p, parent) as R; - if (ret == undefined) { - return ret; - } - - if (tree.kind === J.Kind.IfElse && this.cursor.messages.get("else-indent") !== undefined) { - this.cursor.messages.set("indentToUse", this.cursor.messages.get("else-indent")); - this.cursor.messages.delete("else-indent"); - } - const relativeIndent: string = this.currentIndent; - - return produce(ret, draft => { - if (draft.prefix == undefined) { - draft.prefix = {kind: J.Kind.Space, comments: [], whitespace: ""}; - } - if (draft.prefix.whitespace.includes("\n")) { - draft.prefix.whitespace = this.combineIndent(draft.prefix.whitespace, relativeIndent); - } - if (draft.kind === J.Kind.Block) { - const block = draft as Draft as Draft; - block.end.whitespace = this.combineIndent(block.end.whitespace, relativeIndent); - } - }); + return await super.visit(tree, p, parent) as R; } public async visitLeftPadded(left: J.LeftPadded, p: P): Promise> { @@ -1216,16 +1183,7 @@ export class TabsAndIndentsVisitor

extends JavaScriptVisitor

{ } private get currentIndent(): string { - const indent = this.cursor.getNearestMessage("indentToUse"); - if (indent == undefined) { - const enclosingWhitespace = this.cursor.firstEnclosing((x: any): x is J => x.prefix && x.prefix.whitespace.includes("\n"))?.prefix.whitespace; - if (enclosingWhitespace) { - return enclosingWhitespace.substring(enclosingWhitespace.lastIndexOf("\n") + 1); - } else { - return ""; - } - } - return indent; + return this.cursor.getNearestMessage("indentToUse") ?? ""; } private combineIndent(oldWs: string, relativeIndent: string): string { diff --git a/rewrite-javascript/rewrite/src/javascript/parser.ts b/rewrite-javascript/rewrite/src/javascript/parser.ts index 7992dc89e4..1cd27f10a2 100644 --- a/rewrite-javascript/rewrite/src/javascript/parser.ts +++ b/rewrite-javascript/rewrite/src/javascript/parser.ts @@ -3131,12 +3131,15 @@ export class JavaScriptParserVisitor { } visitFunctionExpression(node: ts.FunctionExpression): JS.StatementExpression { + const delegate = this.mapFunctionDeclaration(node); return { kind: JS.Kind.StatementExpression, id: randomId(), - prefix: emptySpace, + prefix: delegate.prefix, markers: emptyMarkers, - statement: this.mapFunctionDeclaration(node) + statement: produce(delegate, draft => { + draft.prefix = emptySpace; + }) }; } diff --git a/rewrite-javascript/rewrite/test/javascript/format/blank-lines-visitor.test.ts b/rewrite-javascript/rewrite/test/javascript/format/blank-lines-visitor.test.ts index 821a98e6d5..16f1442e95 100644 --- a/rewrite-javascript/rewrite/test/javascript/format/blank-lines-visitor.test.ts +++ b/rewrite-javascript/rewrite/test/javascript/format/blank-lines-visitor.test.ts @@ -23,8 +23,10 @@ import {Style} from "../../../src"; type StyleCustomizer = (draft: Draft) => void; -function blankLines(customizer: StyleCustomizer): BlankLinesStyle { - return produce(IntelliJ.TypeScript.blankLines(), draft => customizer(draft)); +function blankLines(customizer?: StyleCustomizer): BlankLinesStyle { + return customizer + ? produce(IntelliJ.TypeScript.blankLines(), draft => customizer(draft)) + : IntelliJ.TypeScript.blankLines(); } describe('BlankLinesVisitor', () => { @@ -113,8 +115,7 @@ describe('BlankLinesVisitor', () => { }); test('simple un-minify', () => { - spec.recipe = fromVisitor(new BlankLinesVisitor(blankLines(draft => { - }))); + spec.recipe = fromVisitor(new BlankLinesVisitor(blankLines())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -130,8 +131,7 @@ describe('BlankLinesVisitor', () => { }); test('un-minify', () => { - spec.recipe = fromVisitor(new BlankLinesVisitor(blankLines(draft => { - }))); + spec.recipe = fromVisitor(new BlankLinesVisitor(blankLines())); return spec.rewriteRun( // @formatter:off //language=typescript diff --git a/rewrite-javascript/rewrite/test/javascript/format/format.test.ts b/rewrite-javascript/rewrite/test/javascript/format/format.test.ts index 97417d227d..9171c4b07d 100644 --- a/rewrite-javascript/rewrite/test/javascript/format/format.test.ts +++ b/rewrite-javascript/rewrite/test/javascript/format/format.test.ts @@ -185,4 +185,21 @@ describe('AutoformatVisitor', () => { `import {delta, gamma} from 'delta.js'`) // @formatter:on )}); + + test('anonymous function expression', () => { + return spec.rewriteRun( + // @formatter:off + //language=typescript + typescript( + `const fn = function () {return 99;};`, + ` + const fn = + function () { + return 99; + }; + ` + ) + // @formatter:on + ) + }); }); diff --git a/rewrite-javascript/rewrite/test/javascript/format/spaces-visitor.test.ts b/rewrite-javascript/rewrite/test/javascript/format/spaces-visitor.test.ts index bb4546a4b4..607adc8a46 100644 --- a/rewrite-javascript/rewrite/test/javascript/format/spaces-visitor.test.ts +++ b/rewrite-javascript/rewrite/test/javascript/format/spaces-visitor.test.ts @@ -21,8 +21,10 @@ import {MarkersKind, NamedStyles, randomId, Style} from "../../../src"; type StyleCustomizer = (draft: Draft) => void; -function spaces(customizer: StyleCustomizer): SpacesStyle { - return produce(IntelliJ.TypeScript.spaces(), draft => customizer(draft)); +function spaces(customizer?: StyleCustomizer): SpacesStyle { + return customizer + ? produce(IntelliJ.TypeScript.spaces(), draft => customizer(draft)) + : IntelliJ.TypeScript.spaces(); } describe('SpacesVisitor', () => { @@ -50,8 +52,7 @@ describe('SpacesVisitor', () => { }); test('spaces after export or import', () => { - spec.recipe = fromVisitor(new SpacesVisitor(spaces(draft => { - }))); + spec.recipe = fromVisitor(new SpacesVisitor(spaces())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -101,8 +102,7 @@ describe('SpacesVisitor', () => { }); test('await', () => { - spec.recipe = fromVisitor(new SpacesVisitor(spaces(draft => { - }))); + spec.recipe = fromVisitor(new SpacesVisitor(spaces())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -117,8 +117,7 @@ describe('SpacesVisitor', () => { }); test('types', () => { - spec.recipe = fromVisitor(new SpacesVisitor(spaces(draft => { - }))); + spec.recipe = fromVisitor(new SpacesVisitor(spaces())); return spec.rewriteRun( // @formatter:off //language=typescript diff --git a/rewrite-javascript/rewrite/test/javascript/format/tabs-and-indents-visitor.test.ts b/rewrite-javascript/rewrite/test/javascript/format/tabs-and-indents-visitor.test.ts index 2ee85cdaac..70e28aba10 100644 --- a/rewrite-javascript/rewrite/test/javascript/format/tabs-and-indents-visitor.test.ts +++ b/rewrite-javascript/rewrite/test/javascript/format/tabs-and-indents-visitor.test.ts @@ -21,16 +21,17 @@ import {Style} from "../../../src"; type StyleCustomizer = (draft: Draft) => void; -function tabsAndIndents(customizer: StyleCustomizer): TabsAndIndentsStyle { - return produce(IntelliJ.TypeScript.tabsAndIndents(), draft => customizer(draft)); +function tabsAndIndents(customizer?: StyleCustomizer): TabsAndIndentsStyle { + return customizer + ? produce(IntelliJ.TypeScript.tabsAndIndents(), draft => customizer(draft)) + : IntelliJ.TypeScript.tabsAndIndents(); } describe('TabsAndIndentsVisitor', () => { test('simple', () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => { - }))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -56,8 +57,7 @@ describe('TabsAndIndentsVisitor', () => { test('indent', () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => { - }))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -103,8 +103,7 @@ describe('TabsAndIndentsVisitor', () => { test("not so simple", () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => { - }))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -184,8 +183,7 @@ describe('TabsAndIndentsVisitor', () => { test('lambda', () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => { - }))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -219,8 +217,7 @@ describe('TabsAndIndentsVisitor', () => { test("type", () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => { - }))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -241,8 +238,7 @@ describe('TabsAndIndentsVisitor', () => { test("multi-line callback", () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => { - }))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -263,8 +259,7 @@ describe('TabsAndIndentsVisitor', () => { test("single-line callback with braces", () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => { - }))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -275,8 +270,7 @@ describe('TabsAndIndentsVisitor', () => { test("single-line callback without braces", () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => { - }))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -287,7 +281,7 @@ describe('TabsAndIndentsVisitor', () => { test("collapsed if/while", () => { const spec = new RecipeSpec() - spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents(draft => {}))); + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); return spec.rewriteRun( // @formatter:off //language=typescript @@ -328,4 +322,24 @@ describe('TabsAndIndentsVisitor', () => { // @formatter:on ) }) + + test('unify indentation', () => { + const spec = new RecipeSpec() + spec.recipe = fromVisitor(new TabsAndIndentsVisitor(tabsAndIndents())); + return spec.rewriteRun( + // @formatter:off + //language=typescript + typescript(` + const good = 136; + const great = 436; + const ideal = 504; + `, + ` + const good = 136; + const great = 436; + const ideal = 504; + `) + // @formatter:on + ) + }); }); diff --git a/rewrite-javascript/rewrite/test/javascript/parser/variable-declarations.test.ts b/rewrite-javascript/rewrite/test/javascript/parser/variable-declarations.test.ts index ef85ddd9f7..3b2218f301 100644 --- a/rewrite-javascript/rewrite/test/javascript/parser/variable-declarations.test.ts +++ b/rewrite-javascript/rewrite/test/javascript/parser/variable-declarations.test.ts @@ -252,4 +252,23 @@ describe('variable declaration mapping', () => { } `) )); + + test.each([ + "const c = function(): number { return 116; };", + "const c = 136;", + "const c = (1 > 0) ? 116 : 119;" + ])('double space: %s', (code) => + spec.rewriteRun({ + //language=javascript + ...typescript(code), + afterRecipe: (cu: JS.CompilationUnit) => { + expect(cu.statements).toHaveLength(1); + cu.statements.forEach(statement => { + const varDecl = statement.element as J.VariableDeclarations; + const initializer = varDecl.variables[0].element.initializer!; + expect(initializer.before.whitespace).toBe(" "); + expect(initializer.element.prefix.whitespace).toBe(" "); + }); + } + })); }); diff --git a/rewrite-javascript/src/integTest/java/org/openrewrite/javascript/DependencyWorkspaceTest.java b/rewrite-javascript/src/integTest/java/org/openrewrite/javascript/DependencyWorkspaceTest.java new file mode 100644 index 0000000000..92a98ab3a1 --- /dev/null +++ b/rewrite-javascript/src/integTest/java/org/openrewrite/javascript/DependencyWorkspaceTest.java @@ -0,0 +1,231 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Moderne Source Available License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://docs.moderne.io/licensing/moderne-source-available-license + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.javascript; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.openrewrite.Recipe; +import org.openrewrite.test.RewriteTest; + +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.assertj.core.api.Assertions.assertThat; + +class DependencyWorkspaceTest implements RewriteTest { + + @BeforeEach + void setUp() { + DependencyWorkspace.clearCache(); + } + + @Test + void cachesSamePackageJson() { + String packageJson = """ + { + "name": "test", + "dependencies": { + "lodash": "^4.17.21" + } + } + """; + + Path workspace1 = DependencyWorkspace.getOrCreateWorkspace(packageJson); + Path workspace2 = DependencyWorkspace.getOrCreateWorkspace(packageJson); + + // Should return the same cached workspace + assertThat(workspace1).isEqualTo(workspace2); + assertThat(Files.exists(workspace1.resolve("node_modules"))).isTrue(); + assertThat(Files.exists(workspace1.resolve("package.json"))).isTrue(); + } + + @Test + void createsDifferentWorkspacesForDifferentPackageJson() { + String packageJson1 = """ + { + "name": "test1", + "dependencies": { + "lodash": "^4.17.21" + } + } + """; + + String packageJson2 = """ + { + "name": "test2", + "dependencies": { + "axios": "^1.0.0" + } + } + """; + + Path workspace1 = DependencyWorkspace.getOrCreateWorkspace(packageJson1); + Path workspace2 = DependencyWorkspace.getOrCreateWorkspace(packageJson2); + + // Should create different workspaces + assertThat(workspace1).isNotEqualTo(workspace2); + assertThat(Files.exists(workspace1.resolve("node_modules"))).isTrue(); + assertThat(Files.exists(workspace2.resolve("node_modules"))).isTrue(); + } + + @Test + void reusesWorkspaceAfterCacheClear() { + String packageJson = """ + { + "name": "test", + "dependencies": { + "lodash": "^4.17.21" + } + } + """; + + Path workspace1 = DependencyWorkspace.getOrCreateWorkspace(packageJson); + + // Clear in-memory cache + DependencyWorkspace.clearCache(); + + // Should still reuse the workspace from disk + Path workspace2 = DependencyWorkspace.getOrCreateWorkspace(packageJson); + + assertThat(workspace1).isEqualTo(workspace2); + assertThat(Files.exists(workspace2.resolve("node_modules"))).isTrue(); + } + + @Test + void npmIntegrationWithSymlink(@TempDir Path tempDir) throws Exception { + rewriteRun( + spec -> spec.recipe(new NoOpRecipe()), + Assertions.npm(tempDir, + Assertions.packageJson(""" + { + "name": "test-project", + "dependencies": { + "lodash": "^4.17.21" + } + } + """), + Assertions.javascript(""" + import _ from 'lodash'; + console.log(_.VERSION); + """) + ) + ); + + // Verify symlink was created + Path nodeModules = tempDir.resolve("node_modules"); + assertThat(Files.isSymbolicLink(nodeModules)).isTrue(); + assertThat(Files.exists(nodeModules)).isTrue(); + assertThat(Files.exists(nodeModules.resolve("lodash"))).isTrue(); + } + + @Test + void lruCacheEvictsOldEntries() { + // This test verifies LRU eviction, but we can't easily test with MAX_CACHE_SIZE (100) + // entries because npm install is slow. Instead, we verify the cache mechanism works + // by checking that recently used entries are retained. + + String packageJson1 = """ + { + "name": "test1", + "dependencies": { + "lodash": "^4.17.21" + } + } + """; + + String packageJson2 = """ + { + "name": "test2", + "dependencies": { + "axios": "^1.0.0" + } + } + """; + + // Create two workspaces + Path workspace1 = DependencyWorkspace.getOrCreateWorkspace(packageJson1); + Path workspace2 = DependencyWorkspace.getOrCreateWorkspace(packageJson2); + + // Access workspace1 again (should move it to most recently used) + Path workspace1Again = DependencyWorkspace.getOrCreateWorkspace(packageJson1); + + // Both should still be cached (we're well under MAX_CACHE_SIZE) + assertThat(workspace1).isEqualTo(workspace1Again); + assertThat(Files.exists(workspace1)).isTrue(); + assertThat(Files.exists(workspace2)).isTrue(); + } + + @Test + void initializesFromDiskOnStartup() { + String packageJson = """ + { + "name": "test-init", + "dependencies": { + "lodash": "^4.17.21" + } + } + """; + + // Create a workspace + Path workspace = DependencyWorkspace.getOrCreateWorkspace(packageJson); + assertThat(Files.exists(workspace.resolve("node_modules"))).isTrue(); + + // Clear the in-memory cache (simulating a JVM restart) + DependencyWorkspace.clearCache(); + + // The workspace should still be reused from disk + Path workspaceAfterClear = DependencyWorkspace.getOrCreateWorkspace(packageJson); + assertThat(workspaceAfterClear).isEqualTo(workspace); + assertThat(Files.exists(workspaceAfterClear.resolve("node_modules"))).isTrue(); + } + + @Test + void createsWorkspaceWhenBaseDirectoryDoesNotExist() throws Exception { + // This test verifies the fix for the issue where WORKSPACE_BASE might not exist + // when createTempDirectory is called. The fix ensures the base directory is + // created before attempting to create temp directories within it. + + String packageJson = """ + { + "name": "test-base-dir", + "dependencies": { + "lodash": "^4.17.21" + } + } + """; + + // Even if the base directory doesn't exist initially, the workspace should be created + Path workspace = DependencyWorkspace.getOrCreateWorkspace(packageJson); + + assertThat(workspace).isNotNull(); + assertThat(Files.exists(workspace)).isTrue(); + assertThat(Files.exists(workspace.resolve("node_modules"))).isTrue(); + assertThat(Files.exists(workspace.resolve("package.json"))).isTrue(); + } + + private static class NoOpRecipe extends Recipe { + @Override + public String getDisplayName() { + return "No-op recipe"; + } + + @Override + public String getDescription() { + return "Does nothing, used for testing."; + } + } +} diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/Assertions.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/Assertions.java index 2d4944ea75..582e34a320 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/Assertions.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/Assertions.java @@ -39,61 +39,38 @@ private Assertions() { } public static SourceSpecs npm(Path relativeTo, SourceSpecs... sources) { - // Second pass: run npm install if needed - boolean alreadyInstalled = false; + String packageJsonContent = null; - // First pass: write package.json files + // First pass: find package.json content and write it to relativeTo for (SourceSpecs multiSpec : sources) { if (multiSpec instanceof SourceSpec) { SourceSpec spec = (SourceSpec) multiSpec; Path sourcePath = spec.getSourcePath(); if (sourcePath != null && "package.json".equals(sourcePath.toFile().getName())) { + packageJsonContent = spec.getBefore(); try { Path packageJson = relativeTo.resolve(sourcePath); - if (Files.exists(packageJson)) { - // If relativeTo is a non-transient directory we can optimize not having - // to do npm install if the package.json hasn't changed. - if (new String(Files.readAllBytes(packageJson), StandardCharsets.UTF_8).equals(spec.getBefore())) { - alreadyInstalled = true; - continue; - } - } - Files.write(packageJson, requireNonNull(spec.getBefore()).getBytes(StandardCharsets.UTF_8)); + Files.write(packageJson, requireNonNull(packageJsonContent).getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { throw new UncheckedIOException(e); } + break; } } } - for (SourceSpecs multiSpec : sources) { - if (multiSpec instanceof SourceSpec) { - SourceSpec spec = (SourceSpec) multiSpec; - if (!alreadyInstalled && spec.getParser() instanceof JavaScriptParser.Builder) { - // Execute npm install to ensure dependencies are available - // First check if package.json exists - Path packageJsonPath = relativeTo.resolve("package.json"); - if (!Files.exists(packageJsonPath)) { - // Skip npm install if no package.json exists - alreadyInstalled = true; - continue; - } - - try { - ProcessBuilder pb = new ProcessBuilder("npm", "install"); - pb.directory(relativeTo.toFile()); - pb.inheritIO(); - Process process = pb.start(); - int exitCode = process.waitFor(); - if (exitCode != 0) { - throw new RuntimeException("npm install failed with exit code: " + exitCode + " in directory: " + relativeTo.toFile().getAbsolutePath()); - } - } catch (IOException | InterruptedException e) { - throw new RuntimeException("Failed to run npm install in directory: " + relativeTo.toFile().getAbsolutePath(), e); - } + // Second pass: get or create cached workspace and symlink node_modules + if (packageJsonContent != null) { + Path workspaceDir = DependencyWorkspace.getOrCreateWorkspace(packageJsonContent); + Path nodeModulesSource = workspaceDir.resolve("node_modules"); + Path nodeModulesTarget = relativeTo.resolve("node_modules"); - alreadyInstalled = true; + try { + if (Files.exists(nodeModulesSource) && !Files.exists(nodeModulesTarget)) { + Files.createSymbolicLink(nodeModulesTarget, nodeModulesSource); } + } catch (IOException e) { + throw new UncheckedIOException("Failed to create symlink for node_modules", e); } } diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/DependencyWorkspace.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/DependencyWorkspace.java new file mode 100644 index 0000000000..465d4f99e0 --- /dev/null +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/DependencyWorkspace.java @@ -0,0 +1,233 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Moderne Source Available License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://docs.moderne.io/licensing/moderne-source-available-license + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.javascript; + +import lombok.experimental.UtilityClass; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Base64; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.Map; + +import static java.util.Collections.synchronizedMap; + +/** + * Manages workspace directories for JavaScript/TypeScript compilation with dependencies. + * Creates cached workspaces with package.json and installed node_modules to enable + * proper type attribution and dependency resolution. + */ +@UtilityClass +class DependencyWorkspace { + private static final Path WORKSPACE_BASE = Paths.get( + System.getProperty("java.io.tmpdir"), + "openrewrite-js-workspaces" + ); + private static final int MAX_CACHE_SIZE = 100; + private static final Map cache = synchronizedMap( + new LinkedHashMap(16, 0.75f, true) { + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + if (size() > MAX_CACHE_SIZE) { + // Clean up the evicted workspace directory + cleanupDirectory(eldest.getValue()); + return true; + } + return false; + } + } + ); + + static { + // Pre-populate cache with existing workspaces from disk + initializeCacheFromDisk(); + } + + /** + * Gets or creates a workspace directory for the given package.json content. + * Workspaces are cached by content hash to avoid repeated npm installs. + * + * @param packageJsonContent The complete package.json file content + * @return Path to the workspace directory containing node_modules + */ + static Path getOrCreateWorkspace(String packageJsonContent) { + String hash = hashContent(packageJsonContent); + + // Check in-memory cache + Path cached = cache.get(hash); + if (cached != null && isWorkspaceValid(cached)) { + return cached; + } + + // Check disk cache (for cross-JVM reuse) + Path workspaceDir = WORKSPACE_BASE.resolve(hash); + if (isWorkspaceValid(workspaceDir)) { + cache.put(hash, workspaceDir); + return workspaceDir; + } + + // Create new workspace + try { + // Ensure workspace base directory exists + // createDirectories is idempotent and safe to call even if directory exists + Files.createDirectories(WORKSPACE_BASE); + + // Use temp directory for atomic creation + Path tempDir = Files.createTempDirectory(WORKSPACE_BASE, hash + ".tmp-"); + + try { + // Write package.json + Files.write( + tempDir.resolve("package.json"), + packageJsonContent.getBytes(StandardCharsets.UTF_8) + ); + + // Run npm install + ProcessBuilder pb = new ProcessBuilder("npm", "install", "--silent"); + pb.directory(tempDir.toFile()); + pb.inheritIO(); + Process process = pb.start(); + int exitCode = process.waitFor(); + + if (exitCode != 0) { + throw new RuntimeException("npm install failed with exit code: " + exitCode); + } + + // Move to final location (atomic on POSIX systems) + try { + Files.move(tempDir, workspaceDir); + } catch (IOException e) { + // If move fails, another thread might have created it + if (isWorkspaceValid(workspaceDir)) { + // Use the other thread's workspace + cleanupDirectory(tempDir); + } else { + throw e; + } + } + + cache.put(hash, workspaceDir); + return workspaceDir; + + } catch (Exception e) { + // Clean up temp directory on failure + cleanupDirectory(tempDir); + throw e; + } + + } catch (IOException e) { + throw new UncheckedIOException("Failed to create dependency workspace", e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException("npm install was interrupted", e); + } + } + + /** + * Generates a hash from package.json content for caching. + */ + private static String hashContent(String content) { + try { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] hash = digest.digest(content.getBytes(StandardCharsets.UTF_8)); + return Base64.getUrlEncoder() + .withoutPadding() + .encodeToString(hash) + .substring(0, 16) + .replace('/', '_') + .replace('+', '-'); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("SHA-256 algorithm not available", e); + } + } + + /** + * Checks if a workspace is valid (has node_modules directory). + */ + private static boolean isWorkspaceValid(Path workspaceDir) { + return Files.exists(workspaceDir) && + Files.isDirectory(workspaceDir.resolve("node_modules")) && + Files.exists(workspaceDir.resolve("package.json")); + } + + /** + * Cleans up a directory, ignoring errors. + */ + private static void cleanupDirectory(Path dir) { + try { + if (Files.exists(dir)) { + Files.walk(dir) + .sorted(Comparator.reverseOrder()) // Delete files before directories + .forEach(path -> { + try { + Files.delete(path); + } catch (IOException e) { + // Ignore + } + }); + } + } catch (IOException e) { + // Ignore cleanup errors + } + } + + /** + * Clears the in-memory cache. Useful for testing. + */ + static void clearCache() { + cache.clear(); + } + + /** + * Initializes the cache by discovering existing valid workspaces from disk. + * This allows reuse of workspaces across JVM restarts and ensures proper + * LRU eviction even for pre-existing workspaces. + */ + private static void initializeCacheFromDisk() { + try { + if (!Files.exists(WORKSPACE_BASE)) { + return; + } + + Files.list(WORKSPACE_BASE) + .filter(Files::isDirectory) + .filter(dir -> !dir.getFileName().toString().contains(".tmp-")) // Skip temp dirs + .filter(DependencyWorkspace::isWorkspaceValid) + .sorted((a, b) -> { + // Sort by last modified time (oldest first) + // This way oldest workspaces will be evicted first when we hit the limit + try { + return Files.getLastModifiedTime(a).compareTo(Files.getLastModifiedTime(b)); + } catch (IOException e) { + return 0; + } + }) + .forEach(workspaceDir -> { + String hash = workspaceDir.getFileName().toString(); + cache.put(hash, workspaceDir); + }); + } catch (IOException e) { + // Ignore - cache will be empty and workspaces will be created as needed + } + } +} diff --git a/rewrite-kotlin/build.gradle.kts b/rewrite-kotlin/build.gradle.kts index 40de319d73..0c317de414 100644 --- a/rewrite-kotlin/build.gradle.kts +++ b/rewrite-kotlin/build.gradle.kts @@ -1,8 +1,10 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("org.openrewrite.build.language-library") - kotlin("jvm") version "1.9.25" + kotlin("jvm") version "2.2.21" } val kotlinVersion = "1.9.25" @@ -13,9 +15,8 @@ dependencies { implementation(project(":rewrite-java")) - implementation(platform(kotlin("bom", kotlinVersion))) - implementation(kotlin("compiler-embeddable")) - implementation(kotlin("stdlib")) + implementation(kotlin("compiler-embeddable", kotlinVersion)) + implementation(kotlin("stdlib", kotlinVersion)) testImplementation("org.junit-pioneer:junit-pioneer:latest.release") testImplementation(project(":rewrite-test")) @@ -35,5 +36,9 @@ java { } tasks.withType().configureEach { - kotlinOptions.jvmTarget = if (name.contains("Test")) "21" else "1.8" + compilerOptions { + apiVersion = KotlinVersion.KOTLIN_1_9 + languageVersion = KotlinVersion.KOTLIN_1_9 + jvmTarget.set(if (name.contains("Test")) JvmTarget.JVM_21 else JvmTarget.JVM_1_8) + } } diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java index fa928415de..b4145f96c8 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java @@ -412,7 +412,7 @@ public MavenMetadata downloadMetadata(GroupArtifactVersion gav, @Nullable Resolv break; } String href = responseBody.substring(start, end).trim(); - if (href.endsWith("/")) { + if (!href.startsWith("../") && href.endsWith("/")) { //Only look for hrefs that have directories (the directory names are the versions) versions.add(hrefToVersion(href, uri)); } diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java index 2ee8b6ffbc..f7f3d678ce 100755 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java @@ -22,7 +22,6 @@ import org.intellij.lang.annotations.Language; import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; @@ -616,6 +615,18 @@ void deriveMetaDataFromFileRepository(@TempDir Path repoPath) throws Exception { assertThat(metaData.getVersioning().getVersions()).hasSize(3).containsAll(List.of("1.0.0", "1.1.0", "2.0.0")); } + @Test + void deriveMetaDataFromHtmlBasedRepository() throws Exception { + MavenRepository repository = MavenRepository.builder() + .id("html-based") + .uri("https://central.sonatype.com/repository/maven-snapshots") + .knownToExist(true) + .deriveMetadataIfMissing(true) + .build(); + assertThrows(MavenDownloadingException.class, () -> + new MavenPomDownloader(emptyMap(), ctx).downloadMetadata(new GroupArtifact("does.definitely.not", "exist"), null, List.of(repository))); + } + @SuppressWarnings("ConstantConditions") @Test void mergeMetadata() throws Exception { diff --git a/rewrite-test/build.gradle.kts b/rewrite-test/build.gradle.kts index d84e2524cd..6927438f18 100644 --- a/rewrite-test/build.gradle.kts +++ b/rewrite-test/build.gradle.kts @@ -3,12 +3,11 @@ plugins { } dependencies { - api(platform("org.junit:junit-bom:5.13.3")) + api(platform("org.junit:junit-bom:5.14.0")) api(project(":rewrite-core")) compileOnly("io.micrometer:micrometer-core:latest.release") api("org.junit.jupiter:junit-jupiter-api") api("org.junit.jupiter:junit-jupiter-params") - api("org.junit.platform:junit-platform-launcher") implementation("org.assertj:assertj-core:3.+") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-csv") @@ -17,5 +16,4 @@ dependencies { testImplementation(project(":rewrite-groovy")) testRuntimeOnly("org.antlr:antlr4-runtime:4.13.2") - testRuntimeOnly(project(":rewrite-java-21")) } diff --git a/rewrite-test/src/test/java/org/openrewrite/test/internal/RewriteTestTest.java b/rewrite-test/src/test/java/org/openrewrite/test/internal/RewriteTestTest.java index 3a77221231..749797726e 100644 --- a/rewrite-test/src/test/java/org/openrewrite/test/internal/RewriteTestTest.java +++ b/rewrite-test/src/test/java/org/openrewrite/test/internal/RewriteTestTest.java @@ -34,7 +34,6 @@ import static java.util.Collections.emptyList; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.openrewrite.java.Assertions.java; import static org.openrewrite.test.SourceSpecs.text; @SuppressWarnings("UnnecessarySemicolon") @@ -141,21 +140,6 @@ void allowScannerEdit() { text("foo") ); } - - @Test - void allowNonWhitespaceInWhitespace() { - rewriteRun( - spec -> spec.typeValidationOptions(TypeValidation.all().allowNonWhitespaceInWhitespace(true)), - java( - """ - import java.util.List;; - interface A { - List getList(); - } - """ - ) - ); - } } @EqualsAndHashCode(callSuper = false) diff --git a/settings.gradle.kts b/settings.gradle.kts index 7b3e720885..774ad8f788 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -23,7 +23,6 @@ val allProjects = listOf( "rewrite-java-tck", "rewrite-java-test", "rewrite-java-lombok", - "rewrite-java-17", // remove this when rewrite recipe gradle plugin moves to 21 "rewrite-java-21", "rewrite-java-25", "rewrite-javascript", @@ -57,7 +56,13 @@ gradle.allprojects { resolutionStrategy.dependencySubstitution { allProjects .minus(includedProjects) - .minus(arrayOf("rewrite-bom", "rewrite-gradle-tooling-model:model", "rewrite-gradle-tooling-model:plugin")) + .minus( + arrayOf( + "rewrite-bom", + "rewrite-gradle-tooling-model:model", + "rewrite-gradle-tooling-model:plugin" + ) + ) .forEach { substitute(project(":$it")) .using(module("org.openrewrite:$it:latest.integration"))