Showing preview only (441K chars total). Download the full file or copy to clipboard to get everything.
Repository: openrewrite/rewrite-maven-plugin
Branch: main
Commit: 4985717de28e
Files: 168
Total size: 378.1 KB
Directory structure:
gitextract_bkmjst1t/
├── .claude/
│ └── settings.json
├── .editorconfig
├── .github/
│ ├── dependabot.yml
│ └── workflows/
│ ├── bump-snapshots.yml
│ ├── ci.yml
│ ├── pages.yml
│ ├── publish.yml
│ ├── repository-backup.yml
│ └── stale.yml
├── .gitignore
├── .mvn/
│ ├── develocity.xml
│ ├── extensions.xml
│ ├── licenseHeader.txt
│ └── wrapper/
│ └── maven-wrapper.properties
├── .sdkmanrc
├── CLAUDE.md
├── LICENSE/
│ └── apache-license-v2.txt
├── README.md
├── mvnw
├── mvnw.cmd
├── pom.xml
├── rewrite.yml
├── src/
│ ├── main/
│ │ └── java/
│ │ └── org/
│ │ └── openrewrite/
│ │ └── maven/
│ │ ├── AbstractRewriteBaseRunMojo.java
│ │ ├── AbstractRewriteDryRunMojo.java
│ │ ├── AbstractRewriteMojo.java
│ │ ├── AbstractRewriteRunMojo.java
│ │ ├── ArtifactResolver.java
│ │ ├── ConfigurableRewriteMojo.java
│ │ ├── LogLevel.java
│ │ ├── MavenLoggingMeterRegistry.java
│ │ ├── MavenLoggingResolutionEventListener.java
│ │ ├── MavenMojoProjectParser.java
│ │ ├── MavenPomCacheBuilder.java
│ │ ├── MeterRegistryProvider.java
│ │ ├── RecipeCsvGenerateMojo.java
│ │ ├── RewriteDiscoverMojo.java
│ │ ├── RewriteDryRunMojo.java
│ │ ├── RewriteDryRunNoForkMojo.java
│ │ ├── RewriteRunMojo.java
│ │ ├── RewriteRunNoForkMojo.java
│ │ ├── RewriteTypeTableMojo.java
│ │ ├── SanitizedMarkerPrinter.java
│ │ └── package-info.java
│ └── test/
│ ├── java/
│ │ └── org/
│ │ └── openrewrite/
│ │ └── maven/
│ │ ├── AbstractRewriteMojoTest.java
│ │ ├── BasicIT.java
│ │ ├── DiscoverNoActiveRecipeIT.java
│ │ ├── KotlinIT.java
│ │ ├── MavenCLIExtra.java
│ │ ├── MavenMojoProjectParserIsExcludedTest.java
│ │ ├── MavenMojoProjectParserTest.java
│ │ ├── RecipeCsvGenerateIT.java
│ │ ├── RewriteDiscoverIT.java
│ │ ├── RewriteDryRunIT.java
│ │ ├── RewriteRunIT.java
│ │ ├── RewriteRunParallelIT.java
│ │ ├── RewriteTypeTableIT.java
│ │ └── jupiter/
│ │ └── extension/
│ │ ├── GitITExtension.java
│ │ └── GitJupiterExtension.java
│ ├── resources/
│ │ ├── .gitkeep
│ │ └── junit-platform.properties
│ └── resources-its/
│ └── org/
│ └── openrewrite/
│ └── maven/
│ ├── BasicIT/
│ │ ├── groupid_artifactid_should_be_ok/
│ │ │ └── pom.xml
│ │ ├── null_check_profile_activation/
│ │ │ ├── pom.xml
│ │ │ └── settings.xml
│ │ ├── resolves_maven_properties_from_user_provided_system_properties/
│ │ │ └── pom.xml
│ │ ├── resolves_settings/
│ │ │ ├── pom.xml
│ │ │ └── settings-user.xml
│ │ └── snapshot_ok/
│ │ └── pom.xml
│ ├── DiscoverNoActiveRecipeIT/
│ │ └── single_project/
│ │ └── pom.xml
│ ├── KotlinIT/
│ │ ├── kotlin_in_src_main_java/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── MyClass.kt
│ │ └── kotlin_in_src_main_test/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── test/
│ │ └── java/
│ │ └── sample/
│ │ └── MyTest.kt
│ ├── RecipeCsvGenerateIT/
│ │ ├── generates_csv_from_java_recipe/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── org/
│ │ │ └── openrewrite/
│ │ │ └── test/
│ │ │ └── SampleJavaRecipe.java
│ │ └── generates_csv_from_yaml_recipe/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ └── resources/
│ │ └── META-INF/
│ │ └── rewrite/
│ │ └── rewrite.yml
│ ├── RewriteDiscoverIT/
│ │ ├── RecipeLookup/
│ │ │ ├── rewrite_discover_detail/
│ │ │ │ └── pom.xml
│ │ │ ├── rewrite_discover_recipe_lookup_case_insensitive/
│ │ │ │ └── pom.xml
│ │ │ └── rewrite_discover_recursion/
│ │ │ └── pom.xml
│ │ ├── rewrite_discover_default/
│ │ │ └── pom.xml
│ │ ├── rewrite_discover_multi_module/
│ │ │ ├── a/
│ │ │ │ └── pom.xml
│ │ │ ├── b/
│ │ │ │ └── pom.xml
│ │ │ └── pom.xml
│ │ └── rewrite_discover_rewrite_yml/
│ │ ├── pom.xml
│ │ └── rewrite.yml
│ ├── RewriteDryRunIT/
│ │ ├── fail_on_dry_run/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── BadSpacing.java
│ │ ├── multi_module_project/
│ │ │ ├── a/
│ │ │ │ ├── pom.xml
│ │ │ │ └── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── sample/
│ │ │ │ ├── MyInterface.java
│ │ │ │ └── SimplifyBooleanSample.java
│ │ │ ├── b/
│ │ │ │ ├── pom.xml
│ │ │ │ └── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── sample/
│ │ │ │ └── EmptyBlockSample.java
│ │ │ ├── pom.xml
│ │ │ └── rewrite.yml
│ │ ├── no_plugin_in_pom/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── SampleTest.java
│ │ ├── recipe_order/
│ │ │ ├── pom.xml
│ │ │ ├── rewrite.yml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ ├── EmptyBlockSample.java
│ │ │ └── SimplifyBooleanSample.java
│ │ └── single_project/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── sample/
│ │ ├── EmptyBlockSample.java
│ │ └── SimplifyBooleanSample.java
│ ├── RewriteRunIT/
│ │ ├── basedir_resource_no_plaintext_leak/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ ├── main/
│ │ │ │ └── java/
│ │ │ │ └── sample/
│ │ │ │ └── Main.java
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── MainTest.java
│ │ ├── checkstyle_inline_rules/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── SimplifyBooleanSample.java
│ │ ├── cloud_suitability_project/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── resource/
│ │ │ └── some.jks
│ │ ├── command_line_options/
│ │ │ └── pom.xml
│ │ ├── command_line_options_json/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── SomeClass.java
│ │ ├── container_masks/
│ │ │ ├── Containerfile
│ │ │ ├── Dockerfile
│ │ │ ├── build.dockerfile
│ │ │ ├── containerfile.build
│ │ │ ├── pom.xml
│ │ │ └── rewrite.yml
│ │ ├── datatable_export/
│ │ │ ├── pom.xml
│ │ │ └── rewrite.yml
│ │ ├── java_compiler_plugin_project/
│ │ │ ├── parent/
│ │ │ │ └── pom.xml
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── SimplifyBooleanSample.java
│ │ ├── java_upgrade_project/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── MyInterface.java
│ │ ├── lombok_jdk25_linkage_error/
│ │ │ ├── .mvn/
│ │ │ │ └── jvm.config
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ ├── main/
│ │ │ │ └── java/
│ │ │ │ └── sample/
│ │ │ │ └── App.java
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── AppTest.java
│ │ ├── multi_main_source_sets_project/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ ├── additional-main/
│ │ │ │ └── java/
│ │ │ │ └── sample/
│ │ │ │ └── AdditionalMainClass.java
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── MainClass.java
│ │ ├── multi_module_project/
│ │ │ ├── a/
│ │ │ │ ├── pom.xml
│ │ │ │ └── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── sample/
│ │ │ │ ├── MyInterface.java
│ │ │ │ └── SimplifyBooleanSample.java
│ │ │ ├── b/
│ │ │ │ ├── pom.xml
│ │ │ │ └── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── sample/
│ │ │ │ └── EmptyBlockSample.java
│ │ │ ├── pom.xml
│ │ │ └── rewrite.yml
│ │ ├── multi_module_resources/
│ │ │ ├── a/
│ │ │ │ ├── pom.xml
│ │ │ │ └── src/
│ │ │ │ └── main/
│ │ │ │ └── resources/
│ │ │ │ └── example.xml
│ │ │ ├── pom.xml
│ │ │ └── rewrite.yml
│ │ ├── multi_source_sets_project/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ ├── integration-test/
│ │ │ │ └── java/
│ │ │ │ └── sample/
│ │ │ │ └── IntegrationTest.java
│ │ │ └── test/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── RegularTest.java
│ │ ├── plaintext_masks/
│ │ │ ├── .in-root
│ │ │ ├── from-default-list.py
│ │ │ ├── in-root.ignored
│ │ │ ├── pom.xml
│ │ │ ├── rewrite.yml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ ├── Dummy.java
│ │ │ └── in-src.ext
│ │ ├── recipe_project/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── ThrowingRecipe.java
│ │ └── single_project/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── sample/
│ │ ├── EmptyBlockSample.java
│ │ └── SimplifyBooleanSample.java
│ ├── RewriteRunParallelIT/
│ │ └── multi_module_project/
│ │ ├── a/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ ├── MyInterface.java
│ │ │ └── SimplifyBooleanSample.java
│ │ ├── b/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── sample/
│ │ │ └── EmptyBlockSample.java
│ │ ├── pom.xml
│ │ └── rewrite.yml
│ └── RewriteTypeTableIT/
│ └── typetable_default/
│ └── pom.xml
└── suppressions.xml
================================================
FILE CONTENTS
================================================
================================================
FILE: .claude/settings.json
================================================
{
"permissions": {
"allow": [
"Bash(./gradlew:*)",
"Bash(cat:*)",
"Bash(echo:*)",
"Bash(find:*)",
"Bash(gh:*)",
"Bash(git:*)",
"Bash(grep:*)",
"Bash(javac:*)",
"Bash(mv:*)",
"Bash(npm test:*)",
"Bash(rg:*)",
"Bash(rm:*)",
"Bash(timeout:*)",
"WebFetch(domain:github.com)",
"mcp__github__get_issue",
"mcp__github__get_issue_comments",
"mcp__github__get_pull_request",
"mcp__github__get_pull_request_comments",
"mcp__idea__find_files_by_name_substring",
"mcp__idea__get_file_text_by_path",
"mcp__idea__get_open_in_editor_file_path",
"mcp__idea__get_open_in_editor_file_text",
"mcp__idea__get_selected_in_editor_text",
"mcp__idea__list_directory_tree_in_folder",
"mcp__idea__list_files_in_folder",
"mcp__idea__open_file_in_editor",
"mcp__idea__replace_selected_text",
"mcp__idea__replace_specific_text",
"mcp__idea__search_in_files_content"
],
"deny": []
}
}
================================================
FILE: .editorconfig
================================================
root = true
[*]
insert_final_newline = true
trim_trailing_whitespace = true
[src/test*/java/**.java]
indent_size = 4
ij_continuation_indent_size = 2
================================================
FILE: .github/dependabot.yml
================================================
---
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
commit-message:
prefix: "chore(ci)"
- package-ecosystem: maven
directory: /
schedule:
interval: weekly
commit-message:
prefix: "chore(ci)"
ignore:
- dependency-name: "com.puppycrawl.tools:checkstyle"
================================================
FILE: .github/workflows/bump-snapshots.yml
================================================
---
name: bump-snapshots
on:
workflow_dispatch: {}
schedule:
- cron: 0 11 * * THU
jobs:
bump-snapshots:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: maven
server-id: ossrh
settings-path: ${{ github.workspace }}
- name: configure-git-user
run: |
git config user.email "team@moderne.io"
git config user.name "team-moderne[bot]"
- name: bump-rewrite-properties-to-snapshots
run: |
./mvnw versions:update-properties -DincludeProperties=rewrite.version,rewrite-polyglot.version -DallowSnapshots=true
git diff-index --quiet HEAD pom.xml || (git commit -m "Bump rewrite.version property" pom.xml && git push origin main)
================================================
FILE: .github/workflows/ci.yml
================================================
---
name: ci
on:
push:
branches:
- main
tags-ignore:
- "*"
pull_request:
branches:
- main
workflow_dispatch: {}
schedule:
- cron: 0 17 * * *
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.gradle_enterprise_cache_username }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.gradle_enterprise_cache_password }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.gradle_enterprise_access_key }}
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: maven
server-id: ossrh
settings-path: ${{ github.workspace }}
server-username: SONATYPE_USERNAME
server-password: SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_SIGNING_KEY }}
gpg-passphrase: SONATYPE_SIGNING_PASSWORD
- name: validate-develocity-access-key
run: |
if [ -n "$DEVELOCITY_ACCESS_KEY" ] && ! echo "$DEVELOCITY_ACCESS_KEY" | grep -q '='; then
echo "DEVELOCITY_ACCESS_KEY is malformed (missing server-host= prefix), unsetting"
echo "DEVELOCITY_ACCESS_KEY=" >> $GITHUB_ENV
fi
- name: build
run: ./mvnw --show-version --no-transfer-progress --update-snapshots clean verify --file=pom.xml --fail-at-end --batch-mode -Dstyle.color=always
- name: publish-snapshots
if: github.event_name != 'pull_request'
run: ./mvnw --show-version --no-transfer-progress --settings=${{ github.workspace }}/settings.xml --file=pom.xml --batch-mode -Dstyle.color=always --activate-profiles=sign-artifacts clean deploy -DskipTests
env:
GITHUB_TOKEN: ${{ github.token }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_TOKEN }}
SONATYPE_SIGNING_PASSWORD: ${{ secrets.OSSRH_SIGNING_PASSWORD }}
- name: slack-notification
if: failure() && github.event_name == 'schedule' && (github.repository_owner == 'openrewrite' || github.repository_owner == 'moderneinc')
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661
continue-on-error: true
env:
SLACK_WEBHOOK: ${{ secrets.OPS_GITHUB_ACTIONS_WEBHOOK }}
MSG_MINIMAL: true
SLACK_MESSAGE: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
SLACK_USERNAME: ${{ github.repository }} CI failure
SLACK_COLOR: failure
SLACK_FOOTER: ''
================================================
FILE: .github/workflows/pages.yml
================================================
# Simple workflow for deploying static content to GitHub Pages
name: Deploy plugin docs to Pages
on:
push:
tags:
- v*
workflow_dispatch: {}
workflow_run:
workflows: ["publish"]
types:
- completed
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
pages:
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: maven
- name: site
run: ./mvnw --show-version --no-transfer-progress --update-snapshots clean site --file=pom.xml --fail-at-end --batch-mode -Dstyle.color=always -Ddependency-check.skip=true
- uses: actions/configure-pages@v6
- uses: actions/upload-pages-artifact@v5
with:
path: target/site
- uses: actions/deploy-pages@v5
================================================
FILE: .github/workflows/publish.yml
================================================
---
name: publish
on:
workflow_dispatch:
inputs:
version:
description: 'Project version to set before releasing (e.g. 6.33.0-SNAPSHOT). Leave empty to release the current version.'
required: false
type: string
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: maven
server-id: ossrh
settings-path: ${{ github.workspace }}
server-username: SONATYPE_USERNAME
server-password: SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_SIGNING_KEY }}
gpg-passphrase: SONATYPE_SIGNING_PASSWORD
- name: configure-git-user
run: |
git config user.email "team@moderne.io"
git config user.name "team-moderne[bot]"
- name: set-project-version
if: ${{ inputs.version != '' }}
run: ./mvnw versions:set -DnewVersion=${{ inputs.version }} -DgenerateBackupFiles=false
- name: bump-rewrite-properties-to-releases
run: |
./mvnw versions:update-properties -DincludeProperties=rewrite.version,rewrite-polyglot.version -DallowDowngrade=true
git diff-index --quiet HEAD pom.xml || git commit -m "Bump rewrite.version property" pom.xml && rm -f pom.xml.versionsBackup
- name: publish-release
run: ./mvnw --show-version --settings=${{ github.workspace }}/settings.xml --file=pom.xml --activate-profiles=sign-artifacts,release,release-automation help:active-profiles release:prepare release:perform --batch-mode -Dstyle.color=always
env:
GITHUB_TOKEN: ${{ github.token }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_TOKEN }}
SONATYPE_SIGNING_PASSWORD: ${{ secrets.OSSRH_SIGNING_PASSWORD }}
- name: github-release
if: ${{ success() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export tag=$(git describe --tags --abbrev=0)
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${tag#v}" \
--generate-notes
- name: rollback
if: ${{ failure() }}
run: ./mvnw --show-version --settings=${{github.workspace}}/settings.xml --file=pom.xml --activate-profiles=sign-artifacts,release,release-automation help:active-profiles release:rollback --batch-mode -Dstyle.color=always
env:
GITHUB_TOKEN: ${{ github.token }}
- name: bump-rewrite-properties-to-snapshots
run: |
./mvnw versions:update-properties -DincludeProperties=rewrite.version,rewrite-polyglot.version -DallowSnapshots=true
git diff-index --quiet HEAD pom.xml || (git commit -m "Bump rewrite.version property" pom.xml && git push origin main && rm -f pom.xml.versionsBackup)
================================================
FILE: .github/workflows/repository-backup.yml
================================================
---
name: repository-backup
on:
workflow_dispatch: {}
schedule:
- cron: 0 17 * * *
concurrency:
group: backup-${{ github.ref }}
cancel-in-progress: false
jobs:
repository-backup:
uses: openrewrite/gh-automation/.github/workflows/repository-backup.yml@main
secrets:
bucket_mirror_target: ${{ secrets.S3_GITHUB_REPOSITORY_BACKUPS_BUCKET_NAME }}
bucket_access_key_id: ${{ secrets.S3_GITHUB_REPOSITORY_BACKUPS_ACCESS_KEY_ID }}
bucket_secret_access_key: ${{ secrets.S3_GITHUB_REPOSITORY_BACKUPS_SECRET_ACCESS_KEY }}
================================================
FILE: .github/workflows/stale.yml
================================================
---
name: stale
on:
workflow_dispatch: {}
schedule:
- cron: 36 4 * * 1
jobs:
build:
uses: openrewrite/gh-automation/.github/workflows/stale.yml@main
================================================
FILE: .gitignore
================================================
build/
target/
ry/
release.properties
pom.xml.releaseBackup
pom.xml.versionsBackup
.idea/
*.iml
.classpath
.project
.settings
.vscode/
.mvn/.develocity/
# Moderne CLI
.moderne/*
!.moderne/context/
================================================
FILE: .mvn/develocity.xml
================================================
<develocity>
<server>
<url>https://ge.openrewrite.org/</url>
</server>
<buildScan>
<publishing>
<onlyIf><![CDATA[!buildResult.failures.empty]]></onlyIf>
</publishing>
<capture>
<fileFingerprints>true</fileFingerprints>
</capture>
</buildScan>
<buildCache>
<local>
<storeEnabled>true</storeEnabled>
</local>
<remote>
<storeEnabled>#{isTrue(env['CI'])}</storeEnabled>
<server>
<credentials>
<username>#{env['GRADLE_ENTERPRISE_CACHE_USERNAME']}</username>
<password>#{env['GRADLE_ENTERPRISE_CACHE_PASSWORD']}</password>
</credentials>
</server>
</remote>
</buildCache>
</develocity>
================================================
FILE: .mvn/extensions.xml
================================================
<extensions>
<extension>
<groupId>com.gradle</groupId>
<artifactId>develocity-maven-extension</artifactId>
<version>2.2.1</version>
</extension>
</extensions>
================================================
FILE: .mvn/licenseHeader.txt
================================================
Copyright ${year} the original author or authors.
<p>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
<p>
https://www.apache.org/licenses/LICENSE-2.0
<p>
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.
================================================
FILE: .mvn/wrapper/maven-wrapper.properties
================================================
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
================================================
FILE: .sdkmanrc
================================================
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=21.0.10-tem
================================================
FILE: CLAUDE.md
================================================
<!-- prethink-context -->
## Moderne Prethink Context
This repository contains pre-analyzed context generated by [Moderne Prethink](https://docs.moderne.io/user-documentation/recipes/prethink). Prethink extracts structured knowledge from codebases to help you work more effectively. The context files in `.moderne/context/` contain analyzed information about this codebase.
**IMPORTANT: Before exploring source code for architecture, dependency, or data flow questions:**
1. ALWAYS check `.moderne/context/` files FIRST
2. Do NOT perform broad codebase exploration (e.g., spawning Explore agents, searching multiple source files) unless CSV context is insufficient
3. NEVER read entire CSV files - use SQL queries to retrieve only the rows you need
**IMPORTANT: Prethink context is cheap to read — source code exploration is expensive. Always read MORE prethink context rather than less. The "do not explore broadly" rule applies to source code, NOT to prethink context files.**
For cross-cutting questions (data flow, deletion, dependencies between services),
ALWAYS query these context files in parallel on the first turn:
- `architecture.md` — system diagram and component overview
- `data-assets.csv` — entity fields and data model
- `database-connections.csv` — which services own which tables
- `service-endpoints.csv` — relevant API endpoints
- `messaging-connections.csv` — Kafka/async event flows
- `external-service-calls.csv` — cross-service HTTP calls
Do NOT stop after reading a single context file when others are clearly relevant.
### Available Context
| Context | Description | Details |
|---------|-------------|--------|
| Architecture | FINOS CALM architecture diagram | [`architecture.md`](.moderne/context/architecture.md) |
| Class Quality Metrics | Per-class cohesion, coupling, and complexity measurements | [`class-quality-metrics.md`](.moderne/context/class-quality-metrics.md) |
| Code Smells | Detected design problems with severity and evidence | [`code-smells.md`](.moderne/context/code-smells.md) |
| Coding Conventions | Naming patterns, import organization, and coding style | [`coding-conventions.md`](.moderne/context/coding-conventions.md) |
| Dependencies | Project dependencies including transitive dependencies | [`dependencies.md`](.moderne/context/dependencies.md) |
| Error Handling | Exception handling strategies and logging patterns | [`error-handling.md`](.moderne/context/error-handling.md) |
| Method Quality Metrics | Per-method complexity and quality measurements | [`method-quality-metrics.md`](.moderne/context/method-quality-metrics.md) |
| Package Quality Metrics | Per-package coupling, stability, and dependency cycle analysis | [`package-quality-metrics.md`](.moderne/context/package-quality-metrics.md) |
| Project Identity | Build system coordinates, names, and module structure | [`project-identity.md`](.moderne/context/project-identity.md) |
| Test Coverage | Maps test methods to implementation methods they verify | [`test-coverage.md`](.moderne/context/test-coverage.md) |
| Test Gaps | Public non-trivial methods lacking test coverage | [`test-gaps.md`](.moderne/context/test-gaps.md) |
| Test Quality | Test quality issues that may cause flakiness or silent failures | [`test-quality.md`](.moderne/context/test-quality.md) |
| Token Estimates | Estimated input tokens for method comprehension | [`token-estimates.md`](.moderne/context/token-estimates.md) |
### Querying Context Files
For .md context files: Read the full file in a single view call. Never grep it progressively.
For .csv context files: Query with DuckDB, SQLite, or grep (from most to least preference).
Upfront parallel reads: At the start of any architecture question, read all relevant context files in parallel rather than discovering which ones matter through iteration.
Use SQL to query CSV files efficiently. This returns only matching rows instead of loading entire files. Try these in order based on availability:
#### Option 1: DuckDB (Preferred)
DuckDB can query CSV files directly with no setup:
```bash
# Find all POST endpoints
duckdb -c "SELECT * FROM '.moderne/context/service-endpoints.csv' WHERE \"HTTP method\" = 'POST'"
# Find method descriptions containing a keyword
duckdb -c "SELECT \"Class name\", Signature, Description FROM '.moderne/context/method-descriptions.csv' WHERE Description LIKE '%authentication%'"
# Find tests for a specific class
duckdb -c "SELECT \"Test method\", \"Test summary\" FROM '.moderne/context/test-mapping.csv' WHERE \"Implementation class\" LIKE '%OrderService%'"
```
#### Option 2: SQLite
Import CSV into memory and query (available on most systems):
```bash
sqlite3 :memory: -cmd ".mode csv" -cmd ".import .moderne/context/service-endpoints.csv endpoints" \
"SELECT * FROM endpoints WHERE [HTTP method] = 'POST'"
```
#### Option 3: Grep (Last Resort)
If SQL tools are unavailable, use grep. Note this loads more content into context:
```bash
grep -i "POST" .moderne/context/service-endpoints.csv
```
**Note:** Column names with spaces require quoting - use double quotes in DuckDB (`"HTTP method"`) or square brackets in SQLite (`[HTTP method]`).
### Usage Pattern
1. Read the `.md` file to understand the schema and available columns
2. Query the `.csv` with DuckDB or SQLite to get only the rows you need
3. Only explore source if the context doesn't answer the question
When citing Moderne Prethink context, mention Moderne Prethink as the source (e.g., "Based on the architecture context from Moderne Prethink..." or "Based on the test coverage mapping from Prethink, this method is tested by...").
<!-- /prethink-context -->
================================================
FILE: LICENSE/apache-license-v2.txt
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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.
================================================
FILE: README.md
================================================
<p align="center">
<a href="https://docs.openrewrite.org">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/openrewrite/rewrite/raw/main/doc/logo-oss-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://github.com/openrewrite/rewrite/raw/main/doc/logo-oss-light.svg">
<img alt="OpenRewrite Logo" src="https://github.com/openrewrite/rewrite/raw/main/doc/logo-oss-light.svg" width='600px'>
</picture>
</a>
</p>
<div align="center">
<h1>rewrite-maven-plugin</h1>
</div>
<div align="center">
<!-- Keep the gap above this line, otherwise they won't render correctly! -->
[](https://github.com/openrewrite/rewrite-maven-plugin/actions/workflows/ci.yml)
[](https://mvnrepository.com/artifact/org.openrewrite.maven/rewrite-maven-plugin)
[](https://github.com/openrewrite/.github/blob/main/CONTRIBUTING.md)
</div>
## What is this?
This project provides a Maven plugin that applies [Rewrite](https://github.com/openrewrite/rewrite) checking and fixing tasks as build tasks, one of several possible workflows for propagating change across an organization's source code.
## Getting started
This `README` may not have the most up-to-date documentation. For the most up-to-date documentation and reference guides, see:
- [Auto-generated maven plugin documentation](https://openrewrite.github.io/rewrite-maven-plugin/plugin-info.html)
- [Maven Plugin Configuration](https://docs.openrewrite.org/reference/rewrite-maven-plugin)
- [OpenRewrite Quickstart Guide](https://docs.openrewrite.org/running-recipes/getting-started)
To configure, add the plugin to your POM:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version><!-- latest version here --></version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.format.AutoFormat</recipe>
</activeRecipes>
</configuration>
</plugin>
</plugins>
</build>
</project>
```
If wanting to leverage recipes from other dependencies:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version><!-- latest version here --></version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.testing.junit5.JUnit5BestPractices</recipe>
<recipe>org.openrewrite.github.ActionsSetupJavaAdoptOpenJDKToTemurin</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-testing-frameworks</artifactId>
<version><!-- latest dependency version here --></version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-github-actions</artifactId>
<version><!-- latest dependency version here --></version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
```
To get started, try `mvn rewrite:help`, `mvn rewrite:discover`, `mvn rewrite:dryRun`, `mvn rewrite:run`, among other plugin goals.
See the [Maven Plugin Configuration](https://docs.openrewrite.org/reference/rewrite-maven-plugin) documentation for full configuration and usage options.
### Snapshots
To use the latest `-SNAPSHOT` version, add a `<pluginRepositories>` entry for OSSRH snapshots. For example:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<!-- Use whichever version is latest at the time of reading. This number is a placeholder. -->
<version>4.17.0-SNAPSHOT</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.logging.slf4j.Log4j2ToSlf4j</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-testing-frameworks</artifactId>
<!-- Use whichever version is latest at the time of reading. This number is a placeholder. -->
<version>1.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>ossrh-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots</url>
</pluginRepository>
</pluginRepositories>
</project>
```
## Notes for developing and testing this plugin
This plugin uses the [`Maven Integration Testing Framework Extension`](https://github.com/khmarbaise/maven-it-extension) for tests.
All tests can be run from the command line using:
```sh
./mvnw verify
```
If you're looking for more information on the output from a test, try checking the `target/maven-it/**/*IT/**` directory contents after running the tests. It will contain the project state output, including maven logs, etc. Check the [`Integration Testing Framework Users Guide`](https://khmarbaise.github.io/maven-it-extension/itf-documentation/usersguide/usersguide.html) for information, too. It's good.
## Contributing
We appreciate all types of contributions. See the [contributing guide](https://github.com/openrewrite/.github/blob/main/CONTRIBUTING.md) for detailed instructions on how to get started.
### Resource guides
- https://blog.soebes.io/posts/2020/08/2020-08-17-itf-part-i/
- https://carlosvin.github.io/posts/creating-custom-maven-plugin/en/#_dependency_injection
- https://developer.okta.com/blog/2019/09/23/tutorial-build-a-maven-plugin
- https://medium.com/swlh/step-by-step-guide-to-developing-a-custom-maven-plugin-b6e3a0e09966
================================================
FILE: mvnw
================================================
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.3.2
#
# Optional ENV vars
# -----------------
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
# MVNW_REPOURL - repo url base for downloading maven distribution
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
# ----------------------------------------------------------------------------
set -euf
[ "${MVNW_VERBOSE-}" != debug ] || set -x
# OS specific support.
native_path() { printf %s\\n "$1"; }
case "$(uname)" in
CYGWIN* | MINGW*)
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
native_path() { cygpath --path --windows "$1"; }
;;
esac
# set JAVACMD and JAVACCMD
set_java_home() {
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
if [ -n "${JAVA_HOME-}" ]; then
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACCMD="$JAVA_HOME/jre/sh/javac"
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACCMD="$JAVA_HOME/bin/javac"
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
return 1
fi
fi
else
JAVACMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v java
)" || :
JAVACCMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v javac
)" || :
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
return 1
fi
fi
}
# hash string like Java String::hashCode
hash_string() {
str="${1:-}" h=0
while [ -n "$str" ]; do
char="${str%"${str#?}"}"
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
str="${str#?}"
done
printf %x\\n $h
}
verbose() { :; }
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
die() {
printf %s\\n "$1" >&2
exit 1
}
trim() {
# MWRAPPER-139:
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
# Needed for removing poorly interpreted newline sequences when running in more
# exotic environments such as mingw bash on Windows.
printf "%s" "${1}" | tr -d '[:space:]'
}
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
while IFS="=" read -r key value; do
case "${key-}" in
distributionUrl) distributionUrl=$(trim "${value-}") ;;
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
esac
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
case "${distributionUrl##*/}" in
maven-mvnd-*bin.*)
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
*)
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
distributionPlatform=linux-amd64
;;
esac
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
;;
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
esac
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
distributionUrlName="${distributionUrl##*/}"
distributionUrlNameMain="${distributionUrlName%.*}"
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
exec_maven() {
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
}
if [ -d "$MAVEN_HOME" ]; then
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
exec_maven "$@"
fi
case "${distributionUrl-}" in
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
esac
# prepare tmp dir
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
trap clean HUP INT TERM EXIT
else
die "cannot create temp dir"
fi
mkdir -p -- "${MAVEN_HOME%/*}"
# Download and Install Apache Maven
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
verbose "Downloading from: $distributionUrl"
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
# select .zip or .tar.gz
if ! command -v unzip >/dev/null; then
distributionUrl="${distributionUrl%.zip}.tar.gz"
distributionUrlName="${distributionUrl##*/}"
fi
# verbose opt
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
# normalize http auth
case "${MVNW_PASSWORD:+has-password}" in
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
esac
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
verbose "Found wget ... using wget"
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
verbose "Found curl ... using curl"
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
elif set_java_home; then
verbose "Falling back to use Java to download"
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
cat >"$javaSource" <<-END
public class Downloader extends java.net.Authenticator
{
protected java.net.PasswordAuthentication getPasswordAuthentication()
{
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
}
public static void main( String[] args ) throws Exception
{
setDefault( new Downloader() );
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
}
}
END
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
verbose " - Compiling Downloader.java ..."
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
verbose " - Running Downloader.java ..."
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
fi
# If specified, validate the SHA-256 sum of the Maven distribution zip file
if [ -n "${distributionSha256Sum-}" ]; then
distributionSha256Result=false
if [ "$MVN_CMD" = mvnd.sh ]; then
echo "Checksum validation is not supported for maven-mvnd." >&2
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
elif command -v sha256sum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
elif command -v shasum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
fi
if [ $distributionSha256Result = false ]; then
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
exit 1
fi
fi
# unzip and move
if command -v unzip >/dev/null; then
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
else
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
fi
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
clean || :
exec_maven "$@"
================================================
FILE: mvnw.cmd
================================================
<# : batch portion
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. 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,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.3.2
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
@SET __MVNW_CMD__=
@SET __MVNW_ERROR__=
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
@SET PSModulePath=
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
)
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
@SET __MVNW_PSMODULEP_SAVE=
@SET __MVNW_ARG0_NAME__=
@SET MVNW_USERNAME=
@SET MVNW_PASSWORD=
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
@echo Cannot start maven from wrapper >&2 && exit /b 1
@GOTO :EOF
: end batch / begin powershell #>
$ErrorActionPreference = "Stop"
if ($env:MVNW_VERBOSE -eq "true") {
$VerbosePreference = "Continue"
}
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
if (!$distributionUrl) {
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
}
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
"maven-mvnd-*" {
$USE_MVND = $true
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
$MVN_CMD = "mvnd.cmd"
break
}
default {
$USE_MVND = $false
$MVN_CMD = $script -replace '^mvnw','mvn'
break
}
}
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
if ($env:MVNW_REPOURL) {
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
}
$distributionUrlName = $distributionUrl -replace '^.*/',''
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
if ($env:MAVEN_USER_HOME) {
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
}
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
exit $?
}
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
}
# prepare tmp dir
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
trap {
if ($TMP_DOWNLOAD_DIR.Exists) {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
}
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
# Download and Install Apache Maven
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
Write-Verbose "Downloading from: $distributionUrl"
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
$webclient = New-Object System.Net.WebClient
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
# If specified, validate the SHA-256 sum of the Maven distribution zip file
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
if ($distributionSha256Sum) {
if ($USE_MVND) {
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
}
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
}
}
# unzip and move
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
try {
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
} catch {
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
Write-Error "fail to move MAVEN_HOME"
}
} finally {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
================================================
FILE: pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.40.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>rewrite-maven-plugin</name>
<description>Eliminate technical debt. At build time.</description>
<url>https://openrewrite.github.io/rewrite-maven-plugin/</url>
<inceptionYear>2020</inceptionYear>
<organization>
<name>Moderne, Inc.</name>
<url>https://moderne.io/</url>
</organization>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>Jonathan Schneider</name>
<url>https://github.com/jkschneider</url>
<id>jkschneider</id>
</developer>
</developers>
<prerequisites>
<maven>3.3.1</maven>
</prerequisites>
<scm>
<connection>scm:git:https://github.com/openrewrite/rewrite-maven-plugin.git</connection>
<developerConnection>${developerConnectionUrl}</developerConnection>
<url>https://github.com/openrewrite/rewrite-maven-plugin/tree/main</url>
<tag>HEAD</tag>
</scm>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/openrewrite/rewrite-maven-plugin/issues</url>
</issueManagement>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://central.sonatype.com/repository/maven-snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
<properties>
<!-- Pinned versions, as RELEASE would make it into the published pom.xml -->
<rewrite.version>8.82.0-SNAPSHOT</rewrite.version>
<rewrite-polyglot.version>2.11.0-SNAPSHOT</rewrite-polyglot.version>
<!-- using 'ssh' url scheme by default, which assumes a human is performing git operations leveraging an ssh key -->
<developerConnectionUrl>scm:git:ssh://git@github.com/openrewrite/rewrite-maven-plugin.git
</developerConnectionUrl>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<!-- a profile in the profiles section sets the maven.compiler.release property on supported JREs -->
<maven.compiler.testRelease>17</maven.compiler.testRelease>
<!-- dependencies and plugins -->
<jackson-bom.version>2.21.3</jackson-bom.version>
<rocksdbjni.version>8.8.1</rocksdbjni.version>
<itf-maven.version>0.13.1</itf-maven.version>
<maven-dependencies.version>3.9.15</maven-dependencies.version>
<maven-release-plugin.version>3.3.1</maven-release-plugin.version>
<maven-plugin-tools.version>3.15.2</maven-plugin-tools.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>6.0.3</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-bom</artifactId>
<version>3.27.7</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-bom</artifactId>
<version>${rewrite.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- Pin plexus-utils to fix GHSA-6fmv-xxpf-w3cw -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.6.1</version>
</dependency>
<!-- Transitive through Plexus, but with provided scope -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<version>4.0.0-rc-1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-xml</artifactId>
<version>4.0.0-rc-5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-xml-impl</artifactId>
<version>4.0.0-beta-5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java-8</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java-11</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java-17</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java-21</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java-25</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-groovy</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-kotlin</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-xml</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-maven</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-polyglot</artifactId>
<version>${rewrite-polyglot.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.16.5</version>
</dependency>
<dependency>
<groupId>org.rocksdb</groupId>
<artifactId>rocksdbjni</artifactId>
<version>${rocksdbjni.version}</version>
</dependency>
<dependency>
<!-- plugin interfaces and base classes -->
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven-dependencies.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- needed when injecting the Maven Project into a plugin -->
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-dependencies.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>${maven-dependencies.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven-dependencies.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- annotations used to describe the plugin metadata -->
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${maven-plugin-tools.version}</version>
<scope>provided</scope>
</dependency>
<!-- JUnit Jupiter, and using itf-jupiter-extension to get itf support for executing everything as Maven tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-jupiter-extension</artifactId>
<version>${itf-maven.version}</version>
<scope>test</scope>
</dependency>
<!-- Using assertj as well as custom assertions of AssertJ provided by itf-assertj -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-assertj</artifactId>
<version>${itf-maven.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-extension-maven</artifactId>
<version>${itf-maven.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<!-- for consuming upstream openrewrite snapshot artifacts from ossrh during development -->
<id>ossrh-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
</testResource>
<testResource>
<directory>src/test/resources-its</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.6.2</version>
<configuration>
<rules>
<requireJavaVersion>
<version>17</version>
</requireJavaVersion>
<requireMavenVersion>
<version>3.9.6</version>
</requireMavenVersion>
</rules>
</configuration>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>4.0.0-M16</version>
</plugin>
<!-- testing-related plugins -->
<plugin>
<groupId>com.soebes.itf.jupiter.extension</groupId>
<artifactId>itf-maven-plugin</artifactId>
<version>${itf-maven.version}</version>
<configuration>
<!-- Prevents adding files like .DS_Store during resource-its filtering -->
<addDefaultExcludes>true</addDefaultExcludes>
</configuration>
<executions>
<execution>
<id>installing</id>
<phase>pre-integration-test</phase>
<goals>
<goal>install</goal>
<goal>resources-its</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.5</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- essential "core" plugins -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>${maven-plugin-tools.version}</version>
<configuration>
<goalPrefix>rewrite</goalPrefix>
<requiredJavaVersion>8</requiredJavaVersion>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.9.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-helpmojo</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
<configuration>
<compilerArgs>
<arg>-Xlint:deprecation</arg>
<arg>-Xlint:unchecked</arg>
</compilerArgs>
<proc>none</proc>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.12.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>javadoc</goal>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>aggregate</goal>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- release-related plugins -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<releaseProfiles>release</releaseProfiles>
<tagNameFormat>v@{project.version}</tagNameFormat>
<!-- "SemVerVersionPolicy" causes maven-release to increment the MINOR version when calculating the next development version. -->
<!-- For example, if the current version is 4.6.3-SNAPSHOT, then we release, this will release 4.6.3, then set the next development version to 4.7.0-SNAPSHOT -->
<!-- By contrast, the "default" policy increments the PATCH version. -->
<projectVersionPolicyId>SemVerVersionPolicy</projectVersionPolicyId>
</configuration>
<dependencies>
<dependency>
<!-- needed only for the SemVerVersionPolicy policy -->
<groupId>org.apache.maven.release</groupId>
<artifactId>maven-release-semver-policy</artifactId>
<version>${maven-release-plugin.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<!-- 4.6 is the last version supporting Java 8 -->
<version>4.6</version>
<configuration>
<licenseSets>
<licenseSet>
<header>.mvn/licenseHeader.txt</header>
<excludes>
<exclude>*.xml</exclude>
<exclude>suppressions.xml</exclude>
<exclude>**/README.md</exclude>
<exclude>**/.sdkmanrc</exclude>
<exclude>LICENSE/apache-license-v2.txt</exclude>
<exclude>src/test/resources-its/**</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/main/resources/**</exclude>
<exclude>.moderne/</exclude>
<exclude>.mvn/</exclude>
</excludes>
</licenseSet>
</licenseSets>
</configuration>
<dependencies>
<dependency>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin-git</artifactId>
<!-- make sure you use the same version as license-maven-plugin -->
<version>4.6</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>first</id>
<goals>
<goal>format</goal>
</goals>
<phase>process-sources</phase>
</execution>
<execution>
<id>second</id>
<goals>
<goal>check</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>12.2.2</version>
<configuration>
<nvdApiKey>${env.NVD_API_KEY}</nvdApiKey>
<failBuildOnCVSS>9</failBuildOnCVSS>
<suppressionFiles>
<suppressionFile>suppressions.xml</suppressionFile>
</suppressionFiles>
<retireJsAnalyzerEnabled>false</retireJsAnalyzerEnabled>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-report-plugin</artifactId>
<version>${maven-plugin-tools.version}</version>
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<id>sign-artifacts</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.8</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<!-- Prevent gpg from using pinentry programs. Fixes: gpg: signing failed: Inappropriate ioctl for device -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
<extensions>true</extensions>
<configuration>
<!-- https://help.sonatype.com/repomanager2/staging-releases/configuring-your-project-for-deployment -->
<serverId>ossrh</serverId>
<nexusUrl>https://ossrh-staging-api.central.sonatype.com/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<stagingProgressTimeoutMinutes>20</stagingProgressTimeoutMinutes>
<keepStagingRepositoryOnCloseRuleFailure>true</keepStagingRepositoryOnCloseRuleFailure>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<!-- save time by skipping the tests during deploy -->
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
<profile>
<!-- generally should be stacked after the 'release' profile, but in some cases we may want to discern between a ci-cd system performing the release; and if the situation requires it, a human performing the release -->
<id>release-automation</id>
<properties>
<!-- automation via the maven-release-plugin uses a GITHUB_TOKEN which requires 'https' urls for git pushing -->
<developerConnectionUrl>scm:git:https://github.com/openrewrite/rewrite-maven-plugin.git
</developerConnectionUrl>
</properties>
</profile>
<profile>
<!-- set maven.compiler.release on JRE 9+ -->
<id>avoid-maven-compiler-warnings</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<maven.compiler.release>8</maven.compiler.release>
</properties>
</profile>
</profiles>
</project>
================================================
FILE: rewrite.yml
================================================
#
# Copyright 2020 the original author or authors.
# <p>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# <p>
# https://www.apache.org/licenses/LICENSE-2.0
# <p>
# 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.
#
#./mvnw org.openrewrite.maven:rewrite-maven-plugin:LATEST:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-static-analysis:RELEASE -Drewrite.activeRecipes=org.openrewrite.recipes.rewrite.OpenRewriteRecipeBestPracticesSubset
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.recipes.rewrite.OpenRewriteRecipeBestPracticesSubset
displayName: OpenRewrite best practices
description: Best practices for OpenRewrite recipe development.
recipeList:
- org.openrewrite.java.OrderImports:
removeUnused: true
- org.openrewrite.java.format.EmptyNewlineAtEndOfFile
- org.openrewrite.java.format.RemoveTrailingWhitespace
- org.openrewrite.maven.BestPractices
# - org.openrewrite.staticanalysis.OperatorWrap:
# wrapOption: EOL
# - org.openrewrite.staticanalysis.CommonStaticAnalysis
# - org.openrewrite.staticanalysis.CompareEnumsWithEqualityOperator
# - org.openrewrite.staticanalysis.MissingOverrideAnnotation
# - org.openrewrite.staticanalysis.RemoveSystemOutPrintln
# - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables
# - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields
# - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods
================================================
FILE: src/main/java/org/openrewrite/maven/AbstractRewriteBaseRunMojo.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import io.micrometer.core.instrument.Metrics;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.config.CompositeRecipe;
import org.openrewrite.config.DeclarativeRecipe;
import org.openrewrite.config.Environment;
import org.openrewrite.config.RecipeDescriptor;
import org.openrewrite.internal.InMemoryLargeSourceSet;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.java.tree.J;
import org.openrewrite.kotlin.tree.K;
import org.openrewrite.marker.*;
import org.openrewrite.style.NamedStyles;
import org.openrewrite.xml.tree.Xml;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
public abstract class AbstractRewriteBaseRunMojo extends AbstractRewriteMojo {
@Parameter(property = "rewrite.exportDatatables", defaultValue = "false")
protected boolean exportDatatables;
@Parameter(property = "rewrite.options")
@Nullable
protected LinkedHashSet<String> options;
/**
* The level used to log changes performed by recipes.
*/
@Parameter(property = "rewrite.recipeChangeLogLevel", defaultValue = "WARN")
protected LogLevel recipeChangeLogLevel;
protected void log(LogLevel logLevel, CharSequence content) {
switch (logLevel) {
case DEBUG:
getLog().debug(content);
break;
case INFO:
getLog().info(content);
break;
case WARN:
getLog().warn(content);
break;
case ERROR:
getLog().error(content);
break;
}
}
/**
* Attempt to determine the root of the git repository for the given project.
* Many Gradle builds co-locate the build root with the git repository root, but that is not required.
* If no git repository can be located in any folder containing the build, the build root will be returned.
*/
protected Path repositoryRoot() {
Path buildRoot = getBuildRoot();
Path maybeBaseDir = buildRoot;
while (maybeBaseDir != null && !Files.exists(maybeBaseDir.resolve(".git"))) {
maybeBaseDir = maybeBaseDir.getParent();
}
if (maybeBaseDir == null) {
return buildRoot;
}
return maybeBaseDir;
}
protected ResultsContainer listResults(ExecutionContext ctx) throws MojoExecutionException, MojoFailureException {
try (MeterRegistryProvider meterRegistryProvider = new MeterRegistryProvider(getLog(), null)) {
if (!Metrics.globalRegistry.getRegistries().contains(meterRegistryProvider.registry())) {
Metrics.addRegistry(meterRegistryProvider.registry());
}
Path repositoryRoot = repositoryRoot();
getLog().info(String.format("Using active recipe(s) %s", getActiveRecipes()));
getLog().info(String.format("Using active styles(s) %s", getActiveStyles()));
if (getActiveRecipes().isEmpty()) {
return new ResultsContainer(repositoryRoot, emptyList());
}
URLClassLoader recipeArtifactCoordinatesClassloader = getRecipeArtifactCoordinatesClassloader();
if (recipeArtifactCoordinatesClassloader != null) {
merge(getClass().getClassLoader(), recipeArtifactCoordinatesClassloader);
}
Environment env = environment(recipeArtifactCoordinatesClassloader);
Recipe recipe = env.activateRecipes(getActiveRecipes());
if ("org.openrewrite.Recipe$Noop".equals(recipe.getName())) {
getLog().warn("No recipes were activated." +
" Activate a recipe with <activeRecipes><recipe>com.fully.qualified.RecipeClassName</recipe></activeRecipes> in this plugin's <configuration> in your pom.xml," +
" or on the command line with -Drewrite.activeRecipes=com.fully.qualified.RecipeClassName");
return new ResultsContainer(repositoryRoot, emptyList());
}
if (options != null && !options.isEmpty()) {
configureRecipeOptions(recipe, options);
}
getLog().info("Validating active recipes...");
List<Validated<Object>> validations = new ArrayList<>();
recipe.validateAll(ctx, validations);
List<Validated.Invalid<Object>> failedValidations = validations.stream().map(Validated::failures)
.flatMap(Collection::stream).collect(toList());
if (!failedValidations.isEmpty()) {
failedValidations.forEach(failedValidation -> getLog().error(
String.format(
"Recipe validation error in %s for property %s: %s",
recipe.getName(),
failedValidation.getProperty(),
failedValidation.getMessage()),
failedValidation.getException()));
if (failOnInvalidActiveRecipes) {
throw new MojoExecutionException("Recipe validation errors detected as part of one or more activeRecipe(s). Please check error logs.");
}
getLog().error("Recipe validation errors detected as part of one or more activeRecipe(s). Execution will continue regardless.");
}
LargeSourceSet sourceSet = loadSourceSet(repositoryRoot, env, ctx);
List<Result> results = runRecipe(recipe, sourceSet, ctx);
Metrics.removeRegistry(meterRegistryProvider.registry());
return new ResultsContainer(repositoryRoot, results);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Dependency resolution required", e);
}
}
private static void configureRecipeOptions(Recipe recipe, Set<String> options) throws MojoExecutionException {
if (recipe instanceof CompositeRecipe ||
recipe instanceof DeclarativeRecipe ||
recipe instanceof Recipe.DelegatingRecipe ||
!recipe.getRecipeList().isEmpty()) {
// We don't (yet) support configuring potentially nested recipes, as recipes might occur more than once,
// and setting the same value twice might lead to unexpected behavior.
throw new MojoExecutionException(
"Recipes containing other recipes can not be configured from the command line: " + recipe);
}
Map<String, String> optionValues = new HashMap<>();
for (String option : options) {
String[] parts = option.split("=", 2);
if (parts.length == 2) {
optionValues.put(parts[0], parts[1]);
}
}
for (Field field : recipe.getClass().getDeclaredFields()) {
String removed = optionValues.remove(field.getName());
updateOption(recipe, field, removed);
}
if (!optionValues.isEmpty()) {
throw new MojoExecutionException(
String.format("Unknown recipe options: %s", String.join(", ", optionValues.keySet())));
}
}
private static void updateOption(Recipe recipe, Field field, @Nullable String optionValue) throws MojoExecutionException {
Object convertedOptionValue = convertOptionValue(field.getName(), optionValue, field.getType());
if (convertedOptionValue == null) {
return;
}
try {
field.setAccessible(true);
field.set(recipe, convertedOptionValue);
field.setAccessible(false);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new MojoExecutionException(
String.format("Unable to configure recipe '%s' option '%s' with value '%s'",
recipe.getClass().getSimpleName(), field.getName(), optionValue));
}
}
private static @Nullable Object convertOptionValue(String name, @Nullable String optionValue, Class<?> type)
throws MojoExecutionException {
if (optionValue == null) {
return null;
}
if (type.isAssignableFrom(String.class)) {
return optionValue;
}
if (type.isAssignableFrom(boolean.class) || type.isAssignableFrom(Boolean.class)) {
return Boolean.parseBoolean(optionValue);
}
if (type.isAssignableFrom(int.class) || type.isAssignableFrom(Integer.class)) {
return Integer.parseInt(optionValue);
}
if (type.isAssignableFrom(long.class) || type.isAssignableFrom(Long.class)) {
return Long.parseLong(optionValue);
}
throw new MojoExecutionException(
String.format("Unable to convert option: %s value: %s to type: %s", name, optionValue, type));
}
protected LargeSourceSet loadSourceSet(Path repositoryRoot, Environment env, ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException, MojoFailureException {
List<NamedStyles> styles = loadStyles(project, env);
//Parse and collect source files from each project in the maven session.
MavenMojoProjectParser projectParser = new MavenMojoProjectParser(getLog(), repositoryRoot, pomCacheEnabled, pomCacheDirectory, runtime, skipMavenParsing, getExclusions(), getPlainTextMasks(), sizeThresholdMb, mavenSession, settingsDecrypter, runPerSubmodule, true);
Stream<SourceFile> sourceFiles = projectParser.listSourceFiles(project, styles, ctx);
List<SourceFile> sourceFileList = sourcesWithAutoDetectedStyles(sourceFiles);
return new InMemoryLargeSourceSet(sourceFileList);
}
protected List<Result> runRecipe(Recipe recipe, LargeSourceSet sourceSet, ExecutionContext ctx) {
getLog().info("Running recipe(s)...");
CsvDataTableStore csvDataTableStore = null;
if (exportDatatables) {
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss-SSS"));
Path datatableDirectoryPath = Paths.get("target", "rewrite", "datatables", timestamp);
getLog().info(String.format("Printing available datatables to: %s", datatableDirectoryPath));
csvDataTableStore = new CsvDataTableStore(datatableDirectoryPath);
DataTableExecutionContextView.view(ctx).setDataTableStore(csvDataTableStore);
}
RecipeRun recipeRun = recipe.run(sourceSet, ctx);
if (csvDataTableStore != null) {
csvDataTableStore.close();
}
return recipeRun.getChangeset().getAllResults().stream().filter(source -> {
// Remove ASTs originating from generated files
if (source.getBefore() != null) {
return !source.getBefore().getMarkers().findFirst(Generated.class).isPresent();
}
return true;
}).collect(toList());
}
private List<SourceFile> sourcesWithAutoDetectedStyles(Stream<SourceFile> sourceFiles) {
org.openrewrite.java.style.Autodetect.Detector javaDetector = org.openrewrite.java.style.Autodetect.detector();
org.openrewrite.kotlin.style.Autodetect.Detector kotlinDetector = org.openrewrite.kotlin.style.Autodetect.detector();
org.openrewrite.xml.style.Autodetect.Detector xmlDetector = org.openrewrite.xml.style.Autodetect.detector();
List<SourceFile> sourceFileList = sourceFiles
.peek(s -> {
if (s instanceof K.CompilationUnit) {
kotlinDetector.sample(s);
} else if (s instanceof J.CompilationUnit) {
javaDetector.sample(s);
}
})
.peek(xmlDetector::sample)
.collect(toList());
Map<Class<? extends Tree>, NamedStyles> stylesByType = new HashMap<>();
stylesByType.put(J.CompilationUnit.class, javaDetector.build());
stylesByType.put(K.CompilationUnit.class, kotlinDetector.build());
stylesByType.put(Xml.Document.class, xmlDetector.build());
return ListUtils.map(sourceFileList, applyAutodetectedStyle(stylesByType));
}
private UnaryOperator<SourceFile> applyAutodetectedStyle(Map<Class<? extends Tree>, NamedStyles> stylesByType) {
return before -> {
for (Map.Entry<Class<? extends Tree>, NamedStyles> styleTypeEntry : stylesByType.entrySet()) {
if (styleTypeEntry.getKey().isAssignableFrom(before.getClass())) {
before = before.withMarkers(before.getMarkers().add(styleTypeEntry.getValue()));
}
}
return before;
};
}
private void merge(ClassLoader targetClassLoader, URLClassLoader sourceClassLoader) {
ClassRealm targetClassRealm;
try {
targetClassRealm = (ClassRealm) targetClassLoader;
} catch (ClassCastException e) {
getLog().warn("Could not merge ClassLoaders due to unexpected targetClassLoader type", e);
return;
}
Set<String> existingVersionlessJars = new HashSet<>();
for (URL existingUrl : targetClassRealm.getURLs()) {
existingVersionlessJars.add(stripVersion(existingUrl));
}
for (URL newUrl : sourceClassLoader.getURLs()) {
if (!existingVersionlessJars.contains(stripVersion(newUrl))) {
targetClassRealm.addURL(newUrl);
}
}
}
private String stripVersion(URL jarUrl) {
return jarUrl.toString().replaceAll("/[^/]+/[^/]+\\.jar", "");
}
public static class ResultsContainer {
final Path projectRoot;
final List<Result> generated = new ArrayList<>();
final List<Result> deleted = new ArrayList<>();
final List<Result> moved = new ArrayList<>();
final List<Result> refactoredInPlace = new ArrayList<>();
public ResultsContainer(Path projectRoot, Collection<Result> results) {
this.projectRoot = projectRoot;
for (Result result : results) {
if (result.getBefore() == null && result.getAfter() == null) {
// This situation shouldn't happen / makes no sense, log and skip
continue;
}
if (result.getBefore() == null && result.getAfter() != null) {
generated.add(result);
} else if (result.getBefore() != null && result.getAfter() == null) {
deleted.add(result);
} else if (result.getBefore() != null && result.getAfter() != null && !result.getBefore().getSourcePath().equals(result.getAfter().getSourcePath())) {
moved.add(result);
} else {
FencedMarkerPrinter markerPrinter = new FencedMarkerPrinter();
String beforePrint = result.getBefore().printAll(new PrintOutputCapture<>(0, markerPrinter));
String afterPrint = result.getAfter().printAll(new PrintOutputCapture<>(0, markerPrinter));
if (!beforePrint.equals(afterPrint)) {
refactoredInPlace.add(result);
}
}
}
}
public @Nullable RuntimeException getFirstException() {
for (Result result : generated) {
for (RuntimeException error : getRecipeErrors(result)) {
return error;
}
}
for (Result result : deleted) {
for (RuntimeException error : getRecipeErrors(result)) {
return error;
}
}
for (Result result : moved) {
for (RuntimeException error : getRecipeErrors(result)) {
return error;
}
}
for (Result result : refactoredInPlace) {
for (RuntimeException error : getRecipeErrors(result)) {
return error;
}
}
return null;
}
private List<RuntimeException> getRecipeErrors(Result result) {
List<RuntimeException> exceptions = new ArrayList<>();
new TreeVisitor<Tree, Integer>() {
@Override
public Tree preVisit(Tree tree, Integer integer) {
Markers markers = tree.getMarkers();
markers.findFirst(Markup.Error.class).ifPresent(e -> {
Optional<SourceFile> sourceFile = Optional.ofNullable(getCursor().firstEnclosing(SourceFile.class));
String sourcePath = sourceFile.map(SourceFile::getSourcePath).map(Path::toString).orElse("<unknown>");
exceptions.add(new RuntimeException("Error while visiting " + sourcePath + ": " + e.getDetail()));
});
return tree;
}
}.visit(result.getAfter(), 0);
return exceptions;
}
public Path getProjectRoot() {
return projectRoot;
}
public boolean isNotEmpty() {
return !generated.isEmpty() || !deleted.isEmpty() || !moved.isEmpty() || !refactoredInPlace.isEmpty();
}
/**
* List directories that are empty as a result of applying recipe changes
*/
public List<Path> newlyEmptyDirectories() {
Set<Path> maybeEmptyDirectories = new LinkedHashSet<>();
for (Result result : moved) {
assert result.getBefore() != null;
maybeEmptyDirectories.add(projectRoot.resolve(result.getBefore().getSourcePath()).getParent());
}
for (Result result : deleted) {
assert result.getBefore() != null;
maybeEmptyDirectories.add(projectRoot.resolve(result.getBefore().getSourcePath()).getParent());
}
if (maybeEmptyDirectories.isEmpty()) {
return emptyList();
}
List<Path> emptyDirectories = new ArrayList<>(maybeEmptyDirectories.size());
for (Path maybeEmptyDirectory : maybeEmptyDirectories) {
try (Stream<Path> contents = Files.list(maybeEmptyDirectory)) {
if (contents.findAny().isPresent()) {
continue;
}
Files.delete(maybeEmptyDirectory);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
return emptyDirectories;
}
/**
* Only retains output for markers of type {@code SearchResult} and {@code Markup}.
*/
private static class FencedMarkerPrinter implements PrintOutputCapture.MarkerPrinter {
@Override
public String beforeSyntax(Marker marker, Cursor cursor, UnaryOperator<String> commentWrapper) {
return marker instanceof SearchResult || marker instanceof Markup ? "{{" + marker.getId() + "}}" : "";
}
@Override
public String afterSyntax(Marker marker, Cursor cursor, UnaryOperator<String> commentWrapper) {
return marker instanceof SearchResult || marker instanceof Markup ? "{{" + marker.getId() + "}}" : "";
}
}
}
protected void logRecipesThatMadeChanges(Result result) {
String indent = " ";
String prefix = " ";
for (RecipeDescriptor recipeDescriptor : result.getRecipeDescriptorsThatMadeChanges()) {
logRecipe(recipeDescriptor, prefix);
prefix = prefix + indent;
}
}
private void logRecipe(RecipeDescriptor rd, String prefix) {
StringBuilder recipeString = new StringBuilder(prefix + rd.getName());
if (!rd.getOptions().isEmpty()) {
String opts = rd.getOptions().stream().map(option -> {
if (option.getValue() != null) {
return option.getName() + "=" + option.getValue();
}
return null;
}
).filter(Objects::nonNull).collect(joining(", "));
if (!opts.isEmpty()) {
recipeString.append(": {").append(opts).append("}");
}
}
log(recipeChangeLogLevel, recipeString.toString());
for (RecipeDescriptor rchild : rd.getRecipeList()) {
logRecipe(rchild, prefix + " ");
}
}
protected Duration estimateTimeSavedSum(Result result, Duration timeSaving) {
if (null != result.getTimeSavings()) {
return timeSaving.plus(result.getTimeSavings());
}
return timeSaving;
}
protected String formatDuration(Duration duration) {
return duration.toString()
.substring(2)
.replaceAll("(\\d[HMS])(?!$)", "$1 ")
.toLowerCase()
.trim();
}
}
================================================
FILE: src/main/java/org/openrewrite/maven/AbstractRewriteDryRunMojo.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Result;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
/**
* Base mojo for rewrite:dryRun and rewrite:dryRunNoFork.
* <p>
* Generate warnings to the console for any recipe that would make changes, but do not make changes.
*/
public class AbstractRewriteDryRunMojo extends AbstractRewriteBaseRunMojo {
@Parameter(property = "reportOutputDirectory")
@Nullable
private String reportOutputDirectory;
/**
* Whether to throw an exception if there are any result changes produced.
*/
@Parameter(property = "failOnDryRunResults", defaultValue = "false")
private boolean failOnDryRunResults;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (rewriteSkip) {
getLog().info("Skipping execution");
putState(State.SKIPPED);
return;
}
putState(State.TO_BE_PROCESSED);
// If the plugin is configured to run over all projects (at the end of the build) only proceed if the plugin
// is being run on the last project.
if (!runPerSubmodule && !allProjectsMarked()) {
getLog().info("REWRITE: Delaying execution to the end of multi-module project for " +
project.getGroupId() + ":" +
project.getArtifactId()+ ":" +
project.getVersion());
return;
}
List<Throwable> throwables = new ArrayList<>();
ExecutionContext ctx = executionContext(throwables);
ResultsContainer results = listResults(ctx);
RuntimeException firstException = results.getFirstException();
if (firstException != null) {
getLog().error("The recipe produced an error. Please report this to the recipe author.");
throw firstException;
}
if (!throwables.isEmpty()) {
getLog().warn("The recipe produced " + throwables.size() + " warning(s). Please report this to the recipe author.");
if (!getLog().isDebugEnabled() && !exportDatatables) {
getLog().warn("Run with `--debug` or `-Drewrite.exportDatatables=true` to see all warnings.", throwables.get(0));
}
}
if (results.isNotEmpty()) {
Duration estimateTimeSaved = Duration.ZERO;
for (Result result : results.generated) {
assert result.getAfter() != null;
getLog().warn("These recipes would generate a new file " +
result.getAfter().getSourcePath() +
":");
logRecipesThatMadeChanges(result);
estimateTimeSaved = estimateTimeSavedSum(result, estimateTimeSaved);
}
for (Result result : results.deleted) {
assert result.getBefore() != null;
getLog().warn("These recipes would delete a file " +
result.getBefore().getSourcePath() +
":");
logRecipesThatMadeChanges(result);
estimateTimeSaved = estimateTimeSavedSum(result, estimateTimeSaved);
}
for (Result result : results.moved) {
assert result.getBefore() != null;
assert result.getAfter() != null;
getLog().warn("These recipes would move a file from " +
result.getBefore().getSourcePath() + " to " +
result.getAfter().getSourcePath() + ":");
logRecipesThatMadeChanges(result);
estimateTimeSaved = estimateTimeSavedSum(result, estimateTimeSaved);
}
for (Result result : results.refactoredInPlace) {
assert result.getBefore() != null;
getLog().warn("These recipes would make changes to " +
result.getBefore().getSourcePath() +
":");
logRecipesThatMadeChanges(result);
estimateTimeSaved = estimateTimeSavedSum(result, estimateTimeSaved);
}
Path outPath;
if (reportOutputDirectory != null) {
outPath = Paths.get(reportOutputDirectory);
} else if (runPerSubmodule) {
outPath = Paths.get(project.getBuild().getDirectory()).resolve("rewrite");
} else {
outPath = Paths.get(mavenSession.getTopLevelProject().getBuild().getDirectory()).resolve("rewrite");
}
try {
Files.createDirectories(outPath);
} catch (IOException e) {
throw new RuntimeException("Could not create the folder [ " + outPath + "].", e);
}
Path patchFile = outPath.resolve("rewrite.patch");
try (BufferedWriter writer = Files.newBufferedWriter(patchFile)) {
Stream.concat(
Stream.concat(results.generated.stream(), results.deleted.stream()),
Stream.concat(results.moved.stream(), results.refactoredInPlace.stream())
)
.map(Result::diff)
.forEach(diff -> {
try {
writer.write(diff + "\n");
} catch (IOException e) {
throw new RuntimeException(e);
}
});
} catch (Exception e) {
throw new MojoExecutionException("Unable to generate rewrite result.", e);
}
getLog().warn("Patch file available:");
getLog().warn(" " + patchFile.normalize());
getLog().warn("Estimate time saved: " + formatDuration(estimateTimeSaved));
getLog().warn("Run 'mvn rewrite:run' to apply the recipes.");
if (failOnDryRunResults) {
throw new MojoExecutionException("Applying recipes would make changes. See logs for more details.");
}
} else {
getLog().info("Applying recipes would make no changes. No patch file generated.");
}
putState(State.PROCESSED);
}
}
================================================
FILE: src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.rtinfo.RuntimeInformation;
import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.artifact.Artifact;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.config.ClasspathScanningLoader;
import org.openrewrite.config.Environment;
import org.openrewrite.config.YamlResourceLoader;
import org.openrewrite.ipc.http.HttpSender;
import org.openrewrite.ipc.http.HttpUrlConnectionSender;
import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import static java.util.Collections.sort;
@SuppressWarnings("NotNullFieldNotInitialized")
public abstract class AbstractRewriteMojo extends ConfigurableRewriteMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
protected MavenProject project;
/**
* Whether to resolve properties in YAML configuration files, like{@code ${project.artifactId} }.
* Default true; set to false to disable.
*/
@Parameter(property = "rewrite.resolvePropertiesInYaml", defaultValue = "true")
protected boolean resolvePropertiesInYaml;
@Inject
protected RuntimeInformation runtime;
@Inject
protected SettingsDecrypter settingsDecrypter;
@Inject
protected RepositorySystem repositorySystem;
protected Environment environment() throws MojoExecutionException {
return environment(getRecipeArtifactCoordinatesClassloader());
}
static class Config {
final InputStream inputStream;
final URI uri;
Config(InputStream inputStream, URI uri) {
this.inputStream = inputStream;
this.uri = uri;
}
}
@Nullable
Config getConfig() throws IOException {
try {
URI uri = new URI(configLocation);
if (uri.getScheme() != null && uri.getScheme().startsWith("http")) {
HttpSender httpSender = new HttpUrlConnectionSender();
//noinspection resource
return new Config(httpSender.get(configLocation).send().getBody(), uri);
}
} catch (URISyntaxException e) {
// Try to load as a path
}
Path absoluteConfigLocation = Paths.get(configLocation);
if (!absoluteConfigLocation.isAbsolute()) {
absoluteConfigLocation = project.getBasedir().toPath().resolve(configLocation);
}
File rewriteConfig = absoluteConfigLocation.toFile();
if (rewriteConfig.exists()) {
return new Config(Files.newInputStream(rewriteConfig.toPath()), rewriteConfig.toURI());
}
getLog().debug("No rewrite configuration found at " + absoluteConfigLocation);
return null;
}
protected Environment environment(@Nullable ClassLoader recipeClassLoader) throws MojoExecutionException {
@Nullable Properties propertiesToResolve;
if (resolvePropertiesInYaml) {
Properties userProperties = mavenSession.getUserProperties();
if (userProperties.isEmpty()) {
propertiesToResolve = project.getProperties();
} else {
propertiesToResolve = new Properties(project.getProperties());
for (Map.Entry<Object, Object> entry : userProperties.entrySet()) {
propertiesToResolve.put(entry.getKey(), entry.getValue());
}
}
} else {
propertiesToResolve = null;
}
Environment.Builder env = Environment.builder(propertiesToResolve);
if (recipeClassLoader == null) {
env.scanRuntimeClasspath()
.scanUserHome();
} else {
env.load(new ClasspathScanningLoader(propertiesToResolve, recipeClassLoader));
}
try {
Config rewriteConfig = getConfig();
if (rewriteConfig != null) {
try (InputStream is = rewriteConfig.inputStream) {
env.load(new YamlResourceLoader(is, rewriteConfig.uri, propertiesToResolve));
}
}
} catch (IOException e) {
throw new MojoExecutionException("Unable to load rewrite configuration", e);
}
return env.build();
}
protected ExecutionContext executionContext(List<Throwable> throwables) {
return new InMemoryExecutionContext(t -> {
getLog().debug(t);
throwables.add(t);
});
}
protected Path getBuildRoot() {
Path localRepositoryFolder = Paths.get(mavenSession.getLocalRepository().getBasedir()).normalize();
Set<Path> baseFolders = new HashSet<>();
for (MavenProject project : mavenSession.getAllProjects()) {
collectBasePaths(project, baseFolders, localRepositoryFolder);
}
if (!baseFolders.isEmpty()) {
List<Path> sortedPaths = new ArrayList<>(baseFolders);
sort(sortedPaths);
return sortedPaths.get(0);
}
return Paths.get(mavenSession.getExecutionRootDirectory());
}
private void collectBasePaths(MavenProject project, Set<Path> paths, Path localRepository) {
Path baseDir = project.getBasedir() == null ? null : project.getBasedir().toPath().normalize();
if (baseDir == null || baseDir.startsWith(localRepository) || paths.contains(baseDir)) {
return;
}
paths.add(baseDir);
MavenProject parent = project.getParent();
while (parent != null && parent.getBasedir() != null) {
collectBasePaths(parent, paths, localRepository);
parent = parent.getParent();
}
}
protected @Nullable URLClassLoader getRecipeArtifactCoordinatesClassloader() throws MojoExecutionException {
if (getRecipeArtifactCoordinates().isEmpty()) {
return null;
}
ArtifactResolver resolver = new ArtifactResolver(repositorySystem, mavenSession);
Set<Artifact> artifacts = new HashSet<>();
for (String coordinate : getRecipeArtifactCoordinates()) {
artifacts.add(resolver.createArtifact(coordinate));
}
Set<Artifact> resolvedArtifacts = resolver.resolveArtifactsAndDependencies(artifacts);
URL[] urls = resolvedArtifacts.stream()
.map(Artifact::getFile)
.map(File::toURI)
.map(uri -> {
try {
return uri.toURL();
} catch (MalformedURLException e) {
throw new RuntimeException("Failed to resolve artifacts from rewrite.recipeArtifactCoordinates", e);
}
})
.toArray(URL[]::new);
return new URLClassLoader(
urls,
AbstractRewriteMojo.class.getClassLoader()
);
}
}
================================================
FILE: src/main/java/org/openrewrite/maven/AbstractRewriteRunMojo.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.openrewrite.ExecutionContext;
import org.openrewrite.FileAttributes;
import org.openrewrite.PrintOutputCapture;
import org.openrewrite.Result;
import org.openrewrite.binary.Binary;
import org.openrewrite.quark.Quark;
import org.openrewrite.remote.Remote;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
/**
* Run the configured recipes and apply the changes locally.
* <p>
* Base mojo for rewrite:run and rewrite:runNoFork.
*/
public class AbstractRewriteRunMojo extends AbstractRewriteBaseRunMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (rewriteSkip) {
getLog().info("Skipping execution");
putState(State.SKIPPED);
return;
}
putState(State.TO_BE_PROCESSED);
// If the plugin is configured to run over all projects (at the end of the build) only proceed if the plugin
// is being run on the last project.
if (!runPerSubmodule && !allProjectsMarked()) {
getLog().info("REWRITE: Delaying execution to the end of multi-module project for " +
project.getGroupId() + ":" +
project.getArtifactId()+ ":" +
project.getVersion());
return;
}
List<Throwable> throwables = new ArrayList<>();
ExecutionContext ctx = executionContext(throwables);
ResultsContainer results = listResults(ctx);
RuntimeException firstException = results.getFirstException();
if (firstException != null) {
getLog().error("The recipe produced an error. Please report this to the recipe author.");
throw firstException;
}
if (!throwables.isEmpty()) {
getLog().warn("The recipe produced " + throwables.size() + " warning(s). Please report this to the recipe author.");
if (!getLog().isDebugEnabled() && !exportDatatables) {
getLog().warn("Run with `--debug` or `-Drewrite.exportDatatables=true` to see all warnings.", throwables.get(0));
}
}
if (results.isNotEmpty()) {
Duration estimateTimeSaved = Duration.ZERO;
for (Result result : results.generated) {
assert result.getAfter() != null;
log(recipeChangeLogLevel, "Generated new file " +
result.getAfter().getSourcePath().normalize() +
" by:");
logRecipesThatMadeChanges(result);
estimateTimeSaved = estimateTimeSavedSum(result, estimateTimeSaved);
}
for (Result result : results.deleted) {
assert result.getBefore() != null;
log(recipeChangeLogLevel, "Deleted file " +
result.getBefore().getSourcePath().normalize() +
" by:");
logRecipesThatMadeChanges(result);
estimateTimeSaved = estimateTimeSavedSum(result, estimateTimeSaved);
}
for (Result result : results.moved) {
assert result.getAfter() != null;
assert result.getBefore() != null;
log(recipeChangeLogLevel, "File has been moved from " +
result.getBefore().getSourcePath().normalize() + " to " +
result.getAfter().getSourcePath().normalize() + " by:");
logRecipesThatMadeChanges(result);
estimateTimeSaved = estimateTimeSavedSum(result, estimateTimeSaved);
}
for (Result result : results.refactoredInPlace) {
assert result.getBefore() != null;
log(recipeChangeLogLevel, "Changes have been made to " +
result.getBefore().getSourcePath().normalize() +
" by:");
logRecipesThatMadeChanges(result);
estimateTimeSaved = estimateTimeSavedSum(result, estimateTimeSaved);
}
log(recipeChangeLogLevel, "Please review and commit the results.");
log(recipeChangeLogLevel, "Estimate time saved: " + formatDuration(estimateTimeSaved));
try {
for (Result result : results.generated) {
assert result.getAfter() != null;
writeAfter(results.getProjectRoot(), result, ctx);
}
for (Result result : results.deleted) {
assert result.getBefore() != null;
Path originalLocation = results.getProjectRoot().resolve(result.getBefore().getSourcePath()).normalize();
boolean deleteSucceeded = originalLocation.toFile().delete();
if (!deleteSucceeded) {
throw new IOException("Unable to delete file " + originalLocation.toAbsolutePath());
}
}
for (Result result : results.moved) {
// Should we try to use git to move the file first, and only if that fails fall back to this?
assert result.getBefore() != null;
Path originalLocation = results.getProjectRoot().resolve(result.getBefore().getSourcePath());
File originalParentDir = originalLocation.toFile().getParentFile();
assert result.getAfter() != null;
// Ensure directories exist in case something was moved into a hitherto non-existent package
Path afterLocation = results.getProjectRoot().resolve(result.getAfter().getSourcePath());
File afterParentDir = afterLocation.toFile().getParentFile();
// Rename the directory if its name case has been changed, e.g. camel case to lower case.
if (afterParentDir.exists() &&
afterParentDir.getAbsolutePath().equalsIgnoreCase((originalParentDir.getAbsolutePath())) &&
!afterParentDir.getAbsolutePath().equals(originalParentDir.getAbsolutePath())) {
if (!originalParentDir.renameTo(afterParentDir)) {
throw new RuntimeException("Unable to rename directory from " + originalParentDir.getAbsolutePath() + " To: " + afterParentDir.getAbsolutePath());
}
} else if (!afterParentDir.exists() && !afterParentDir.mkdirs()) {
throw new RuntimeException("Unable to create directory " + afterParentDir.getAbsolutePath());
}
if (result.getAfter() instanceof Quark) {
// We don't know the contents of a Quark, but we can move it
Files.move(originalLocation, results.getProjectRoot().resolve(result.getAfter().getSourcePath()));
} else {
// On Mac this can return "false" even when the file was deleted, so skip the check
//noinspection ResultOfMethodCallIgnored
originalLocation.toFile().delete();
writeAfter(results.getProjectRoot(), result, ctx);
}
}
for (Result result : results.refactoredInPlace) {
assert result.getBefore() != null;
assert result.getAfter() != null;
writeAfter(results.getProjectRoot(), result, ctx);
}
List<Path> emptyDirectories = results.newlyEmptyDirectories();
if (!emptyDirectories.isEmpty()) {
getLog().info("Removing " + emptyDirectories.size() + " newly empty directories:");
for (Path emptyDirectory : emptyDirectories) {
getLog().info(" " + emptyDirectory);
Files.delete(emptyDirectory);
}
}
} catch (IOException e) {
throw new RuntimeException("Unable to rewrite source files", e);
}
}
putState(State.PROCESSED);
}
private static void writeAfter(Path root, Result result, ExecutionContext ctx) {
if (result.getAfter() == null || result.getAfter() instanceof Quark) {
return;
}
Path targetPath = root.resolve(result.getAfter().getSourcePath());
File targetFile = targetPath.toFile();
if (!targetFile.getParentFile().exists()) {
//noinspection ResultOfMethodCallIgnored
targetFile.getParentFile().mkdirs();
}
if (result.getAfter() instanceof Binary) {
try (FileOutputStream sourceFileWriter = new FileOutputStream(targetFile)) {
sourceFileWriter.write(((Binary) result.getAfter()).getBytes());
} catch (IOException e) {
throw new UncheckedIOException("Unable to rewrite source files", e);
}
} else if (result.getAfter() instanceof Remote) {
Remote remote = (Remote) result.getAfter();
try (FileOutputStream sourceFileWriter = new FileOutputStream(targetFile)) {
InputStream source = remote.getInputStream(ctx);
byte[] buf = new byte[4096];
int length;
while ((length = source.read(buf)) > 0) {
sourceFileWriter.write(buf, 0, length);
}
} catch (IOException e) {
throw new UncheckedIOException("Unable to rewrite source files", e);
}
} else if (!(result.getAfter() instanceof Quark)) {
// Don't attempt to write to a Quark; it has already been logged as change that has been made
Charset charset = result.getAfter().getCharset() == null ? StandardCharsets.UTF_8 : result.getAfter().getCharset();
try (BufferedWriter sourceFileWriter = Files.newBufferedWriter(targetPath, charset)) {
sourceFileWriter.write(result.getAfter().printAll(new PrintOutputCapture<>(0, new SanitizedMarkerPrinter())));
} catch (IOException e) {
throw new UncheckedIOException("Unable to rewrite source files", e);
}
}
if (result.getAfter().getFileAttributes() != null) {
FileAttributes fileAttributes = result.getAfter().getFileAttributes();
if (targetFile.canRead() != fileAttributes.isReadable()) {
//noinspection ResultOfMethodCallIgnored
targetFile.setReadable(fileAttributes.isReadable());
}
if (targetFile.canWrite() != fileAttributes.isWritable()) {
//noinspection ResultOfMethodCallIgnored
targetFile.setWritable(fileAttributes.isWritable());
}
if (targetFile.canExecute() != fileAttributes.isExecutable()) {
//noinspection ResultOfMethodCallIgnored
targetFile.setExecutable(fileAttributes.isExecutable());
}
}
}
}
================================================
FILE: src/main/java/org/openrewrite/maven/ArtifactResolver.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.resolution.ArtifactResult;
import org.eclipse.aether.resolution.DependencyRequest;
import org.eclipse.aether.resolution.DependencyResolutionException;
import org.eclipse.aether.resolution.DependencyResult;
import org.eclipse.aether.util.artifact.JavaScopes;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptySet;
import static java.util.stream.Collectors.toList;
public class ArtifactResolver {
private final RepositorySystem repositorySystem;
private final RepositorySystemSession repositorySystemSession;
private final List<RemoteRepository> remoteRepositories;
public ArtifactResolver(RepositorySystem repositorySystem, MavenSession session) {
this.repositorySystem = repositorySystem;
this.repositorySystemSession = session.getRepositorySession();
this.remoteRepositories = RepositoryUtils.toRepos(session.getCurrentProject().getRemoteArtifactRepositories());
}
public Artifact createArtifact(String coordinates) throws MojoExecutionException {
String[] parts = coordinates.split(":");
if (parts.length < 3) {
throw new MojoExecutionException("Must include at least groupId:artifactId:version in artifact coordinates" + coordinates);
}
return new DefaultArtifact(parts[0], parts[1], null, "jar", parts[2]);
}
public Set<Artifact> resolveArtifactsAndDependencies(Set<Artifact> artifacts) throws MojoExecutionException {
if (artifacts.isEmpty()) {
return emptySet();
}
Set<Artifact> elements = new HashSet<>();
try {
List<Dependency> dependencies = artifacts.stream().map(a -> new Dependency(a, JavaScopes.RUNTIME)).collect(toList());
CollectRequest collectRequest =
new CollectRequest(dependencies, emptyList(), remoteRepositories);
DependencyRequest dependencyRequest = new DependencyRequest();
dependencyRequest.setCollectRequest(collectRequest);
DependencyResult dependencyResult =
repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
for (ArtifactResult resolved : dependencyResult.getArtifactResults()) {
elements.add(resolved.getArtifact());
}
return elements;
} catch (DependencyResolutionException e) {
throw new MojoExecutionException("Failed to resolve requested artifacts transitive dependencies.", e);
}
}
}
================================================
FILE: src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.MXSerializer;
import org.intellij.lang.annotations.Language;
import org.jspecify.annotations.Nullable;
import org.openrewrite.config.Environment;
import org.openrewrite.style.NamedStyles;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet;
import static java.util.stream.Collectors.toCollection;
import static org.openrewrite.java.style.CheckstyleConfigLoader.loadCheckstyleConfig;
@SuppressWarnings("FieldMayBeFinal")
public abstract class ConfigurableRewriteMojo extends AbstractMojo {
private static final String CHECKSTYLE_DOCTYPE = "module PUBLIC " +
"\"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN\" " +
"\"https://checkstyle.org/dtds/configuration_1_3.dtd\"";
@Parameter(property = "rewrite.configLocation", alias = "configLocation", defaultValue = "${maven.multiModuleProjectDirectory}/rewrite.yml")
protected String configLocation;
@Parameter(property = "rewrite.activeRecipes")
@Nullable
protected LinkedHashSet<String> activeRecipes;
@Parameter(property = "rewrite.activeStyles")
@Nullable
protected LinkedHashSet<String> activeStyles;
@Parameter(property = "rewrite.pomCacheEnabled", alias = "pomCacheEnabled", defaultValue = "true")
protected boolean pomCacheEnabled;
@Parameter(property = "rewrite.pomCacheDirectory", alias = "pomCacheDirectory")
@Nullable
protected String pomCacheDirectory;
@Parameter(property = "rewrite.skip", defaultValue = "false")
protected boolean rewriteSkip;
/**
* When enabled, skip parsing Maven `pom.xml`s, and any transitive poms, as source files.
* This can be an efficiency improvement in certain situations.
*/
@Parameter(property = "skipMavenParsing", defaultValue = "false")
protected boolean skipMavenParsing;
@Parameter(property = "rewrite.checkstyleConfigFile", alias = "checkstyleConfigFile")
@Nullable
protected String checkstyleConfigFile;
@Parameter(property = "rewrite.checkstyleDetectionEnabled", alias = "checkstyleDetectionEnabled", defaultValue = "true")
protected boolean checkstyleDetectionEnabled;
@Parameter(property = "rewrite.exclusions")
@Nullable
private LinkedHashSet<String> exclusions;
protected Set<String> getExclusions() {
return getCleanedSet(exclusions);
}
/**
* Override default plain text masks. If this is specified,
* {@code rewrite.additionalPlainTextMasks} will have no effect.
*/
@Parameter(property = "rewrite.plainTextMasks")
@Nullable
private LinkedHashSet<String> plainTextMasks;
/**
* Allows adding additional plain text masks without overriding
* the defaults.
*/
@Parameter(property = "rewrite.additionalPlainTextMasks")
@Nullable
private LinkedHashSet<String> additionalPlainTextMasks;
protected Set<String> getPlainTextMasks() {
Set<String> masks = getCleanedSet(plainTextMasks);
if (!masks.isEmpty()) {
return masks;
}
//If not defined, use a default set of masks
masks = new HashSet<>(Arrays.asList(
"**/*.adoc",
"**/*.aj",
"**/*.bash",
"**/*.bat",
"**/CODEOWNERS",
"**/*.css",
"**/*.config",
"**/[dD]ockerfile*",
"**/*.[dD]ockerfile",
"**/*[cC]ontainerfile*",
"**/*.[cC]ontainerfile",
"**/*.env",
"**/.gitattributes",
"**/.gitignore",
"**/*.htm*",
"**/gradlew",
"**/.java-version",
"**/*.jelly",
"**/*.jsp",
"**/*.ksh",
"**/*.lock",
"**/lombok.config",
"**/[mM]akefile",
"**/*.md",
"**/*.mf",
"**/META-INF/services/**",
"**/META-INF/spring/**",
"**/META-INF/spring.factories",
"**/mvnw",
"**/mvnw.cmd",
"**/*.qute.java",
"**/.sdkmanrc",
"**/*.sh",
"**/*.sql",
"**/*.svg",
"**/*.tsx",
"**/*.txt",
"**/*.py"
));
masks.addAll(getCleanedSet(additionalPlainTextMasks));
return unmodifiableSet(masks);
}
@Parameter(property = "sizeThresholdMb", defaultValue = "10")
protected int sizeThresholdMb;
/**
* Whether to throw an exception if an activeRecipe fails configuration validation.
* This may happen if the activeRecipe is improperly configured, or any downstream recipes are improperly configured.
* <p>
* For the time, this default is "false" to prevent one improper recipe from failing the build.
* In the future, this default may be changed to "true" to be more restrictive.
*/
@Parameter(property = "rewrite.failOnInvalidActiveRecipes", alias = "failOnInvalidActiveRecipes", defaultValue = "false")
protected boolean failOnInvalidActiveRecipes;
@Parameter(property = "rewrite.runPerSubmodule", alias = "runPerSubmodule", defaultValue = "false")
protected boolean runPerSubmodule;
@Parameter(defaultValue = "${session}", readonly = true)
protected MavenSession mavenSession;
@Parameter(defaultValue = "${plugin}", required = true, readonly = true)
protected PluginDescriptor pluginDescriptor;
protected enum State {
SKIPPED,
PROCESSED,
TO_BE_PROCESSED
}
private static final String OPENREWRITE_PROCESSED_MARKER = "openrewrite.processed";
protected void putState(State state) {
//noinspection unchecked
getPluginContext().put(OPENREWRITE_PROCESSED_MARKER, state.name());
}
private boolean hasState(MavenProject project) {
Map<String, Object> pluginContext = mavenSession.getPluginContext(pluginDescriptor, project);
return pluginContext.containsKey(OPENREWRITE_PROCESSED_MARKER);
}
protected boolean allProjectsMarked() {
return mavenSession.getProjects().stream().allMatch(this::hasState);
}
@Parameter(property = "rewrite.recipeArtifactCoordinates")
@Nullable
private LinkedHashSet<String> recipeArtifactCoordinates;
@Nullable
private volatile Set<String> computedRecipes;
@Nullable
private volatile Set<String> computedStyles;
@Nullable
private volatile Set<String> computedRecipeArtifactCoordinates;
protected Set<String> getActiveRecipes() {
if (computedRecipes == null) {
synchronized (this) {
if (computedRecipes == null) {
computedRecipes = getCleanedSet(activeRecipes);
}
}
}
//noinspection ConstantConditions
return computedRecipes;
}
protected Set<String> getActiveStyles() {
if (computedStyles == null) {
synchronized (this) {
if (computedStyles == null) {
computedStyles = getCleanedSet(activeStyles);
}
}
}
//noinspection ConstantConditions
return computedStyles;
}
protected List<NamedStyles> loadStyles(MavenProject project, Environment env) {
List<NamedStyles> styles = env.activateStyles(getActiveStyles());
try {
Plugin checkstylePlugin = project.getPlugin("org.apache.maven.plugins:maven-checkstyle-plugin");
if (checkstyleConfigFile != null && !checkstyleConfigFile.isEmpty()) {
styles.add(loadCheckstyleConfig(Paths.get(checkstyleConfigFile), emptyMap()));
} else if (checkstyleDetectionEnabled && checkstylePlugin != null) {
Object checkstyleConfRaw = checkstylePlugin.getConfiguration();
if (checkstyleConfRaw instanceof Xpp3Dom) {
Xpp3Dom xmlCheckstyleConf = (Xpp3Dom) checkstyleConfRaw;
Xpp3Dom xmlConfigLocation = xmlCheckstyleConf.getChild("configLocation");
Xpp3Dom xmlCheckstyleRules = xmlCheckstyleConf.getChild("checkstyleRules");
if (xmlConfigLocation != null) {
// resolve location against plugin location (could be in parent pom)
Path configPath = Paths.get(checkstylePlugin.getLocation("").getSource().getLocation())
.resolveSibling(xmlConfigLocation.getValue());
if (configPath.toFile().exists()) {
styles.add(loadCheckstyleConfig(configPath, emptyMap()));
}
} else if (xmlCheckstyleRules != null && xmlCheckstyleRules.getChildCount() > 0) {
styles.add(loadCheckstyleConfig(toCheckStyleDocument(xmlCheckstyleRules.getChild(0)), emptyMap()));
} else {
// When no config location is specified, the maven-checkstyle-plugin falls back on sun_checks.xml
try (InputStream is = org.openrewrite.tools.checkstyle.Checker.class.getResourceAsStream("/sun_checks.xml")) {
if (is != null) {
styles.add(loadCheckstyleConfig(is, emptyMap()));
}
}
}
}
}
} catch (Exception e) {
getLog().warn("Unable to parse checkstyle configuration. Checkstyle will not inform rewrite execution.", e);
}
return styles;
}
private @Language("XML") String toCheckStyleDocument(final Xpp3Dom dom) throws IOException {
StringWriter stringWriter = new StringWriter();
MXSerializer serializer = new MXSerializer();
serializer.setOutput(stringWriter);
serializer.docdecl(CHECKSTYLE_DOCTYPE);
dom.writeToSerializer("", serializer);
return stringWriter.toString();
}
protected Set<String> getRecipeArtifactCoordinates() {
if (computedRecipeArtifactCoordinates == null) {
synchronized (this) {
if (computedRecipeArtifactCoordinates == null) {
computedRecipeArtifactCoordinates = getCleanedSet(recipeArtifactCoordinates);
}
}
}
//noinspection ConstantConditions
return computedRecipeArtifactCoordinates;
}
private static Set<String> getCleanedSet(@Nullable Set<@Nullable String> set) {
if (set == null) {
return emptySet();
}
Set<String> cleaned = set.stream()
.filter(Objects::nonNull)
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(toCollection(LinkedHashSet::new));
return unmodifiableSet(cleaned);
}
}
================================================
FILE: src/main/java/org/openrewrite/maven/LogLevel.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
public enum LogLevel {
DEBUG,
INFO,
WARN,
ERROR
}
================================================
FILE: src/main/java/org/openrewrite/maven/MavenLoggingMeterRegistry.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import io.micrometer.core.instrument.*;
import io.micrometer.core.instrument.binder.BaseUnits;
import io.micrometer.core.instrument.cumulative.*;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.core.instrument.distribution.HistogramSnapshot;
import io.micrometer.core.instrument.distribution.pause.PauseDetector;
import io.micrometer.core.instrument.internal.DefaultGauge;
import io.micrometer.core.instrument.internal.DefaultLongTaskTimer;
import io.micrometer.core.instrument.internal.DefaultMeter;
import io.micrometer.core.instrument.util.TimeUtils;
import org.apache.maven.plugin.logging.Log;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import java.util.function.ToDoubleFunction;
import java.util.function.ToLongFunction;
import java.util.stream.StreamSupport;
import static io.micrometer.core.instrument.util.DoubleFormat.decimalOrNan;
import static java.util.stream.Collectors.joining;
@NullMarked
public class MavenLoggingMeterRegistry extends MeterRegistry {
private final Log log;
public MavenLoggingMeterRegistry(Log log) {
super(Clock.SYSTEM);
this.log = log;
}
@Override
public void close() {
getMeters().stream()
.sorted((m1, m2) -> {
int typeComp = m1.getId().getType().compareTo(m2.getId().getType());
if (typeComp == 0) {
return m1.getId().getName().compareTo(m2.getId().getName());
}
return typeComp;
})
.forEach(m -> {
Printer print = new Printer(m);
m.use(
gauge -> log.info(print.id() + " value=" + print.value(gauge.value())),
counter -> {
double count = counter.count();
log.info(print.id() + " count=" + print.count(count));
},
timer -> {
HistogramSnapshot snapshot = timer.takeSnapshot();
long count = snapshot.count();
log.info(print.id() + " count=" + print.unitlessCount(count) +
" mean=" + print.time(snapshot.mean(getBaseTimeUnit())) +
" max=" + print.time(snapshot.max(getBaseTimeUnit())));
},
summary -> {
HistogramSnapshot snapshot = summary.takeSnapshot();
long count = snapshot.count();
log.info(print.id() + " count=" + print.unitlessCount(count) +
" mean=" + print.value(snapshot.mean()) +
" max=" + print.value(snapshot.max()));
},
longTaskTimer -> {
int activeTasks = longTaskTimer.activeTasks();
log.info(print.id() +
" active=" + print.value(activeTasks) +
" duration=" + print.time(longTaskTimer.duration(getBaseTimeUnit())));
},
timeGauge -> {
double value = timeGauge.value(getBaseTimeUnit());
log.info(print.id() + " value=" + print.time(value));
},
counter -> {
double count = counter.count();
log.info(print.id() + " count=" + print.count(count));
},
timer -> {
double count = timer.count();
log.info(print.id() + " count=" + print.count(count) +
" mean=" + print.time(timer.mean(getBaseTimeUnit())));
},
meter -> log.info(writeMeter(meter, print))
);
});
}
String writeMeter(Meter meter, Printer print) {
return StreamSupport.stream(meter.measure().spliterator(), false)
.map(ms -> {
String msLine = ms.getStatistic().getTagValueRepresentation() + "=";
switch (ms.getStatistic()) {
case TOTAL:
case MAX:
case VALUE:
return msLine + print.value(ms.getValue());
case TOTAL_TIME:
case DURATION:
return msLine + print.time(ms.getValue());
case COUNT:
return "count=" + print.count(ms.getValue());
default:
return msLine + decimalOrNan(ms.getValue());
}
})
.collect(joining(", ", print.id() + " ", ""));
}
@Override
protected Timer newTimer(Meter.Id id, DistributionStatisticConfig distributionStatisticConfig, PauseDetector pauseDetector) {
return new CumulativeTimer(id, clock, distributionStatisticConfig, pauseDetector, getBaseTimeUnit(), false);
}
@Override
protected DistributionSummary newDistributionSummary(Meter.Id id, DistributionStatisticConfig distributionStatisticConfig, double scale) {
return new CumulativeDistributionSummary(id, clock, distributionStatisticConfig, scale, false);
}
@Override
protected Counter newCounter(Meter.Id id) {
return new CumulativeCounter(id);
}
@Override
protected <T> Gauge newGauge(Meter.Id id, @Nullable T obj, ToDoubleFunction<T> valueFunction) {
return new DefaultGauge<>(id, obj, valueFunction);
}
@Override
protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTimeFunctionUnit) {
return new CumulativeFunctionTimer<>(id, obj, countFunction, totalTimeFunction, totalTimeFunctionUnit, getBaseTimeUnit());
}
@Override
protected <T> FunctionCounter newFunctionCounter(Meter.Id id, T obj, ToDoubleFunction<T> countFunction) {
return new CumulativeFunctionCounter<>(id, obj, countFunction);
}
@Override
protected LongTaskTimer newLongTaskTimer(Meter.Id id, DistributionStatisticConfig distributionStatisticConfig) {
return new DefaultLongTaskTimer(id, clock, getBaseTimeUnit(), distributionStatisticConfig, false);
}
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
return new DefaultMeter(id, type, measurements);
}
@Override
protected DistributionStatisticConfig defaultHistogramConfig() {
return DistributionStatisticConfig.builder()
.expiry(Duration.ofMinutes(1))
.bufferLength(3)
.build();
}
class Printer {
private final Meter meter;
Printer(Meter meter) {
this.meter = meter;
}
String id() {
return getConventionName(meter.getId()) + getConventionTags(meter.getId()).stream()
.map(t -> t.getKey() + "=" + t.getValue())
.collect(joining(",", "{", "}"));
}
String count(double count) {
return humanReadableBaseUnit(count);
}
String unitlessCount(double count) {
return decimalOrNan(count);
}
String time(double time) {
return TimeUtils.format(Duration.ofNanos((long) TimeUtils.convert(time, getBaseTimeUnit(), TimeUnit.NANOSECONDS)));
}
String value(double value) {
return humanReadableBaseUnit(value);
}
// see https://stackoverflow.com/a/3758880/510017
@SuppressWarnings("StringConcatenationMissingWhitespace")
String humanReadableByteCount(double bytes) {
int unit = 1024;
if (bytes < unit || Double.isNaN(bytes)) {
return decimalOrNan(bytes) + " B";
}
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = "KMGTPE".charAt(exp - 1) + "i";
return decimalOrNan(bytes / Math.pow(unit, exp)) + " " + pre + "B";
}
String humanReadableBaseUnit(double value) {
String baseUnit = meter.getId().getBaseUnit();
if (BaseUnits.BYTES.equals(baseUnit)) {
return humanReadableByteCount(value);
}
return decimalOrNan(value) + (baseUnit != null ? " " + baseUnit : "");
}
}
@Override
protected TimeUnit getBaseTimeUnit() {
return TimeUnit.MILLISECONDS;
}
}
================================================
FILE: src/main/java/org/openrewrite/maven/MavenLoggingResolutionEventListener.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import org.apache.maven.plugin.logging.Log;
import org.jspecify.annotations.Nullable;
import org.openrewrite.maven.tree.*;
import java.util.List;
class MavenLoggingResolutionEventListener implements ResolutionEventListener {
private final Log logger;
public MavenLoggingResolutionEventListener(Log logger) {
this.logger = logger;
}
@Override
public void downloadSuccess(ResolvedGroupArtifactVersion gav, @Nullable ResolvedPom containing) {
if (logger.isDebugEnabled()) {
logger.debug("Downloaded " + gav + pomContaining(containing));
}
}
@Override
public void downloadError(GroupArtifactVersion gav, List<String> attemptedUris, @Nullable Pom containing) {
StringBuilder sb = new StringBuilder("Failed to download " + gav + pomContaining(containing) + ". Attempted URIs:");
attemptedUris.forEach(uri -> sb.append("\n - ").append(uri));
logger.warn(sb);
}
@Override
public void repositoryAccessFailed(String uri, Throwable e) {
logger.warn("Failed to access maven repository " + uri + " due to: " + e.getMessage());
logger.debug(e);
}
private static String pomContaining(@Nullable Pom containing) {
return containing != null ? " from " + containing.getGav() : "";
}
private static String pomContaining(@Nullable ResolvedPom containing) {
return containing != null ? " from " + containing.getGav() : "";
}
}
================================================
FILE: src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java
================================================
/*
* Copyright 2020 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.maven;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Repository;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.rtinfo.RuntimeInformation;
import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.apache.maven.settings.crypto.SettingsDecryptionRequest;
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.jspecify.annotations.Nullable;
import org.openrewrite.ExecutionContext;
import org.openrewrite.HttpSenderExecutionContextView;
import org.openrewrite.ParseExceptionResult;
import org.openrewrite.PathUtils;
import org.openrewrite.SourceFile;
import org.openrewrite.groovy.GroovyParser;
import org.openrewrite.internal.GitIgnore;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.ipc.http.HttpUrlConnectionSender;
import org.openrewrite.java.JavaParser;
import org.openrewrite.java.internal.JavaTypeCache;
import org.openrewrite.java.marker.JavaProject;
import org.openrewrite.java.marker.JavaSourceSet;
import org.openrewrite.java.marker.JavaVersion;
import org.openrewrite.jgit.api.Git;
import org.openrewrite.jgit.lib.ObjectId;
import org.openrewrite.jgit.revwalk.RevCommit;
import org.openrewrite.jgit.revwalk.RevWalk;
import org.openrewrite.jgit.treewalk.TreeWalk;
import org.openrewrite.jgit.treewalk.filter.PathFilter;
import org.openrewrite.kotlin.KotlinParser;
import org.openrewrite.marker.*;
import org.openrewrite.marker.ci.BuildEnvironment;
import org.openrewrite.maven.cache.InMemoryMavenPomCache;
import org.openrewrite.maven.cache.MavenPomCache;
import org.openrewrite.maven.internal.MavenXmlMapper;
import org.openrewrite.maven.internal.RawPom;
import org.openrewrite.maven.internal.RawRepositories;
import org.openrewrite.maven.tree.Pom;
import org.openrewrite.maven.tree.ProfileActivation;
import org.openrewrite.maven.tree.ResolvedGroupArtifactVersion;
import org.openrewrite.maven.utilities.MavenWrapper;
import org.openrewrite.polyglot.OmniParser;
import org.openrewrite.quark.QuarkParser;
import org.openrewrite.style.NamedStyles;
import org.openrewrite.text.PlainTextParser;
import org.openrewrite.xml.tree.Xml;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
import static org.openrewrite.PathUtils.separatorsToUnix;
import static org.openrewrite.Tree.randomId;
import static org.openrewrite.maven.MavenMojoProjectParser.MavenScope.MAIN;
import static org.openrewrite.maven.MavenMojoProjectParser.MavenScope.TEST;
import static org.openrewrite.tree.ParsingExecutionContextView.view;
// -----------------------------------------------------------------------------------------------------------------
// Notes About Provenance Information:
//
// There are always three markers applied to each source file and there can potentially be up to five provenance markers
// total:
//
// BuildTool - What build tool was used to compile the source file (This will always be Maven)
// JavaVersion - What Java version/vendor was used when compiling the source file.
// JavaProject - For each maven module/submodule, the same JavaProject will be associated with ALL source files belonging to that module.
//
// Optional:
//
// GitProvenance - If the project exists in the context of a git repository, all source files (for all modules) will have the same GitProvenance.
// JavaSourceSet - All Java source files and all resource files that exist in src/main or src/test will have a JavaSourceSet marker assigned to them.
// -----------------------------------------------------------------------------------------------------------------
public class MavenMojoProjectParser {
private static final String MVN_JVM_CONFIG = ".mvn/jvm.config";
private static final String MVN_MAVEN_CONFIG = ".mvn/maven.config";
private static final String MAVEN_COMPILER_PLUGIN = "org.apache.maven.plugins:maven-compiler-plugin";
@Nullable
public static MavenPomCache POM_CACHE;
private final Log logger;
private final AtomicBoolean firstWarningLogged = new AtomicBoolean(false);
private final Path baseDir;
private final org.openrewrite.jgit.lib.@Nullable Repository repository;
private final boolean pomCacheEnabled;
@Nullable
private final String pomCacheDirectory;
private final boolean skipMavenParsing;
private final BuildTool buildTool;
private final Collection<String> exclusions;
private final Collection<String> plainTextMasks;
private final int sizeThresholdMb;
private final MavenSession mavenSession;
private final SettingsDecrypter settingsDecrypter;
private final boolean runPerSubmodule;
private final boolean parseAdditionalResources;
@SuppressWarnings("BooleanParameter")
public MavenMojoProjectParser(Log logger, Path baseDir, boolean pomCacheEnabled, @Nullable String pomCacheDirectory, RuntimeInformation runtime, boolean skipMavenParsing, Collection<String> exclusions, Collection<String> plainTextMasks, int sizeThresholdMb, MavenSession session, SettingsDecrypter settingsDecrypter, boolean runPerSubmodule, boolean parseAdditionalResources) {
this.logger = logger;
this.baseDir = baseDir;
this.repository = getRepository(baseDir);
this.pomCacheEnabled = pomCacheEnabled;
this.pomCacheDirectory = pomCacheDirectory;
this.skipMavenParsing = skipMavenParsing;
this.buildTool = new BuildTool(randomId(), BuildTool.Type.Maven, runtime.getMavenVersion());
this.exclusions = exclusions;
this.plainTextMasks = plainTextMasks;
this.sizeThresholdMb = sizeThresholdMb;
this.mavenSession = session;
this.settingsDecrypter = settingsDecrypter;
this.runPerSubmodule = runPerSubmodule;
this.parseAdditionalResources = parseAdditionalResources;
}
protected JavaTypeCache createTypeCache() {
return new JavaTypeCache();
}
public Stream<SourceFile> listSourceFiles(MavenProject mavenProject, List<NamedStyles> styles,
ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException, MojoFailureException {
if (runPerSubmodule) {
//If running per submodule, parse the source files for only the current project.
List<Marker> projectProvenance = generateProvenance(mavenProject);
Xml.Document maven = parseMaven(mavenProject, projectProvenance, ctx);
return listSourceFiles(mavenProject, maven, projectProvenance, styles, ctx);
}
//If running across all projects, iterate and parse source files from each project
Map<MavenProject, List<Marker>> projectProvenances = mavenSession.getProjects().stream()
.collect(toMap(Function.identity(), this::generateProvenance));
Map<MavenProject, Xml.Document> projectMap = parseMaven(mavenSession.getProjects(), projectProvenances, ctx);
return mavenSession.getProjects().stream()
.flatMap(project -> {
List<Marker> projectProvenance = projectProvenances.get(project);
try {
return listSourceFiles(project, projectMap.get(project), projectProvenance, styles, ctx);
} catch (DependencyResolutionRequiredException | MojoExecutionException e) {
throw sneakyThrow(e);
}
});
}
public Stream<SourceFile> listSourceFiles(MavenProject mavenProject, Xml.@Nullable Document maven, List<Marker> projectProvenance, List<NamedStyles> styles,
ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException {
return listSourceFiles(mavenProject, maven, projectProvenance, Arrays.asList(MAIN, TEST), styles, ctx);
}
public Stream<SourceFile> listSourceFiles(MavenProject mavenProject, Xml.@Nullable Document maven, List<Marker> projectProvenance, List<MavenScope> scopes,
List<NamedStyles> styles, ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException {
Stream<SourceFile> sourceFiles = Stream.empty();
Set<Path> parsedPaths = new HashSet<>();
if (maven != null) {
sourceFiles = Stream.of(maven);
parsedPaths.add(baseDir.resolve(maven.getSourcePath()));
}
JavaParser.Builder<? extends JavaParser, ?> javaParserBuilder = JavaParser.fromJavaVersion()
.styles(styles)
.logCompilationWarningsAndErrors(false);
// todo, add styles from autoDetect
KotlinParser.Builder kotlinParserBuilder = KotlinParser.builder();
GroovyParser.Builder groovyParserBuilder = GroovyParser.builder();
// Pre-populate parsedPaths with all source paths from both scopes (including generated sources)
// to prevent resource parsers from claiming these as PlainText
parsedPaths.addAll(listJavaSources(mavenProject, mavenProject.getExecutionProject().getCompileSourceRoots()));
parsedPaths.addAll(listKotlinSources(mavenProject, "compile", mavenProject.getBuild().getSourceDirectory()));
parsedPaths.addAll(listGroovySources(mavenProject, mavenProject.getExecutionProject().getCompileSourceRoots()));
parsedPaths.addAll(listJavaSources(mavenProject, mavenProject.getExecutionProject().getTestCompileSourceRoots()));
parsedPaths.addAll(listKotlinSources(mavenProject, "test-compile", mavenProject.getBuild().getTestSourceDirectory()));
parsedPaths.addAll(listGroovySources(mavenProject, mavenProject.getExecutionProject().getTestCompileSourceRoots()));
if (scopes.contains(MAIN)) {
sourceFiles = Stream.concat(sourceFiles, processMainSources(mavenProject, javaParserBuilder.clone(), kotlinParserBuilder.clone(), groovyParserBuilder.clone(), parsedPaths, ctx));
}
if (scopes.contains(TEST)) {
sourceFiles = Stream.concat(sourceFiles, processTestSources(mavenProject, javaParserBuilder.clone(), kotlinParserBuilder.clone(), groovyParserBuilder.clone(), parsedPaths, ctx));
}
Collection<PathMatcher> exclusionMatchers = exclusions.stream()
.map(pattern -> baseDir.getFileSystem().getPathMatcher("glob:" + pattern))
.collect(toList());
Path buildDirectory = baseDir.relativize(Paths.get(mavenProject.getBuild().getDirectory()));
sourceFiles = sourceFiles
.filter(sourceFile -> !sourceFile.getSourcePath().startsWith(buildDirectory) && !isExcluded(repository, exclusionMatchers, sourceFile.getSourcePath()));
Stream<SourceFile> mavenWrapperFiles = parseMavenWrapperFiles(mavenProject, exclusionMatchers, parsedPaths, ctx);
sourceFiles = Stream.concat(sourceFiles, mavenWrapperFiles);
Stream<SourceFile> nonProjectResources = parseNonProjectResources(mavenProject, parsedPaths, ctx);
sourceFiles = Stream.concat(sourceFiles, nonProjectResources);
return sourceFiles.map(addProvenance(projectProvenance))
.map(addGitTreeEntryInformation())
.map(this::logParseErrors);
}
static boolean isExcluded(org.openrewrite.jgit.lib.@Nullable Repository repository, Collection<PathMatcher> exclusionMatchers, Path path) {
for (PathMatcher excluded : exclusionMatchers) {
if (excluded.matches(path)) {
return true;
}
}
// PathMatcher will not evaluate the path "pom.xml" to be matched by the pattern "**/pom.xml"
// This is counter-intuitive for most users and would otherwise require separate exclusions for files at the root and files in subdirectories
if (!path.isAbsolute() && !path.startsWith(File.separator)) {
Path prefixed = Paths.get("/" + path);
for (PathMatcher excluded : exclusionMatchers) {
if (excluded.matches(prefixed)) {
return true;
}
}
}
if (repository != null) {
return GitIgnore.isIgnoredAndUntracked(repository, separatorsToUnix(path.toString()));
}
return false;
}
public enum MavenScope {
MAIN,
TEST
}
static Optional<Charset> getCharset(MavenProject mavenProject) {
String compilerPluginKey = MAVEN_COMPILER_PLUGIN;
Plugin plugin = Optional.ofNullable(mavenProject.getPlugin(compilerPluginKey))
.orElseGet(() -> {
PluginManagement pluginManagement = mavenProject.getPluginManagement();
return pluginManagement != null ? pluginManagement.getPluginsAsMap().get(compilerPluginKey) : null;
});
if (plugin != null && plugin.getConfiguration() instanceof Xpp3Dom) {
Xpp3Dom encoding = ((Xpp3Dom) plugin.getConfiguration()).getChild("encoding");
if (encoding != null && StringUtils.isNotEmpty(encoding.getValue())) {
String resolved = resolveProperty(encoding.getValue(), mavenProject);
if (resolved != null) {
return Optional.of(Charset.forName(resolved));
}
}
}
Object mavenSourceEncoding = mavenProject.getProperties().get("project.build.sourceEncoding");
if (mavenSourceEncoding != null) {
String resolved = resolveProperty(mavenSourceEncoding.toString(), mavenProject);
if (resolved != null) {
return Optional.of(Charset.forName(resolved));
}
}
return Optional.empty();
}
private static @Nullable String resolveProperty(String value, MavenProject mavenProject) {
if (value.startsWith("${") && value.endsWith("}")) {
String propertyName = value.substring(2, value.length() - 1);
String resolved = mavenProject.getProperties().getProperty(propertyName);
if (resolved != null && !resolved.contains("${")) {
return resolved;
}
return null;
}
return value.contains("${") ? null : value;
}
static org.openrewrite.jgit.lib.@Nullable Repository getRepository(Path rootDir) {
try (Git git = Git.open(rootDir.toFile())) {
return git.getRepository();
} catch (IOException e) {
// no git
return null;
}
}
private SourceFile logParseErrors(SourceFile source) {
source.getMarkers().findFirst(ParseExceptionResult.class).ifPresent(e -> {
if (firstWarningLogged.compareAndSet(false, true)) {
logger.warn("There were problems parsing some source files" +
(mavenSession.getRequest().isShowErrors() ? "" : ", run with --errors to see full stack traces"));
}
logger.warn("There were problems parsing " + source.getSourcePath());
if (mavenSession.getRequest().isShowErrors()) {
logger.warn(e.getMessage());
}
});
return source;
}
public List<Marker> generateProvenance(MavenProject mavenProject) {
BuildEnvironment buildEnvironment = BuildEnvironment.build(System::getenv);
return Stream.of(
buildEnvironment,
gitProvenance(baseDir, buildEnvironment),
OperatingSystemProvenance.current(),
buildTool,
new JavaProject(randomId(), mavenProject.getName(), new JavaProject.Publication(
mavenProject.getGroupId(),
mavenProject.getArtifactId(),
mavenProject.getVersion()
)))
.filter(Objects::nonNull)
.collect(toList());
}
private static JavaVersion getSrcMainJavaVersion(MavenProject mavenProject) {
String sourceCompatibility = null;
String targetCompatibility = null;
Plugin compilerPlugin = mavenProject.getPlugin(MAVEN_COMPILER_PLUGIN);
if (compilerPlugin != null && compilerPlugin.getConfiguration() instanceof Xpp3Dom) {
Xpp3Dom dom = (Xpp3Dom) compilerPlugin.getConfiguration();
Xpp3Dom release = dom.getChild("release");
if (release != null && StringUtils.isNotEmpty(release.getValue()) && !release.getValue().contains("${")) {
sourceCompatibility = release.getValue();
targetCompatibility = release.getValue();
} else {
Xpp3Dom source = dom.getChild("source");
if (source != null && StringUtils.isNotEmpty(source.getValue()) && !source.getValue().contains("${")) {
sourceCompatibility = source.getValue();
}
Xpp3Dom target = dom.getChild("target");
if (target != null && StringUtils.isNotEmpty(target.getValue()) && !target.getValue().contains("${")) {
targetCompatibility = target.getValue();
}
}
}
if (sourceCompatibility == null || targetCompatibility == null) {
String propertiesReleaseCompatibility = (String) mavenProject.getProperties().get("maven.compiler.release");
if (propertiesReleaseCompatibility != null) {
sourceCompatibility = propertiesReleaseCompatibility;
targetCompatibility = propertiesReleaseCompatibility;
} else {
String propertiesSourceCompatibility = (String) mavenProject.getProperties().get("maven.compiler.source");
if (sourceCompatibility == null && propertiesSourceCompatibility != null) {
sourceCompatibility = propertiesSourceCompatibility;
}
String propertiesTargetCompatibility = (String) mavenProject.getProperties().get("maven.compiler.target");
if (targetCompatibility == null && propertiesTargetCompatibility != null) {
targetCompatibility = propertiesTargetCompatibility;
}
}
}
return getJavaVersionMarker(sourceCompatibility, targetCompatibility);
}
static JavaVersion getSrcTestJavaVersion(MavenProject mavenProject) {
String sourceCompatibility = null;
String targetCompatibility = null;
Plugin compilerPlugin = mavenProject.getPlugin(MAVEN_COMPILER_PLUGIN);
if (compilerPlugin != null && compilerPlugin.getConfiguration() instanceof Xpp3Dom) {
Xpp3Dom dom = (Xpp3Dom) compilerPlugin.getConfiguration();
Xpp3Dom release = dom.getChild("testRelease");
if (release != null && StringUtils.isNotEmpty(release.getValue()) && !release.getValue().contains("${")) {
sourceCompatibility = release.getValue();
targetCompatibility = release.getValue();
} else {
Xpp3Dom source = dom.getChild("testSource");
if (source != null && StringUtils.isNotEmpty(source.getValue()) && !source.getValue().contains("${")) {
sourceCompatibility = source.getValue();
}
Xpp3Dom target = dom.getChild("testTarget");
if (target != null && StringUtils.isNotEmpty(target.getValue()) && !target.getValue().contains("${")) {
targetCompatibility = target.getValue();
}
}
}
if (sourceCompatibility == null || targetCompatibility == null) {
String propertiesReleaseCompatibility = (String) mavenProject.getProperties().get("maven.compiler.testRelease");
if (propertiesReleaseCompatibility != null) {
sourceCompatibility = propertiesReleaseCompatibility;
targetCompatibility = propertiesReleaseCompatibility;
} else {
String propertiesSourceCompatibility = (String) mavenProject.getProperties().get("maven.compiler.testSource");
if (sourceCompatibility == null && propertiesSourceCompatibility != null) {
sourceCompatibility = propertiesSourceCompatibility;
}
String propertiesTargetCompatibility = (String) mavenProject.getProperties().get("maven.compiler.testTarget");
if (targetCompatibility == null && propertiesTargetCompatibility != null) {
targetCompatibility = propertiesTargetCompatibility;
}
}
}
// Fall back to main source compatibility if test source compatibility is not set, or only partially set.
if (sourceCompatibility == null || targetCompatibility == null) {
JavaVersion srcMainJavaVersion = getSrcMainJavaVersion(mavenProject);
if (sourceCompatibility == null && targetCompatibility == null) {
return srcMainJavaVersion;
}
sourceCompatibility = sourceCompatibility == null ? srcMainJavaVersion.getSourceCompatibility() : sourceCompatibility;
targetCompatibility = targetCompatibility == null ? srcMainJavaVersion.getTargetCompatibility() : targetCompatibility;
}
return getJavaVersionMarker(sourceCompatibility, targetCompatibility);
}
private static JavaVersion getJavaVersionMarker(@Nullable String sourceCompatibility, @Nullable String targetCompatibility) {
String javaRuntimeVersion = System.getProperty("java.specification.version");
String javaVendor = System.getProperty("java.vm.vendor");
if (sourceCompatibility == null) {
sourceCompatibility = javaRuntimeVersion;
}
if (targetCompatibility == null) {
targetCompatibility = sourceCompatibility;
}
return new JavaVersion(randomId(), javaRuntimeVersion, javaVendor, sourceCompatibility, targetCompatibility);
}
private Stream<SourceFile> processMainSources(
MavenProject mavenProject,
JavaParser.Builder<? extends JavaParser, ?> javaParserBuilder,
KotlinParser.Builder kotlinParserBuilder,
GroovyParser.Builder groovyParserBuilder,
Set<Path> parsedPaths,
ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException {
Stream<SourceFile> sourceFiles = Stream.of();
// Skip generated source roots under the build directory; their compiled classes are
// already on the classpath via getCompileClasspathElements() and available for type attribution.
List<String> sourceRoots = filterGeneratedSourceRoots(mavenProject, mavenProject.getExecutionProject().getCompileSourceRoots());
// scan Java files
Collection<Path> mainJavaSources = listJavaSources(mavenProject, sourceRoots);
// scan Kotlin files
List<Path> mainKotlinSources = listKotlinSources(mavenProject, "compile", mavenProject.getBuild().getSourceDirectory());
// scan Groovy files
List<Path> mainGroovySources = listGroovySources(mavenProject, sourceRoots);
logInfo(mavenProject, "Parsing source files");
List<Path> dependencies = mavenProject.getCompileClasspathElements().stream()
.distinct()
.map(Paths::get)
.collect(toList());
JavaTypeCache typeCache = createTypeCache();
javaParserBuilder.classpath(dependencies).typeCache(typeCache);
kotlinParserBuilder.classpath(dependencies).typeCache(typeCache);
groovyParserBuilder.classpath(dependencies).typeCache(typeCache);
if (!mainJavaSources.isEmpty()) {
Stream<SourceFile> parsedJava = Stream.of((Supplier<JavaParser>) javaParserBuilder::build)
.map(Supplier::get)
.flatMap(jp -> {
view(ctx).setCharset(getCharset(mavenProject).orElse(null));
return jp.parse(mainJavaSources, baseDir, ctx).onClose(() -> view(ctx).setCharset(null));
});
sourceFiles = Stream.concat(sourceFiles, parsedJava);
logDebug(mavenProject, "Scanned " + mainJavaSources.size() + " java source files in main scope.");
}
if (!mainKotlinSources.isEmpty()) {
Stream<SourceFile> parsedKotlin = Stream.of((Supplier<KotlinParser>) kotlinParserBuilder::build)
.map(Supplier::get)
.flatMap(kp -> {
view(ctx).setCharset(StandardCharsets.UTF_8); // Kotlin requires UTF-8
return kp.parse(mainKotlinSources, baseDir, ctx).onClose(() -> view(ctx).setCharset(null));
});
sourceFiles = Stream.concat(sourceFiles, parsedKotlin);
logDebug(mavenProject, "Scanned " + mainKotlinSources.size() + " kotlin source files in main scope.");
}
if (!mainGroovySources.isEmpty()) {
Stream<SourceFile> parsedGroovy = Stream.of((Supplier<GroovyParser>) groovyParserBuilder::build)
.map(Supplier::get)
.flatMap(gp -> gp.parse(mainGroovySources, baseDir, ctx));
sourceFiles = Stream.concat(sourceFiles, parsedGroovy);
logDebug(mavenProject, "Scanned " + mainGroovySources.size() + " groovy source files in main scope.");
}
OmniParser omniParser = omniParser(parsedPaths, mavenProject);
for (Resource resource : mavenProject.getResources()) {
Path resourcePath = mavenProject.getBasedir().toPath().resolve(resource.getDirectory());
if (Files.exists(resourcePath) && !parsedPaths.contains(resourcePath)) {
List<Path> accepted = omniParser.acceptedPaths(baseDir, resourcePath);
parsedPaths.add(resourcePath);
sourceFiles = Stream.concat(sourceFiles, omniParser.parse(accepted, baseDir, ctx));
parsedPaths.addAll(accepted);
}
}
// Also parse webapp resources (e.g., web.xml) for WAR projects
if ("war".equals(mavenProject.getPackaging())) {
Path webappPath = mavenProject.getBasedir().toPath().resolve("src/main/webapp");
if (Files.exists(webappPath) && !parsedPaths.contains(webappPath)) {
List<Path> accepted = omniParser.acceptedPaths(baseDir, webappPath);
parsedPaths.add(webappPath);
sourceFiles = Stream.concat(sourceFiles, omniParser.parse(accepted, baseDir, ctx));
parsedPaths.addAll(accepted);
}
}
List<Marker> mainProjectProvenance = new ArrayList<>();
mainProjectProvenance.add(JavaSourceSet.build("main", dependencies));
mainProjectProvenance.add(getSrcMainJavaVersion(mavenProject));
return sourceFiles
.map(addProvenance(mainProjectProvenance));
}
private Stream<SourceFile> processTestSources(
MavenProject mavenProject,
JavaParser.Builder<? extends JavaParser, ?> javaParserBuilder,
KotlinParser.Builder kotlinParserBuilder,
GroovyParser.Builder groovyParserBuilder,
Set<Path> parsedPaths,
ExecutionContext ctx) throws DependencyResolutionRequiredException, MojoExecutionException {
Stream<SourceFile> sourceFiles = Stream.of();
// Skip generated source roots under the build directory; their compiled classes are
// already on the classpath via getTestClasspathElements() and available for type attribution.
List<String> testSourceRoots = filterGeneratedSourceRoots(mavenProject, mavenProject.getExecutionProject().getTestCompileSourceRoots());
// scan Java files
Collection<Path> testJavaSources = listJavaSources(mavenProject, testSourceRoots);
// scan Kotlin files
List<Path> testKotlinSources = listKotlinSources(mavenProject, "test-compile", mavenProject.getBuild().getTestSourceDirectory());
// scan Groovy files
List<Path> testGroovySources = listGroovySources(mavenProject, testSourceRoots);
List<Path> testDependencies = mavenProject.getTestClasspathElements().stream()
.distinct()
.map(Paths::get)
.collect(toList());
JavaTypeCache typeCache = createTypeCache();
javaParserBuilder.classpath(testDependencies).typeCache(typeCache);
kotlinParserBuilder.classpath(testDependencies).typeCache(typeCache);
groovyParserBuilder.classpath(testDependencies).typeCache(typeCache);
if (!testJavaSources.isEmpty()) {
Stream<SourceFile> parsedJava = Stream.of((Supplier<JavaParser>) javaParserBuilder::build)
.map(Supplier::get)
.flatMap(jp -> {
view(ctx).setCharset(getCharset(mavenProject).orElse(null));
return jp.parse(testJavaSources, baseDir, ctx).onClose(() -> view(ctx).setCharset(null));
});
sourceFiles = Stream.concat(sourceFiles, parsedJava);
logDebug(mavenProject, "Scanned " + testJavaSources.size() + " java source files in test scope.");
}
if (!testKotlinSources.isEmpty()) {
Stream<SourceFile> parsedKotlin = Stream.of((Supplier<KotlinParser>) kotlinParserBuilder::build)
.map(Supplier::get)
.flatMap(kp -> {
view(ctx).setCharset(StandardCharsets.UTF_8); // Kotlin requires UTF-8
return kp.parse(testKotlinSources, baseDir, ctx).onClose(() -> view(ctx).setCharset(null));
});
sourceFiles = Stream.concat(sourceFiles, parsedKotlin);
logDebug(mavenProject, "Scanned " + testKotlinSources.size() + " kotlin source files in test scope.");
}
if (!testGroovySources.isEmpty()) {
Stream<SourceFile> parsedGroovy = Stream.of((Supplier<GroovyParser>) groovyParserBuilder::build)
.map(Supplier::get)
.flatMap(gp -> gp.parse(testGroovySources, baseDir, ctx));
sourceFiles = Stream.concat(sourceFiles, parsedGroovy);
logDebug(mavenProject, "Scanned " + testGroovySources.size() + " groovy source files in test scope.");
}
OmniParser omniParser = omniParser(parsedPaths, mavenProject);
for (Resource resource : mavenProject.getTestResources()) {
Path resourcePath = mavenProject.getBasedir().toPath().resolve(resource.getDirectory());
if (Files.exists(resourcePath) && !parsedPaths.contains(resourcePath)) {
List<Path> accepted = omniParser.acceptedPaths(baseDir, resourcePath);
parsedPaths.add(resourcePath);
sourceFiles = Stream.concat(sourceFiles, omniParser.parse(accepted, baseDir, ctx));
parsedPaths.addAll(accepted);
}
}
List<Marker> testProjectProvenance = new ArrayList<>();
testProjectProvenance.add(JavaSourceSet.build("test", testDependencies));
testProjectProvenance.add(getSrcTestJavaVersion(mavenProject));
return sourceFiles
.map(addProvenance(testProjectProvenance));
}
public Xml.@Nullable Document parseMaven(MavenProject mavenProject, List<Marker> projectProvenance, ExecutionContext ctx) throws MojoFailureException {
return parseMaven(singletonList(mavenProject), singletonMap(mavenProject, projectProvenance), ctx).get(mavenProject);
}
public Map<MavenProject, Xml.Document> parseMaven(List<MavenProject> mavenProjects, Map<MavenProject, List<Marker>> projectProvenances, ExecutionContext ctx) throws MojoFailureException {
if (skipMavenParsing) {
logger.info("Skipping Maven parsing...");
return emptyMap();
}
MavenSettings settings = buildSettings();
MavenExecutionContextView mavenExecutionContext = MavenExecutionContextView.view(ctx);
mavenExecutionContext.setMavenSettings(settings);
mavenExecutionContext.setResolutionListener(new MavenLoggingResolutionEventListener(logger));
configureProxy(settings, ctx);
// The default pom cache is enabled as a two-layer cache L1 == in-memory and L2 == RocksDb
// If the flag is set to false, only the default, in-memory cache is used.
MavenPomCache pomCache = pomCacheEnabled ? getPomCache(pomCacheDirectory, logger) : mavenExecutionContext.getPomCache();
mavenExecutionContext.setPomCache(pomCache);
MavenProject topLevelProject = mavenSession.getTopLevelProject();
logInfo(topLevelProject, "Resolving Poms...");
Set<Path> allPoms = new LinkedHashSet<>();
mavenProjects.forEach(p -> collectPoms(p, allPoms, mavenExecutionContext));
for (MavenProject mavenProject : mavenProjects) {
mavenSession.getProjectDependencyGraph().getUpstreamProjects(mavenProject, true).forEach(p -> collectPoms(p, allPoms, mavenExecutionContext));
}
MavenParser.Builder mave
gitextract_bkmjst1t/ ├── .claude/ │ └── settings.json ├── .editorconfig ├── .github/ │ ├── dependabot.yml │ └── workflows/ │ ├── bump-snapshots.yml │ ├── ci.yml │ ├── pages.yml │ ├── publish.yml │ ├── repository-backup.yml │ └── stale.yml ├── .gitignore ├── .mvn/ │ ├── develocity.xml │ ├── extensions.xml │ ├── licenseHeader.txt │ └── wrapper/ │ └── maven-wrapper.properties ├── .sdkmanrc ├── CLAUDE.md ├── LICENSE/ │ └── apache-license-v2.txt ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml ├── rewrite.yml ├── src/ │ ├── main/ │ │ └── java/ │ │ └── org/ │ │ └── openrewrite/ │ │ └── maven/ │ │ ├── AbstractRewriteBaseRunMojo.java │ │ ├── AbstractRewriteDryRunMojo.java │ │ ├── AbstractRewriteMojo.java │ │ ├── AbstractRewriteRunMojo.java │ │ ├── ArtifactResolver.java │ │ ├── ConfigurableRewriteMojo.java │ │ ├── LogLevel.java │ │ ├── MavenLoggingMeterRegistry.java │ │ ├── MavenLoggingResolutionEventListener.java │ │ ├── MavenMojoProjectParser.java │ │ ├── MavenPomCacheBuilder.java │ │ ├── MeterRegistryProvider.java │ │ ├── RecipeCsvGenerateMojo.java │ │ ├── RewriteDiscoverMojo.java │ │ ├── RewriteDryRunMojo.java │ │ ├── RewriteDryRunNoForkMojo.java │ │ ├── RewriteRunMojo.java │ │ ├── RewriteRunNoForkMojo.java │ │ ├── RewriteTypeTableMojo.java │ │ ├── SanitizedMarkerPrinter.java │ │ └── package-info.java │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── openrewrite/ │ │ └── maven/ │ │ ├── AbstractRewriteMojoTest.java │ │ ├── BasicIT.java │ │ ├── DiscoverNoActiveRecipeIT.java │ │ ├── KotlinIT.java │ │ ├── MavenCLIExtra.java │ │ ├── MavenMojoProjectParserIsExcludedTest.java │ │ ├── MavenMojoProjectParserTest.java │ │ ├── RecipeCsvGenerateIT.java │ │ ├── RewriteDiscoverIT.java │ │ ├── RewriteDryRunIT.java │ │ ├── RewriteRunIT.java │ │ ├── RewriteRunParallelIT.java │ │ ├── RewriteTypeTableIT.java │ │ └── jupiter/ │ │ └── extension/ │ │ ├── GitITExtension.java │ │ └── GitJupiterExtension.java │ ├── resources/ │ │ ├── .gitkeep │ │ └── junit-platform.properties │ └── resources-its/ │ └── org/ │ └── openrewrite/ │ └── maven/ │ ├── BasicIT/ │ │ ├── groupid_artifactid_should_be_ok/ │ │ │ └── pom.xml │ │ ├── null_check_profile_activation/ │ │ │ ├── pom.xml │ │ │ └── settings.xml │ │ ├── resolves_maven_properties_from_user_provided_system_properties/ │ │ │ └── pom.xml │ │ ├── resolves_settings/ │ │ │ ├── pom.xml │ │ │ └── settings-user.xml │ │ └── snapshot_ok/ │ │ └── pom.xml │ ├── DiscoverNoActiveRecipeIT/ │ │ └── single_project/ │ │ └── pom.xml │ ├── KotlinIT/ │ │ ├── kotlin_in_src_main_java/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── MyClass.kt │ │ └── kotlin_in_src_main_test/ │ │ ├── pom.xml │ │ └── src/ │ │ └── test/ │ │ └── java/ │ │ └── sample/ │ │ └── MyTest.kt │ ├── RecipeCsvGenerateIT/ │ │ ├── generates_csv_from_java_recipe/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── org/ │ │ │ └── openrewrite/ │ │ │ └── test/ │ │ │ └── SampleJavaRecipe.java │ │ └── generates_csv_from_yaml_recipe/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── resources/ │ │ └── META-INF/ │ │ └── rewrite/ │ │ └── rewrite.yml │ ├── RewriteDiscoverIT/ │ │ ├── RecipeLookup/ │ │ │ ├── rewrite_discover_detail/ │ │ │ │ └── pom.xml │ │ │ ├── rewrite_discover_recipe_lookup_case_insensitive/ │ │ │ │ └── pom.xml │ │ │ └── rewrite_discover_recursion/ │ │ │ └── pom.xml │ │ ├── rewrite_discover_default/ │ │ │ └── pom.xml │ │ ├── rewrite_discover_multi_module/ │ │ │ ├── a/ │ │ │ │ └── pom.xml │ │ │ ├── b/ │ │ │ │ └── pom.xml │ │ │ └── pom.xml │ │ └── rewrite_discover_rewrite_yml/ │ │ ├── pom.xml │ │ └── rewrite.yml │ ├── RewriteDryRunIT/ │ │ ├── fail_on_dry_run/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── BadSpacing.java │ │ ├── multi_module_project/ │ │ │ ├── a/ │ │ │ │ ├── pom.xml │ │ │ │ └── src/ │ │ │ │ └── main/ │ │ │ │ └── java/ │ │ │ │ └── sample/ │ │ │ │ ├── MyInterface.java │ │ │ │ └── SimplifyBooleanSample.java │ │ │ ├── b/ │ │ │ │ ├── pom.xml │ │ │ │ └── src/ │ │ │ │ └── main/ │ │ │ │ └── java/ │ │ │ │ └── sample/ │ │ │ │ └── EmptyBlockSample.java │ │ │ ├── pom.xml │ │ │ └── rewrite.yml │ │ ├── no_plugin_in_pom/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── test/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── SampleTest.java │ │ ├── recipe_order/ │ │ │ ├── pom.xml │ │ │ ├── rewrite.yml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ ├── EmptyBlockSample.java │ │ │ └── SimplifyBooleanSample.java │ │ └── single_project/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── java/ │ │ └── sample/ │ │ ├── EmptyBlockSample.java │ │ └── SimplifyBooleanSample.java │ ├── RewriteRunIT/ │ │ ├── basedir_resource_no_plaintext_leak/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── main/ │ │ │ │ └── java/ │ │ │ │ └── sample/ │ │ │ │ └── Main.java │ │ │ └── test/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── MainTest.java │ │ ├── checkstyle_inline_rules/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── SimplifyBooleanSample.java │ │ ├── cloud_suitability_project/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── resource/ │ │ │ └── some.jks │ │ ├── command_line_options/ │ │ │ └── pom.xml │ │ ├── command_line_options_json/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── SomeClass.java │ │ ├── container_masks/ │ │ │ ├── Containerfile │ │ │ ├── Dockerfile │ │ │ ├── build.dockerfile │ │ │ ├── containerfile.build │ │ │ ├── pom.xml │ │ │ └── rewrite.yml │ │ ├── datatable_export/ │ │ │ ├── pom.xml │ │ │ └── rewrite.yml │ │ ├── java_compiler_plugin_project/ │ │ │ ├── parent/ │ │ │ │ └── pom.xml │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── SimplifyBooleanSample.java │ │ ├── java_upgrade_project/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── MyInterface.java │ │ ├── lombok_jdk25_linkage_error/ │ │ │ ├── .mvn/ │ │ │ │ └── jvm.config │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── main/ │ │ │ │ └── java/ │ │ │ │ └── sample/ │ │ │ │ └── App.java │ │ │ └── test/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── AppTest.java │ │ ├── multi_main_source_sets_project/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── additional-main/ │ │ │ │ └── java/ │ │ │ │ └── sample/ │ │ │ │ └── AdditionalMainClass.java │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── MainClass.java │ │ ├── multi_module_project/ │ │ │ ├── a/ │ │ │ │ ├── pom.xml │ │ │ │ └── src/ │ │ │ │ └── main/ │ │ │ │ └── java/ │ │ │ │ └── sample/ │ │ │ │ ├── MyInterface.java │ │ │ │ └── SimplifyBooleanSample.java │ │ │ ├── b/ │ │ │ │ ├── pom.xml │ │ │ │ └── src/ │ │ │ │ └── main/ │ │ │ │ └── java/ │ │ │ │ └── sample/ │ │ │ │ └── EmptyBlockSample.java │ │ │ ├── pom.xml │ │ │ └── rewrite.yml │ │ ├── multi_module_resources/ │ │ │ ├── a/ │ │ │ │ ├── pom.xml │ │ │ │ └── src/ │ │ │ │ └── main/ │ │ │ │ └── resources/ │ │ │ │ └── example.xml │ │ │ ├── pom.xml │ │ │ └── rewrite.yml │ │ ├── multi_source_sets_project/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── integration-test/ │ │ │ │ └── java/ │ │ │ │ └── sample/ │ │ │ │ └── IntegrationTest.java │ │ │ └── test/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── RegularTest.java │ │ ├── plaintext_masks/ │ │ │ ├── .in-root │ │ │ ├── from-default-list.py │ │ │ ├── in-root.ignored │ │ │ ├── pom.xml │ │ │ ├── rewrite.yml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ ├── Dummy.java │ │ │ └── in-src.ext │ │ ├── recipe_project/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── ThrowingRecipe.java │ │ └── single_project/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── java/ │ │ └── sample/ │ │ ├── EmptyBlockSample.java │ │ └── SimplifyBooleanSample.java │ ├── RewriteRunParallelIT/ │ │ └── multi_module_project/ │ │ ├── a/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ ├── MyInterface.java │ │ │ └── SimplifyBooleanSample.java │ │ ├── b/ │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── sample/ │ │ │ └── EmptyBlockSample.java │ │ ├── pom.xml │ │ └── rewrite.yml │ └── RewriteTypeTableIT/ │ └── typetable_default/ │ └── pom.xml └── suppressions.xml
SYMBOL INDEX (322 symbols across 66 files)
FILE: src/main/java/org/openrewrite/maven/AbstractRewriteBaseRunMojo.java
class AbstractRewriteBaseRunMojo (line 57) | public abstract class AbstractRewriteBaseRunMojo extends AbstractRewrite...
method log (line 72) | protected void log(LogLevel logLevel, CharSequence content) {
method repositoryRoot (line 94) | protected Path repositoryRoot() {
method listResults (line 106) | protected ResultsContainer listResults(ExecutionContext ctx) throws Mo...
method configureRecipeOptions (line 168) | private static void configureRecipeOptions(Recipe recipe, Set<String> ...
method updateOption (line 196) | private static void updateOption(Recipe recipe, Field field, @Nullable...
method convertOptionValue (line 212) | private static @Nullable Object convertOptionValue(String name, @Nulla...
method loadSourceSet (line 234) | protected LargeSourceSet loadSourceSet(Path repositoryRoot, Environmen...
method runRecipe (line 245) | protected List<Result> runRecipe(Recipe recipe, LargeSourceSet sourceS...
method sourcesWithAutoDetectedStyles (line 272) | private List<SourceFile> sourcesWithAutoDetectedStyles(Stream<SourceFi...
method applyAutodetectedStyle (line 296) | private UnaryOperator<SourceFile> applyAutodetectedStyle(Map<Class<? e...
method merge (line 307) | private void merge(ClassLoader targetClassLoader, URLClassLoader sourc...
method stripVersion (line 326) | private String stripVersion(URL jarUrl) {
class ResultsContainer (line 330) | public static class ResultsContainer {
method ResultsContainer (line 337) | public ResultsContainer(Path projectRoot, Collection<Result> results) {
method getFirstException (line 361) | public @Nullable RuntimeException getFirstException() {
method getRecipeErrors (line 385) | private List<RuntimeException> getRecipeErrors(Result result) {
method getProjectRoot (line 402) | public Path getProjectRoot() {
method isNotEmpty (line 406) | public boolean isNotEmpty() {
method newlyEmptyDirectories (line 413) | public List<Path> newlyEmptyDirectories() {
class FencedMarkerPrinter (line 443) | private static class FencedMarkerPrinter implements PrintOutputCaptu...
method beforeSyntax (line 444) | @Override
method afterSyntax (line 449) | @Override
method logRecipesThatMadeChanges (line 456) | protected void logRecipesThatMadeChanges(Result result) {
method logRecipe (line 465) | private void logRecipe(RecipeDescriptor rd, String prefix) {
method estimateTimeSavedSum (line 485) | protected Duration estimateTimeSavedSum(Result result, Duration timeSa...
method formatDuration (line 492) | protected String formatDuration(Duration duration) {
FILE: src/main/java/org/openrewrite/maven/AbstractRewriteDryRunMojo.java
class AbstractRewriteDryRunMojo (line 40) | public class AbstractRewriteDryRunMojo extends AbstractRewriteBaseRunMojo {
method execute (line 52) | @Override
FILE: src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java
class AbstractRewriteMojo (line 46) | @SuppressWarnings("NotNullFieldNotInitialized")
method environment (line 68) | protected Environment environment() throws MojoExecutionException {
class Config (line 72) | static class Config {
method Config (line 76) | Config(InputStream inputStream, URI uri) {
method getConfig (line 82) | @Nullable
method environment (line 109) | protected Environment environment(@Nullable ClassLoader recipeClassLoa...
method executionContext (line 146) | protected ExecutionContext executionContext(List<Throwable> throwables) {
method getBuildRoot (line 153) | protected Path getBuildRoot() {
method collectBasePaths (line 169) | private void collectBasePaths(MavenProject project, Set<Path> paths, P...
method getRecipeArtifactCoordinatesClassloader (line 184) | protected @Nullable URLClassLoader getRecipeArtifactCoordinatesClasslo...
FILE: src/main/java/org/openrewrite/maven/AbstractRewriteRunMojo.java
class AbstractRewriteRunMojo (line 42) | public class AbstractRewriteRunMojo extends AbstractRewriteBaseRunMojo {
method execute (line 44) | @Override
method writeAfter (line 182) | private static void writeAfter(Path root, Result result, ExecutionCont...
FILE: src/main/java/org/openrewrite/maven/ArtifactResolver.java
class ArtifactResolver (line 42) | public class ArtifactResolver {
method ArtifactResolver (line 47) | public ArtifactResolver(RepositorySystem repositorySystem, MavenSessio...
method createArtifact (line 53) | public Artifact createArtifact(String coordinates) throws MojoExecutio...
method resolveArtifactsAndDependencies (line 62) | public Set<Artifact> resolveArtifactsAndDependencies(Set<Artifact> art...
FILE: src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java
class ConfigurableRewriteMojo (line 44) | @SuppressWarnings("FieldMayBeFinal")
method getExclusions (line 90) | protected Set<String> getExclusions() {
method getPlainTextMasks (line 110) | protected Set<String> getPlainTextMasks() {
type State (line 182) | protected enum State {
method putState (line 190) | protected void putState(State state) {
method hasState (line 195) | private boolean hasState(MavenProject project) {
method allProjectsMarked (line 200) | protected boolean allProjectsMarked() {
method getActiveRecipes (line 217) | protected Set<String> getActiveRecipes() {
method getActiveStyles (line 229) | protected Set<String> getActiveStyles() {
method loadStyles (line 241) | protected List<NamedStyles> loadStyles(MavenProject project, Environme...
method toCheckStyleDocument (line 278) | private @Language("XML") String toCheckStyleDocument(final Xpp3Dom dom...
method getRecipeArtifactCoordinates (line 290) | protected Set<String> getRecipeArtifactCoordinates() {
method getCleanedSet (line 302) | private static Set<String> getCleanedSet(@Nullable Set<@Nullable Strin...
FILE: src/main/java/org/openrewrite/maven/LogLevel.java
type LogLevel (line 18) | public enum LogLevel {
FILE: src/main/java/org/openrewrite/maven/MavenLoggingMeterRegistry.java
class MavenLoggingMeterRegistry (line 41) | @NullMarked
method MavenLoggingMeterRegistry (line 45) | public MavenLoggingMeterRegistry(Log log) {
method close (line 50) | @Override
method writeMeter (line 106) | String writeMeter(Meter meter, Printer print) {
method newTimer (line 127) | @Override
method newDistributionSummary (line 132) | @Override
method newCounter (line 137) | @Override
method newGauge (line 142) | @Override
method newFunctionTimer (line 147) | @Override
method newFunctionCounter (line 152) | @Override
method newLongTaskTimer (line 157) | @Override
method newMeter (line 162) | @Override
method defaultHistogramConfig (line 167) | @Override
class Printer (line 175) | class Printer {
method Printer (line 178) | Printer(Meter meter) {
method id (line 182) | String id() {
method count (line 188) | String count(double count) {
method unitlessCount (line 192) | String unitlessCount(double count) {
method time (line 196) | String time(double time) {
method value (line 200) | String value(double value) {
method humanReadableByteCount (line 205) | @SuppressWarnings("StringConcatenationMissingWhitespace")
method humanReadableBaseUnit (line 216) | String humanReadableBaseUnit(double value) {
method getBaseTimeUnit (line 225) | @Override
FILE: src/main/java/org/openrewrite/maven/MavenLoggingResolutionEventListener.java
class MavenLoggingResolutionEventListener (line 24) | class MavenLoggingResolutionEventListener implements ResolutionEventList...
method MavenLoggingResolutionEventListener (line 28) | public MavenLoggingResolutionEventListener(Log logger) {
method downloadSuccess (line 32) | @Override
method downloadError (line 39) | @Override
method repositoryAccessFailed (line 46) | @Override
method pomContaining (line 52) | private static String pomContaining(@Nullable Pom containing) {
method pomContaining (line 56) | private static String pomContaining(@Nullable ResolvedPom containing) {
FILE: src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java
class MavenMojoProjectParser (line 125) | public class MavenMojoProjectParser {
method MavenMojoProjectParser (line 155) | @SuppressWarnings("BooleanParameter")
method createTypeCache (line 173) | protected JavaTypeCache createTypeCache() {
method listSourceFiles (line 177) | public Stream<SourceFile> listSourceFiles(MavenProject mavenProject, L...
method listSourceFiles (line 200) | public Stream<SourceFile> listSourceFiles(MavenProject mavenProject, X...
method listSourceFiles (line 205) | public Stream<SourceFile> listSourceFiles(MavenProject mavenProject, X...
method isExcluded (line 256) | static boolean isExcluded(org.openrewrite.jgit.lib.@Nullable Repositor...
type MavenScope (line 279) | public enum MavenScope {
method getCharset (line 284) | static Optional<Charset> getCharset(MavenProject mavenProject) {
method resolveProperty (line 311) | private static @Nullable String resolveProperty(String value, MavenPro...
method getRepository (line 323) | static org.openrewrite.jgit.lib.@Nullable Repository getRepository(Pat...
method logParseErrors (line 332) | private SourceFile logParseErrors(SourceFile source) {
method generateProvenance (line 346) | public List<Marker> generateProvenance(MavenProject mavenProject) {
method getSrcMainJavaVersion (line 362) | private static JavaVersion getSrcMainJavaVersion(MavenProject mavenPro...
method getSrcTestJavaVersion (line 405) | static JavaVersion getSrcTestJavaVersion(MavenProject mavenProject) {
method getJavaVersionMarker (line 458) | private static JavaVersion getJavaVersionMarker(@Nullable String sourc...
method processMainSources (line 470) | private Stream<SourceFile> processMainSources(
method processTestSources (line 563) | private Stream<SourceFile> processTestSources(
method parseMaven (line 644) | public Xml.@Nullable Document parseMaven(MavenProject mavenProject, Li...
method parseMaven (line 648) | public Map<MavenProject, Xml.Document> parseMaven(List<MavenProject> m...
method collectPoms (line 750) | private void collectPoms(MavenProject project, Set<Path> paths, MavenE...
method pomPath (line 778) | private static Path pomPath(MavenProject mavenProject) {
method getPomCache (line 793) | private static MavenPomCache getPomCache(@Nullable String pomCacheDire...
method buildSettings (line 803) | public MavenSettings buildSettings() {
method configureProxy (line 878) | private void configureProxy(MavenSettings settings, ExecutionContext c...
method buildRawRepositories (line 937) | private static @Nullable RawRepositories buildRawRepositories(@Nullabl...
method pathsToOtherMavenProjects (line 956) | private Set<Path> pathsToOtherMavenProjects(MavenProject mavenProject) {
method addProvenance (line 963) | private <T extends SourceFile> UnaryOperator<T> addProvenance(List<Mar...
method addGitTreeEntryInformation (line 973) | private <T extends SourceFile> UnaryOperator<T> addGitTreeEntryInforma...
method filterGeneratedSourceRoots (line 1003) | private static List<String> filterGeneratedSourceRoots(MavenProject ma...
method listJavaSources (line 1010) | private static Collection<Path> listJavaSources(MavenProject mavenProj...
method listKotlinSources (line 1018) | private List<Path> listKotlinSources(MavenProject mavenProject, String...
method listGroovySources (line 1041) | private static List<Path> listGroovySources(MavenProject mavenProject,...
method listSources (line 1061) | private static List<Path> listSources(Path sourceDirectory, String ext...
method parseMavenWrapperFiles (line 1082) | private Stream<SourceFile> parseMavenWrapperFiles(MavenProject mavenPr...
method parseNonProjectResources (line 1103) | protected Stream<SourceFile> parseNonProjectResources(MavenProject mav...
method omniParser (line 1113) | private OmniParser omniParser(Set<Path> parsedPaths, MavenProject mave...
method mergeExclusions (line 1127) | private Collection<String> mergeExclusions(MavenProject mavenProject) {
method pathMatchers (line 1137) | private Collection<PathMatcher> pathMatchers(Path basePath, Collection...
method gitProvenance (line 1145) | private @Nullable GitProvenance gitProvenance(Path baseDir, @Nullable ...
method logError (line 1156) | private void logError(MavenProject mavenProject, String message) {
method logInfo (line 1160) | private void logInfo(MavenProject mavenProject, String message) {
method logDebug (line 1164) | private void logDebug(MavenProject mavenProject, String message) {
method sneakyThrow (line 1168) | @SuppressWarnings({"RedundantThrows", "unchecked"})
method createResolvedGAV (line 1173) | private static ResolvedGroupArtifactVersion createResolvedGAV(MavenPro...
method createPom (line 1183) | private static @Nullable Pom createPom(MavenProject project) {
FILE: src/main/java/org/openrewrite/maven/MavenPomCacheBuilder.java
class MavenPomCacheBuilder (line 27) | public class MavenPomCacheBuilder {
method MavenPomCacheBuilder (line 30) | public MavenPomCacheBuilder(Log logger) {
method build (line 34) | public @Nullable MavenPomCache build(@Nullable String pomCacheDirector...
method isJvm64Bit (line 59) | private static boolean isJvm64Bit() {
FILE: src/main/java/org/openrewrite/maven/MeterRegistryProvider.java
class MeterRegistryProvider (line 23) | public class MeterRegistryProvider implements AutoCloseable {
method MeterRegistryProvider (line 32) | public MeterRegistryProvider(Log log, @Nullable String destination) {
method registry (line 37) | public MeterRegistry registry() {
method buildRegistry (line 44) | private MeterRegistry buildRegistry() {
method close (line 52) | @Override
FILE: src/main/java/org/openrewrite/maven/RecipeCsvGenerateMojo.java
class RecipeCsvGenerateMojo (line 48) | @Execute(phase = LifecyclePhase.PROCESS_CLASSES)
method execute (line 52) | @Override
FILE: src/main/java/org/openrewrite/maven/RewriteDiscoverMojo.java
class RewriteDiscoverMojo (line 36) | @Mojo(name = "discover", threadSafe = true, requiresProject = false, agg...
method execute (line 61) | @Override
method getRecipeDescriptor (line 80) | private static RecipeDescriptor getRecipeDescriptor(String recipe, Col...
method writeDiscovery (line 87) | private void writeDiscovery(Collection<RecipeDescriptor> availableReci...
method writeRecipeDescriptor (line 124) | private void writeRecipeDescriptor(RecipeDescriptor rd, boolean verbos...
FILE: src/main/java/org/openrewrite/maven/RewriteDryRunMojo.java
class RewriteDryRunMojo (line 29) | @Execute(phase = LifecyclePhase.PROCESS_TEST_CLASSES)
FILE: src/main/java/org/openrewrite/maven/RewriteDryRunNoForkMojo.java
class RewriteDryRunNoForkMojo (line 28) | @Mojo(name = "dryRunNoFork", requiresDependencyResolution = ResolutionSc...
FILE: src/main/java/org/openrewrite/maven/RewriteRunMojo.java
class RewriteRunMojo (line 29) | @Execute(phase = LifecyclePhase.PROCESS_TEST_CLASSES)
FILE: src/main/java/org/openrewrite/maven/RewriteRunNoForkMojo.java
class RewriteRunNoForkMojo (line 28) | @Mojo(name = "runNoFork", requiresDependencyResolution = ResolutionScope...
FILE: src/main/java/org/openrewrite/maven/RewriteTypeTableMojo.java
class RewriteTypeTableMojo (line 39) | @Execute(phase = LifecyclePhase.GENERATE_RESOURCES)
method execute (line 43) | @Override
method resolveArtifacts (line 69) | private Set<Artifact> resolveArtifacts(String recipeArtifactCoordinate...
FILE: src/main/java/org/openrewrite/maven/SanitizedMarkerPrinter.java
class SanitizedMarkerPrinter (line 29) | public class SanitizedMarkerPrinter implements PrintOutputCapture.Marker...
method beforeSyntax (line 30) | @Override
method afterSyntax (line 38) | @Override
FILE: src/test/java/org/openrewrite/maven/AbstractRewriteMojoTest.java
class AbstractRewriteMojoTest (line 38) | class AbstractRewriteMojoTest {
method resolvePropertiesInYamlUsesUserProperties (line 40) | @Test
method configLocation (line 79) | @ParameterizedTest
FILE: src/test/java/org/openrewrite/maven/BasicIT.java
class BasicIT (line 25) | @GitJupiterExtension
method groupid_artifactid_should_be_ok (line 31) | @MavenGoal("clean")
method null_check_profile_activation (line 42) | @Disabled
method resolves_maven_properties_from_user_provided_system_properties (line 62) | @MavenGoal("${project.groupId}:${project.artifactId}:${project.version...
method resolves_settings (line 74) | @MavenGoal("${project.groupId}:${project.artifactId}:${project.version...
method snapshot_ok (line 87) | @MavenGoal("clean")
FILE: src/test/java/org/openrewrite/maven/DiscoverNoActiveRecipeIT.java
class DiscoverNoActiveRecipeIT (line 23) | @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:...
method single_project (line 29) | @MavenTest
FILE: src/test/java/org/openrewrite/maven/KotlinIT.java
class KotlinIT (line 26) | @DisabledOnOs(OS.WINDOWS)
method kotlin_in_src_main_java (line 35) | @MavenTest
method kotlin_in_src_main_test (line 45) | @MavenTest
FILE: src/test/java/org/openrewrite/maven/MavenCLIExtra.java
class MavenCLIExtra (line 18) | final class MavenCLIExtra
FILE: src/test/java/org/openrewrite/maven/MavenMojoProjectParserIsExcludedTest.java
class MavenMojoProjectParserIsExcludedTest (line 42) | class MavenMojoProjectParserIsExcludedTest {
method untrackedGitIgnoredFileIsExcluded (line 44) | @Test
method trackedGitIgnoredFileIsNotExcluded (line 61) | @Test
method untrackedFileInGitIgnoredDirectoryIsExcluded (line 80) | @Test
method trackedFileInGitIgnoredDirectoryIsNotExcluded (line 97) | @Test
method exclusionMatcherMatchesDirectly (line 116) | @Test
method exclusionMatcherDoesNotMatchUnrelatedPath (line 126) | @Test
method exclusionMatcherMatchesRootFileViaPrefixedSlash (line 136) | @Test
method exclusionMatcherMatchesRootFileWithLeadingSlash (line 148) | @Test
method exclusionMatcherMatchesSubdirFileWithoutPrefixing (line 160) | @Test
method writeFile (line 171) | private static void writeFile(Path path, String content) throws Except...
FILE: src/test/java/org/openrewrite/maven/MavenMojoProjectParserTest.java
class MavenMojoProjectParserTest (line 35) | class MavenMojoProjectParserTest {
method givenNoJavaVersionInformationExistsInMavenThenJavaSpecificationVersionShouldBeUsed (line 36) | @DisplayName("Given No Java version information exists in Maven Then j...
method getCharsetShouldResolveEncodingFromPropertyPlaceholder (line 44) | @DisplayName("getCharset should resolve encoding from property placeho...
method getCharsetShouldReturnEmptyWhenPropertyPlaceholderIsUnresolved (line 71) | @DisplayName("getCharset should return empty when property placeholder...
method getCharsetShouldNotThrowWhenSourceEncodingIsPropertyPlaceholder (line 100) | @DisplayName("getCharset should not throw when project.build.sourceEnc...
method getCharsetShouldReturnCharsetWhenEncodingIsValid (line 116) | @DisplayName("getCharset should return charset when encoding is valid")
FILE: src/test/java/org/openrewrite/maven/RecipeCsvGenerateIT.java
class RecipeCsvGenerateIT (line 23) | @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:...
method generates_csv_from_yaml_recipe (line 29) | @MavenTest
method generates_csv_from_java_recipe (line 39) | @MavenTest
FILE: src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java
class RewriteDiscoverIT (line 24) | @MavenGoal("clean")
class RecipeLookup (line 31) | @Nested
method rewrite_discover_detail (line 34) | @MavenTest
method rewrite_discover_recipe_lookup_case_insensitive (line 46) | @MavenTest
method rewrite_discover_recursion (line 56) | @MavenTest
method rewrite_discover_default (line 69) | @MavenTest
method rewrite_discover_rewrite_yml (line 85) | @MavenTest
method rewrite_discover_multi_module (line 96) | @MavenTest
FILE: src/test/java/org/openrewrite/maven/RewriteDryRunIT.java
class RewriteDryRunIT (line 24) | @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:...
method fail_on_dry_run (line 32) | @MavenTest
method multi_module_project (line 41) | @MavenTest
method recipe_order (line 50) | @MavenTest
method single_project (line 59) | @MavenTest
method no_plugin_in_pom (line 68) | @MavenTest
FILE: src/test/java/org/openrewrite/maven/RewriteRunIT.java
class RewriteRunIT (line 37) | @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:...
method multi_module_project (line 44) | @MavenTest
method multi_module_resources (line 53) | @MavenTest
method multi_source_sets_project (line 63) | @MavenGoal("generate-test-sources")
method multi_main_source_sets_project (line 78) | @MavenGoal("generate-sources")
method basedir_resource_no_plaintext_leak (line 92) | @MavenTest
method single_project (line 104) | @MavenTest
method checkstyle_inline_rules (line 113) | @MavenTest
method recipe_project (line 122) | @MavenTest
method cloud_suitability_project (line 131) | @MavenTest
method command_line_options (line 140) | @MavenTest
method command_line_options_json (line 153) | @DisabledOnOs(value = OS.WINDOWS, disabledReason = "Quotes for comment...
method java_upgrade_project (line 168) | @MavenTest
method java_compiler_plugin_project (line 178) | @MavenTest
method container_masks (line 188) | @MavenTest
method datatable_export (line 202) | @MavenTest
method plaintext_masks (line 254) | @MavenTest
method lombok_jdk25_linkage_error (line 275) | @MavenTest
FILE: src/test/java/org/openrewrite/maven/RewriteRunParallelIT.java
class RewriteRunParallelIT (line 26) | @DisabledOnOs(OS.WINDOWS)
method multi_module_project (line 35) | @MavenTest
FILE: src/test/java/org/openrewrite/maven/RewriteTypeTableIT.java
class RewriteTypeTableIT (line 24) | @MavenJupiterExtension
method typetable_default (line 30) | @MavenTest
FILE: src/test/java/org/openrewrite/maven/jupiter/extension/GitITExtension.java
class GitITExtension (line 26) | class GitITExtension implements BeforeEachCallback {
method beforeEach (line 27) | @Override
method getMavenBaseDir (line 40) | static Path getMavenBaseDir() {
method toFullyQualifiedPath (line 44) | static String toFullyQualifiedPath(Class<?> testClass) {
method getTargetDir (line 51) | static Path getTargetDir() {
FILE: src/test/resources-its/org/openrewrite/maven/RecipeCsvGenerateIT/generates_csv_from_java_recipe/src/main/java/org/openrewrite/test/SampleJavaRecipe.java
class SampleJavaRecipe (line 7) | public class SampleJavaRecipe extends Recipe {
method getDisplayName (line 9) | @Override
method getDescription (line 14) | @Override
method getVisitor (line 19) | @Override
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/fail_on_dry_run/src/main/java/sample/BadSpacing.java
class BadSpacing (line 3) | public class BadSpacing {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/a/src/main/java/sample/MyInterface.java
type MyInterface (line 3) | public interface MyInterface {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/a/src/main/java/sample/SimplifyBooleanSample.java
class SimplifyBooleanSample (line 3) | public class SimplifyBooleanSample {
method ifNoElse (line 4) | boolean ifNoElse() {
method isOddMillis (line 11) | static boolean isOddMillis() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/b/src/main/java/sample/EmptyBlockSample.java
class EmptyBlockSample (line 7) | public class EmptyBlockSample implements MyInterface {
method sideEffect (line 13) | int sideEffect() {
method boolSideEffect (line 17) | boolean boolSideEffect() {
method lotsOfIfs (line 21) | public void lotsOfIfs() {
method emptyTry (line 32) | public void emptyTry() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/no_plugin_in_pom/src/test/java/sample/SampleTest.java
class SampleTest (line 7) | public class SampleTest {
method testMethod (line 8) | @Test
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/recipe_order/src/main/java/sample/EmptyBlockSample.java
class EmptyBlockSample (line 7) | public class EmptyBlockSample {
method sideEffect (line 13) | int sideEffect() {
method boolSideEffect (line 17) | boolean boolSideEffect() {
method lotsOfIfs (line 21) | public void lotsOfIfs() {
method emptyTry (line 32) | public void emptyTry() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/recipe_order/src/main/java/sample/SimplifyBooleanSample.java
class SimplifyBooleanSample (line 3) | public class SimplifyBooleanSample {
method ifNoElse (line 4) | boolean ifNoElse() {
method isOddMillis (line 11) | static boolean isOddMillis() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/single_project/src/main/java/sample/EmptyBlockSample.java
class EmptyBlockSample (line 6) | public class EmptyBlockSample {
method sideEffect (line 12) | int sideEffect() {
method boolSideEffect (line 16) | boolean boolSideEffect() {
method lotsOfIfs (line 20) | public void lotsOfIfs() {
method emptyTry (line 31) | public void emptyTry() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/single_project/src/main/java/sample/SimplifyBooleanSample.java
class SimplifyBooleanSample (line 3) | public class SimplifyBooleanSample {
method ifNoElse (line 4) | boolean ifNoElse() {
method isOddMillis (line 11) | static boolean isOddMillis() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/basedir_resource_no_plaintext_leak/src/main/java/sample/Main.java
class Main (line 3) | public class Main {
method hello (line 4) | public void hello() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/basedir_resource_no_plaintext_leak/src/test/java/sample/MainTest.java
class MainTest (line 3) | public class MainTest {
method test (line 4) | public void test() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/checkstyle_inline_rules/src/main/java/sample/SimplifyBooleanSample.java
class SimplifyBooleanSample (line 3) | public class SimplifyBooleanSample {
method ifNoElse (line 4) | boolean ifNoElse() {
method isOddMillis (line 11) | static boolean isOddMillis() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/command_line_options_json/src/main/java/sample/SomeClass.java
class SomeClass (line 3) | public class SomeClass {
method doTheThing (line 4) | public void doTheThing() {}
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/java_compiler_plugin_project/src/main/java/sample/SimplifyBooleanSample.java
class SimplifyBooleanSample (line 3) | public class SimplifyBooleanSample {
method ifNoElse (line 4) | boolean ifNoElse() {
method isOddMillis (line 11) | static boolean isOddMillis() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/java_upgrade_project/src/main/java/sample/MyInterface.java
type MyInterface (line 3) | public interface MyInterface {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/lombok_jdk25_linkage_error/src/main/java/sample/App.java
class App (line 7) | @Data
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/lombok_jdk25_linkage_error/src/test/java/sample/AppTest.java
class AppTest (line 3) | public class AppTest {
method testApp (line 4) | void testApp() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_main_source_sets_project/src/additional-main/java/sample/AdditionalMainClass.java
class AdditionalMainClass (line 3) | public class AdditionalMainClass {
method method (line 5) | public void method() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_main_source_sets_project/src/main/java/sample/MainClass.java
class MainClass (line 3) | public class MainClass {
method method (line 5) | public void method() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/a/src/main/java/sample/MyInterface.java
type MyInterface (line 3) | public interface MyInterface {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/a/src/main/java/sample/SimplifyBooleanSample.java
class SimplifyBooleanSample (line 3) | public class SimplifyBooleanSample {
method ifNoElse (line 4) | boolean ifNoElse() {
method isOddMillis (line 11) | static boolean isOddMillis() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/b/src/main/java/sample/EmptyBlockSample.java
class EmptyBlockSample (line 7) | public class EmptyBlockSample implements MyInterface {
method sideEffect (line 13) | int sideEffect() {
method boolSideEffect (line 17) | boolean boolSideEffect() {
method lotsOfIfs (line 21) | public void lotsOfIfs() {
method emptyTry (line 32) | public void emptyTry() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_source_sets_project/src/integration-test/java/sample/IntegrationTest.java
class IntegrationTest (line 5) | class IntegrationTest {
method testBar (line 6) | @Test
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_source_sets_project/src/test/java/sample/RegularTest.java
class RegularTest (line 5) | class RegularTest {
method testBar (line 6) | @Test
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/plaintext_masks/src/main/java/sample/Dummy.java
class Dummy (line 3) | public class Dummy {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/recipe_project/src/main/java/sample/ThrowingRecipe.java
class ThrowingRecipe (line 14) | public class ThrowingRecipe extends Recipe {
method getDisplayName (line 16) | @Override
method getDescription (line 21) | @Override
method getVisitor (line 26) | @Override
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/single_project/src/main/java/sample/EmptyBlockSample.java
class EmptyBlockSample (line 7) | public class EmptyBlockSample {
method sideEffect (line 13) | int sideEffect() {
method boolSideEffect (line 17) | boolean boolSideEffect() {
method lotsOfIfs (line 21) | public void lotsOfIfs() {
method emptyTry (line 32) | public void emptyTry() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunIT/single_project/src/main/java/sample/SimplifyBooleanSample.java
class SimplifyBooleanSample (line 3) | public class SimplifyBooleanSample {
method ifNoElse (line 4) | boolean ifNoElse() {
method isOddMillis (line 11) | static boolean isOddMillis() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/a/src/main/java/sample/MyInterface.java
type MyInterface (line 3) | public interface MyInterface {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/a/src/main/java/sample/SimplifyBooleanSample.java
class SimplifyBooleanSample (line 3) | public class SimplifyBooleanSample {
method ifNoElse (line 4) | boolean ifNoElse() {
method isOddMillis (line 11) | static boolean isOddMillis() {
FILE: src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/b/src/main/java/sample/EmptyBlockSample.java
class EmptyBlockSample (line 5) | public class EmptyBlockSample {
method sideEffect (line 11) | int sideEffect() {
Condensed preview — 168 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (419K chars).
[
{
"path": ".claude/settings.json",
"chars": 1045,
"preview": "{\n \"permissions\": {\n \"allow\": [\n \"Bash(./gradlew:*)\",\n \"Bash(cat:*)\",\n \"Bash(echo:*)\",\n \"Bash(fi"
},
{
"path": ".editorconfig",
"chars": 151,
"preview": "root = true\n\n[*]\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[src/test*/java/**.java]\nindent_size = 4\ni"
},
{
"path": ".github/dependabot.yml",
"chars": 362,
"preview": "---\nversion: 2\nupdates:\n - package-ecosystem: github-actions\n directory: /\n schedule:\n interval: weekly\n "
},
{
"path": ".github/workflows/bump-snapshots.yml",
"chars": 931,
"preview": "---\nname: bump-snapshots\n\non:\n workflow_dispatch: {}\n schedule:\n - cron: 0 11 * * THU\n\njobs:\n bump-snapshots:\n "
},
{
"path": ".github/workflows/ci.yml",
"chars": 2696,
"preview": "---\nname: ci\n\non:\n push:\n branches:\n - main\n tags-ignore:\n - \"*\"\n pull_request:\n branches:\n - "
},
{
"path": ".github/workflows/pages.yml",
"chars": 1340,
"preview": "# Simple workflow for deploying static content to GitHub Pages\nname: Deploy plugin docs to Pages\n\non:\n push:\n tags:\n"
},
{
"path": ".github/workflows/publish.yml",
"chars": 3025,
"preview": "---\nname: publish\n\non:\n workflow_dispatch:\n inputs:\n version:\n description: 'Project version to set befo"
},
{
"path": ".github/workflows/repository-backup.yml",
"chars": 553,
"preview": "---\nname: repository-backup\non:\n workflow_dispatch: {}\n schedule:\n - cron: 0 17 * * *\n\nconcurrency:\n group: backup"
},
{
"path": ".github/workflows/stale.yml",
"chars": 165,
"preview": "---\nname: stale\n\non:\n workflow_dispatch: {}\n schedule:\n - cron: 36 4 * * 1\n\njobs:\n build:\n uses: openrewrite/gh"
},
{
"path": ".gitignore",
"chars": 198,
"preview": "build/\ntarget/\nry/\nrelease.properties\npom.xml.releaseBackup\npom.xml.versionsBackup\n.idea/\n*.iml\n.classpath\n.project\n.set"
},
{
"path": ".mvn/develocity.xml",
"chars": 700,
"preview": "<develocity>\n <server>\n <url>https://ge.openrewrite.org/</url>\n </server>\n <buildScan>\n <publishing>\n <onl"
},
{
"path": ".mvn/extensions.xml",
"chars": 175,
"preview": "<extensions>\n <extension>\n <groupId>com.gradle</groupId>\n <artifactId>develocity-maven-extension</artifactId>\n "
},
{
"path": ".mvn/licenseHeader.txt",
"chars": 581,
"preview": "Copyright ${year} the original author or authors.\n<p>\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyo"
},
{
"path": ".mvn/wrapper/maven-wrapper.properties",
"chars": 166,
"preview": "wrapperVersion=3.3.2\ndistributionType=only-script\ndistributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/"
},
{
"path": ".sdkmanrc",
"chars": 113,
"preview": "# Enable auto-env through the sdkman_auto_env config\n# Add key=value pairs of SDKs to use below\njava=21.0.10-tem\n"
},
{
"path": "CLAUDE.md",
"chars": 5642,
"preview": "<!-- prethink-context -->\n## Moderne Prethink Context\n\nThis repository contains pre-analyzed context generated by [Moder"
},
{
"path": "LICENSE/apache-license-v2.txt",
"chars": 11358,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 6906,
"preview": "<p align=\"center\">\n <a href=\"https://docs.openrewrite.org\">\n <picture>\n <source media=\"(prefers-color-scheme: d"
},
{
"path": "mvnw",
"chars": 10665,
"preview": "#!/bin/sh\n# ----------------------------------------------------------------------------\n# Licensed to the Apache Softwa"
},
{
"path": "mvnw.cmd",
"chars": 7061,
"preview": "<# : batch portion\r\n@REM ----------------------------------------------------------------------------\r\n@REM Licensed to "
},
{
"path": "pom.xml",
"chars": 25265,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "rewrite.yml",
"chars": 1817,
"preview": "#\n# Copyright 2020 the original author or authors.\n# <p>\n# Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "src/main/java/org/openrewrite/maven/AbstractRewriteBaseRunMojo.java",
"chars": 22653,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/AbstractRewriteDryRunMojo.java",
"chars": 7385,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java",
"chars": 7946,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/AbstractRewriteRunMojo.java",
"chars": 12150,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/ArtifactResolver.java",
"chars": 3768,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java",
"chars": 12320,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/LogLevel.java",
"chars": 722,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/MavenLoggingMeterRegistry.java",
"chars": 10053,
"preview": "/*\r\n * Copyright 2020 the original author or authors.\r\n * <p>\r\n * Licensed under the Apache License, Version 2.0 (the \"L"
},
{
"path": "src/main/java/org/openrewrite/maven/MavenLoggingResolutionEventListener.java",
"chars": 2127,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java",
"chars": 60110,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/MavenPomCacheBuilder.java",
"chars": 2470,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/MeterRegistryProvider.java",
"chars": 1752,
"preview": "/*\r\n * Copyright 2020 the original author or authors.\r\n * <p>\r\n * Licensed under the Apache License, Version 2.0 (the \"L"
},
{
"path": "src/main/java/org/openrewrite/maven/RecipeCsvGenerateMojo.java",
"chars": 5108,
"preview": "/*\n * Copyright 2026 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/RewriteDiscoverMojo.java",
"chars": 7448,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/RewriteDryRunMojo.java",
"chars": 1486,
"preview": "/*\r\n * Copyright 2020 the original author or authors.\r\n * <p>\r\n * Licensed under the Apache License, Version 2.0 (the \"L"
},
{
"path": "src/main/java/org/openrewrite/maven/RewriteDryRunNoForkMojo.java",
"chars": 1410,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/RewriteRunMojo.java",
"chars": 1434,
"preview": "/*\r\n * Copyright 2020 the original author or authors.\r\n * <p>\r\n * Licensed under the Apache License, Version 2.0 (the \"L"
},
{
"path": "src/main/java/org/openrewrite/maven/RewriteRunNoForkMojo.java",
"chars": 1288,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/RewriteTypeTableMojo.java",
"chars": 3407,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/SanitizedMarkerPrinter.java",
"chars": 1627,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/main/java/org/openrewrite/maven/package-info.java",
"chars": 692,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/AbstractRewriteMojoTest.java",
"chars": 3754,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/BasicIT.java",
"chars": 4046,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/DiscoverNoActiveRecipeIT.java",
"chars": 1392,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/KotlinIT.java",
"chars": 2101,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/MavenCLIExtra.java",
"chars": 931,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/MavenMojoProjectParserIsExcludedTest.java",
"chars": 7504,
"preview": "/*\n * Copyright 2026 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/MavenMojoProjectParserTest.java",
"chars": 5956,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/RecipeCsvGenerateIT.java",
"chars": 1781,
"preview": "/*\n * Copyright 2026 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java",
"chars": 3567,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/RewriteDryRunIT.java",
"chars": 3130,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/RewriteRunIT.java",
"chars": 12117,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/RewriteRunParallelIT.java",
"chars": 1925,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/RewriteTypeTableIT.java",
"chars": 1942,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/jupiter/extension/GitITExtension.java",
"chars": 2191,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/java/org/openrewrite/maven/jupiter/extension/GitJupiterExtension.java",
"chars": 908,
"preview": "/*\n * Copyright 2020 the original author or authors.\n * <p>\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "src/test/resources/.gitkeep",
"chars": 0,
"preview": ""
},
{
"path": "src/test/resources/junit-platform.properties",
"chars": 784,
"preview": "#\n# Copyright 2025 the original author or authors.\n# <p>\n# Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "src/test/resources-its/org/openrewrite/maven/BasicIT/groupid_artifactid_should_be_ok/pom.xml",
"chars": 1248,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/BasicIT/null_check_profile_activation/pom.xml",
"chars": 1212,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/BasicIT/null_check_profile_activation/settings.xml",
"chars": 711,
"preview": "<settings xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/BasicIT/resolves_maven_properties_from_user_provided_system_properties/pom.xml",
"chars": 1835,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/BasicIT/resolves_settings/pom.xml",
"chars": 1188,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/BasicIT/resolves_settings/settings-user.xml",
"chars": 583,
"preview": "<settings xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/BasicIT/snapshot_ok/pom.xml",
"chars": 1185,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/DiscoverNoActiveRecipeIT/single_project/pom.xml",
"chars": 1181,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/KotlinIT/kotlin_in_src_main_java/pom.xml",
"chars": 4187,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/KotlinIT/kotlin_in_src_main_java/src/main/java/sample/MyClass.kt",
"chars": 48,
"preview": " package sample\n\n class MyClass {\n\n }\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/KotlinIT/kotlin_in_src_main_test/pom.xml",
"chars": 4187,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/KotlinIT/kotlin_in_src_main_test/src/test/java/sample/MyTest.kt",
"chars": 43,
"preview": "package sample\n\n class MyTest {\n }\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RecipeCsvGenerateIT/generates_csv_from_java_recipe/pom.xml",
"chars": 1153,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RecipeCsvGenerateIT/generates_csv_from_java_recipe/src/main/java/org/openrewrite/test/SampleJavaRecipe.java",
"chars": 530,
"preview": "package org.openrewrite.test;\n\nimport org.openrewrite.ExecutionContext;\nimport org.openrewrite.Recipe;\nimport org.openre"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RecipeCsvGenerateIT/generates_csv_from_yaml_recipe/pom.xml",
"chars": 1148,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RecipeCsvGenerateIT/generates_csv_from_yaml_recipe/src/main/resources/META-INF/rewrite/rewrite.yml",
"chars": 241,
"preview": "---\ntype: specs.openrewrite.org/v1beta/recipe\nname: org.openrewrite.test.TestRecipe\ndisplayName: Test recipe\ndescription"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/RecipeLookup/rewrite_discover_detail/pom.xml",
"chars": 784,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/RecipeLookup/rewrite_discover_recipe_lookup_case_insensitive/pom.xml",
"chars": 832,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/RecipeLookup/rewrite_discover_recursion/pom.xml",
"chars": 790,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/rewrite_discover_default/pom.xml",
"chars": 1156,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/rewrite_discover_multi_module/a/pom.xml",
"chars": 507,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mave"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/rewrite_discover_multi_module/b/pom.xml",
"chars": 507,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mave"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/rewrite_discover_multi_module/pom.xml",
"chars": 1176,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mave"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/rewrite_discover_rewrite_yml/pom.xml",
"chars": 1263,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDiscoverIT/rewrite_discover_rewrite_yml/rewrite.yml",
"chars": 156,
"preview": "---\r\ntype: specs.openrewrite.org/v1beta/recipe\r\nname: com.example.RewriteDiscoverIT.CodeCleanup\r\nrecipeList:\r\n - org.op"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/fail_on_dry_run/pom.xml",
"chars": 1293,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/fail_on_dry_run/src/main/java/sample/BadSpacing.java",
"chars": 62,
"preview": "package sample;\n\npublic class BadSpacing {\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/a/pom.xml",
"chars": 512,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/a/src/main/java/sample/MyInterface.java",
"chars": 50,
"preview": "package sample;\n\npublic interface MyInterface {\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/a/src/main/java/sample/SimplifyBooleanSample.java",
"chars": 389,
"preview": "package sample;\n\npublic class SimplifyBooleanSample {\n boolean ifNoElse() {\n if (isOddMillis()) {\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/b/pom.xml",
"chars": 730,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/b/src/main/java/sample/EmptyBlockSample.java",
"chars": 812,
"preview": "package sample;\n\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.Random;\n\npublic class EmptyBlo"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/pom.xml",
"chars": 1857,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/multi_module_project/rewrite.yml",
"chars": 287,
"preview": "---\r\ntype: specs.openrewrite.org/v1beta/recipe\r\nname: com.example.RewriteDryRunIT.CodeCleanup\r\nrecipeList:\r\n - org.open"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/no_plugin_in_pom/pom.xml",
"chars": 1170,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/no_plugin_in_pom/src/test/java/sample/SampleTest.java",
"chars": 244,
"preview": "package sample;\n\nimport org.junit.jupiter.api.Test;\n\nimport static org.junit.jupiter.api.Assertions.assertTrue;\n\npublic "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/recipe_order/pom.xml",
"chars": 1949,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/recipe_order/rewrite.yml",
"chars": 287,
"preview": "---\r\ntype: specs.openrewrite.org/v1beta/recipe\r\nname: com.example.RewriteDryRunIT.CodeCleanup\r\nrecipeList:\r\n - org.open"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/recipe_order/src/main/java/sample/EmptyBlockSample.java",
"chars": 789,
"preview": "package sample;\n\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.Random;\n\npublic class EmptyBlo"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/recipe_order/src/main/java/sample/SimplifyBooleanSample.java",
"chars": 389,
"preview": "package sample;\n\npublic class SimplifyBooleanSample {\n boolean ifNoElse() {\n if (isOddMillis()) {\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/single_project/pom.xml",
"chars": 1222,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/single_project/src/main/java/sample/EmptyBlockSample.java",
"chars": 757,
"preview": "package sample;\n\nimport java.nio.file.*;\nimport java.util.Random;\n\npublic class EmptyBlockSample {\n int n = sideEffec"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteDryRunIT/single_project/src/main/java/sample/SimplifyBooleanSample.java",
"chars": 389,
"preview": "package sample;\n\npublic class SimplifyBooleanSample {\n boolean ifNoElse() {\n if (isOddMillis()) {\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/basedir_resource_no_plaintext_leak/pom.xml",
"chars": 1733,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/basedir_resource_no_plaintext_leak/src/main/java/sample/Main.java",
"chars": 91,
"preview": "package sample;\n\npublic class Main {\n public void hello() {\n if(true) {}\n }\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/basedir_resource_no_plaintext_leak/src/test/java/sample/MainTest.java",
"chars": 94,
"preview": "package sample;\n\npublic class MainTest {\n public void test() {\n if(true) {}\n }\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/checkstyle_inline_rules/pom.xml",
"chars": 1929,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/checkstyle_inline_rules/src/main/java/sample/SimplifyBooleanSample.java",
"chars": 389,
"preview": "package sample;\n\npublic class SimplifyBooleanSample {\n boolean ifNoElse() {\n if (isOddMillis()) {\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/cloud_suitability_project/pom.xml",
"chars": 1539,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/cloud_suitability_project/src/main/resource/some.jks",
"chars": 0,
"preview": ""
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/command_line_options/pom.xml",
"chars": 981,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/command_line_options_json/pom.xml",
"chars": 986,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/command_line_options_json/src/main/java/sample/SomeClass.java",
"chars": 76,
"preview": "package sample;\n\npublic class SomeClass {\n public void doTheThing() {}\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/container_masks/Containerfile",
"chars": 47,
"preview": "FROM alpine:latest\nCMD [\"echo\", \"Hello World\"]\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/container_masks/Dockerfile",
"chars": 47,
"preview": "FROM alpine:latest\nCMD [\"echo\", \"Hello World\"]\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/container_masks/build.dockerfile",
"chars": 47,
"preview": "FROM alpine:latest\nCMD [\"echo\", \"Hello World\"]\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/container_masks/containerfile.build",
"chars": 47,
"preview": "FROM alpine:latest\nCMD [\"echo\", \"Hello World\"]\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/container_masks/pom.xml",
"chars": 1411,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/container_masks/rewrite.yml",
"chars": 217,
"preview": "---\ntype: specs.openrewrite.org/v1beta/recipe\nname: com.example.RewriteRunIT.ContainerMasks\n\nrecipeList:\n - org.openrew"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/datatable_export/pom.xml",
"chars": 1319,
"preview": "<project>\n <modelVersion>4.0.0</modelVersion>\n <groupId>com.mycompany.app</groupId>\n <artifactId>my-app</artifa"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/datatable_export/rewrite.yml",
"chars": 472,
"preview": "type: specs.openrewrite.org/v1beta/recipe\nname: com.github.timtebeek.FindBoth\ndisplayName: Find dependencies\ndescription"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/java_compiler_plugin_project/parent/pom.xml",
"chars": 585,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/java_compiler_plugin_project/pom.xml",
"chars": 1683,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/java_compiler_plugin_project/src/main/java/sample/SimplifyBooleanSample.java",
"chars": 393,
"preview": "package sample;\n\npublic class SimplifyBooleanSample {\n boolean ifNoElse() {\n if (isOddMillis()) {\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/java_upgrade_project/pom.xml",
"chars": 1518,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/java_upgrade_project/src/main/java/sample/MyInterface.java",
"chars": 50,
"preview": "package sample;\n\npublic interface MyInterface {\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/lombok_jdk25_linkage_error/.mvn/jvm.config",
"chars": 513,
"preview": "--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED\n--add-exports jdk.compiler/com.sun.tools.javac.tree=AL"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/lombok_jdk25_linkage_error/pom.xml",
"chars": 2143,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/lombok_jdk25_linkage_error/src/main/java/sample/App.java",
"chars": 203,
"preview": "package sample;\n\nimport lombok.Data;\nimport lombok.Builder;\nimport lombok.With;\n\n@Data\n@Builder\npublic class App {\n @"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/lombok_jdk25_linkage_error/src/test/java/sample/AppTest.java",
"chars": 289,
"preview": "package sample;\n\npublic class AppTest {\n void testApp() {\n // GIVEN\n var name = \"test\";\n var cou"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_main_source_sets_project/pom.xml",
"chars": 1552,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mave"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_main_source_sets_project/src/additional-main/java/sample/AdditionalMainClass.java",
"chars": 172,
"preview": "package sample;\n\npublic class AdditionalMainClass {\n //This is a test class\n public void method() {\n System"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_main_source_sets_project/src/main/java/sample/MainClass.java",
"chars": 151,
"preview": "package sample;\n\npublic class MainClass {\n //This is a test class\n public void method() {\n System.out.print"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/a/pom.xml",
"chars": 512,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/a/src/main/java/sample/MyInterface.java",
"chars": 50,
"preview": "package sample;\n\npublic interface MyInterface {\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/a/src/main/java/sample/SimplifyBooleanSample.java",
"chars": 389,
"preview": "package sample;\n\npublic class SimplifyBooleanSample {\n boolean ifNoElse() {\n if (isOddMillis()) {\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/b/pom.xml",
"chars": 730,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/b/src/main/java/sample/EmptyBlockSample.java",
"chars": 812,
"preview": "package sample;\n\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.Random;\n\npublic class EmptyBlo"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/pom.xml",
"chars": 1851,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_project/rewrite.yml",
"chars": 284,
"preview": "---\r\ntype: specs.openrewrite.org/v1beta/recipe\r\nname: com.example.RewriteRunIT.CodeCleanup\r\nrecipeList:\r\n - org.openrew"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_resources/a/pom.xml",
"chars": 500,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mave"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_resources/a/src/main/resources/example.xml",
"chars": 15,
"preview": "<foo>bar</foo>\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_resources/pom.xml",
"chars": 1766,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mave"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_module_resources/rewrite.yml",
"chars": 200,
"preview": "---\ntype: specs.openrewrite.org/v1beta/recipe\nname: bug.report.ChangeTag\ndisplayName: Change XML tag name\nrecipeList:\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_source_sets_project/pom.xml",
"chars": 2086,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_source_sets_project/src/integration-test/java/sample/IntegrationTest.java",
"chars": 111,
"preview": "package sample;\n\nimport org.junit.jupiter.api.Test;\n\nclass IntegrationTest {\n @Test\n void testBar() {}\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/multi_source_sets_project/src/test/java/sample/RegularTest.java",
"chars": 107,
"preview": "package sample;\n\nimport org.junit.jupiter.api.Test;\n\nclass RegularTest {\n @Test\n void testBar() {}\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/plaintext_masks/.in-root",
"chars": 6,
"preview": "findMe"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/plaintext_masks/from-default-list.py",
"chars": 7,
"preview": "findMe\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/plaintext_masks/in-root.ignored",
"chars": 6,
"preview": "findMe"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/plaintext_masks/pom.xml",
"chars": 1730,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/plaintext_masks/rewrite.yml",
"chars": 212,
"preview": "---\ntype: specs.openrewrite.org/v1beta/recipe\nname: com.example.RewriteRunIT.PlainTextMasks\n\nrecipeList:\n - org.openrew"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/plaintext_masks/src/main/java/sample/Dummy.java",
"chars": 91,
"preview": "package sample;\n\npublic class Dummy {\n private static final String findMe = \"findMe\";\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/plaintext_masks/src/main/java/sample/in-src.ext",
"chars": 6,
"preview": "findMe"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/recipe_project/pom.xml",
"chars": 1693,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/recipe_project/src/main/java/sample/ThrowingRecipe.java",
"chars": 911,
"preview": "package sample;\n\nimport org.openrewrite.ExecutionContext;\nimport org.openrewrite.Recipe;\nimport org.openrewrite.Tree;\nim"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/single_project/pom.xml",
"chars": 1219,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\r\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/single_project/src/main/java/sample/EmptyBlockSample.java",
"chars": 789,
"preview": "package sample;\n\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.Random;\n\npublic class EmptyBlo"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunIT/single_project/src/main/java/sample/SimplifyBooleanSample.java",
"chars": 389,
"preview": "package sample;\n\npublic class SimplifyBooleanSample {\n boolean ifNoElse() {\n if (isOddMillis()) {\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/a/pom.xml",
"chars": 1344,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/a/src/main/java/sample/MyInterface.java",
"chars": 50,
"preview": "package sample;\n\npublic interface MyInterface {\n}\n"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/a/src/main/java/sample/SimplifyBooleanSample.java",
"chars": 389,
"preview": "package sample;\n\npublic class SimplifyBooleanSample {\n boolean ifNoElse() {\n if (isOddMillis()) {\n "
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/b/pom.xml",
"chars": 512,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/b/src/main/java/sample/EmptyBlockSample.java",
"chars": 192,
"preview": "package sample;\n\nimport java.util.Random;\n\npublic class EmptyBlockSample {\n int n = sideEffect();\n\n static {\n }"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/pom.xml",
"chars": 1851,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://mav"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteRunParallelIT/multi_module_project/rewrite.yml",
"chars": 284,
"preview": "---\r\ntype: specs.openrewrite.org/v1beta/recipe\r\nname: com.example.RewriteRunIT.CodeCleanup\r\nrecipeList:\r\n - org.openrew"
},
{
"path": "src/test/resources-its/org/openrewrite/maven/RewriteTypeTableIT/typetable_default/pom.xml",
"chars": 1620,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"http://maven.apache.org/POM/4.0.0\"\n "
},
{
"path": "suppressions.xml",
"chars": 430,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<suppressions xmlns=\"https://jeremylong.github.io/DependencyCheck/dependency-supp"
}
]
About this extraction
This page contains the full source code of the openrewrite/rewrite-maven-plugin GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 168 files (378.1 KB), approximately 92.4k tokens, and a symbol index with 322 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.