Safeguard
Developer Tools•

How do I convert a Maven POM to Gradle with gradle init?

gradle init converts POMs into build scripts, repositories and dependencies, but not assemblies or most plugins. Here is what to review afterwards.

Safeguard Security Team
3 min read

Run gradle init in the root of the Maven project. Gradle parses the POMs and generates build scripts, a settings script for multi module builds, the repositories listed in the POM, and your dependencies. It does not convert assemblies, and plugin coverage is limited. Treat the output as a first draft and review every dependency line.

What the conversion produces

The Gradle migration guide says the automatic conversion creates the build files you need, even for multi module builds. The new build includes the custom repositories specified in the POM, external and inter project dependencies, and the plugins needed to build the project, limited to the Maven Publish, Java and War plugins. For simple projects it may be ready to run.

The same guide is clear about gaps: assemblies are not automatically converted and need manual work, such as the Distribution plugin, the Application plugin or custom archive tasks.

Steps

  1. Keep the Maven build working in place. The guide recommends keeping the old and new builds side by side until the Gradle build produces the same artifacts.
  2. Run the conversion from the project root.
  3. Run a build and read the failures.
  4. Review dependencies line by line (below).
  5. Replace Maven plugins with Gradle equivalents one at a time.
  6. Compare outputs against the Maven build before cutting over.
gradle init
gradle build

Review the dependency output

The conversion is mechanical, so the security review is yours. Look for:

ItemQuestion to ask
ScopesDid compile, runtime, test and provided land in the right Gradle configuration?
ExclusionsWas the original reason preserved? See migrating Maven exclusions to Gradle
Version managementDid dependencyManagement become a platform or constraints?
RepositoriesAre only intended repositories present?
Resolved versionsDo they match the Maven tree? See version shift between Maven and Gradle

Expect output differences

The guide notes that generated POMs from Gradle contain only the information needed for consumption, and that file order in archives and on classpaths can differ. Most differences are minor, but identify and verify them. A changed classpath order can matter when two jars contain the same class.

Lock it down afterwards

Once the Gradle build matches, turn on dependency locking and consider verification metadata so the new build is as pinned as the old one. See how to turn on Gradle dependency locking and bootstrapping Gradle dependency verification safely.

Safeguard's dependency scanning and SBOM generation can inventory the Maven build and the Gradle build for comparison. Try the free scan at gold.safeguard.sh/scan.

Try it yourself

Click through it at your own pace, or open it full screen. Look at the direct and transitive split, which you should compare across the two builds.

Quick check

Does gradle init convert Maven plugins?

Only a limited set. The guide says the Maven Publish, Java and War plugins. Others need Gradle equivalents or custom work.

Should I delete pom.xml after converting?

Not until the Gradle build produces the same artifacts and has shipped a release. The guide recommends keeping both side by side.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.