maven-to-gradle

Claude Code skill for migrating Maven projects to Gradle Kotlin DSL with version catalogs

adityamparikh
作者 adityamparikh
AI 与机器学习 · Apache-2.0 · Python · 更新时间: 6 months ago
12
星标
1
Forks
已验证
A
安全:
优秀
AA
质量:

name: maven-to-gradle description: Migrates Maven projects to Gradle Kotlin DSL (build.gradle.kts) with version catalogs (libs.versions.toml). Covers single-module and multi-module projects, Spring Boot starter-parent conversion, dependency-scope and BOM mapping, Maven plugin to Gradle plugin translation, and Maven profile equivalents. Also supports a dual-build overlay mode that adds Gradle alongside Maven without removing pom.xml. Triggers on requests to convert pom.xml to Gradle, migrate from Maven to Gradle, generate build.gradle.kts, set up a Gradle version catalog from Maven, modernize a JVM build system, or add Gradle alongside Maven for gradual migration. Does not apply to Gradle-to-Maven conversion, authoring brand-new Gradle projects from scratch with no Maven source, Groovy DSL (build.gradle) authoring unrelated to migration, or non-JVM build tools (npm, Bazel, sbt, Make). allowed-tools: Read(), Glob(), Grep(), Bash(python3 scripts/migrate.py:), Bash(./mvnw:), Bash(mvn:), Bash(./gradlew:), Bash(gradle:), Bash(gh api:), WebFetch(), WebSearch(), mcp__claude_ai_Context7__, mcp__plugin_context7_context7__*

Maven to Gradle KTS Migration

Workflow

  1. Analyze the Maven project structure (single vs multi-module, Spring Boot, Kotlin).
  2. Run scripts/migrate.py to generate baseline Gradle files.
  3. Review and refine the generated output.
  4. Handle profiles and custom plugin configurations manually.
  5. Verify the build compiles and tests pass.

Verify Library and Framework Versions

Plugin IDs, DSL syntax, and dependency coordinates change between Gradle versions. Before finalizing output, look up current docs (Context7 MCP, web fetch, Gradle Plugin Portal, or gh api repos/{owner}/{repo}/releases/latest) for any plugin or framework whose version is newer than the model's training data, or whose Gradle equivalent is uncommon. Do not assume a plugin ID or DSL form is correct from memory.

Step 1: Analyze the Project

Step 2: Run the Migration Script

Two modes:

Full migration (default) — generates Gradle files; suggests removing Maven after verification:

python3 scripts/migrate.py <path-to-maven-project> --dry-run

Overlay / dual-build — adds Gradle alongside Maven so both build systems work:

python3 scripts/migrate.py <path-to-maven-project> --mode overlay --dry-run

Overlay mode also appends Gradle entries to .gitignore and preserves all pom.xml files.

The script generates:

Review --dry-run output first, then run without the flag to write files.

The script handles:

Step 3: Review and Refine

The generated files are a starting point. Always review and adjust:

Version catalog (libs.versions.toml):

Build files (build.gradle.kts):

For multi-module projects:

Step 4: Handle Profiles

Maven profiles require manual conversion. The script adds comments identifying each profile.

See references/profiles.md for complete patterns:

Step 5: Verify

gradle wrapper --gradle-version=8.12
./gradlew build
./gradlew dependencies  # compare with: mvn dependency:tree

See references/gotchas.md section 9 for the full verification checklist.

Known Limitations

The migration script provides a solid starting point but has these limitations that require manual intervention:

Reference Files

🔓 登录解锁更多
使用 GitHub 登录