Quick revision
The short answer
I would start with gradle init to convert the pom.xml into a first build, then review it: apply the Spring Boot plugin and keep Boot's managed versions with io.spring.dependency-management or platform(...) on the Boot BOM, map each Maven scope to the right Gradle configuration, replace each Maven plugin with a Gradle equivalent, and turn profiles into properties or tasks. Finally I compare the jar contents and the dependency trees from mvn dependency:tree and gradle dependencies to prove the two builds are equivalent. What usually goes wrong is lost managed versions, annotation processors, resource filtering and things the parent POM did silently.
What to remember
In this answer, we migrated a single-module Spring Boot project: gradle init gave a first build to review, the Spring Boot plugin with io.spring.dependency-management or platform(...) on the Boot BOM kept managed versions, Maven scopes were mapped to implementation or api, compileOnly, runtimeOnly and testImplementation, with annotationProcessor and useJUnitPlatform added, plugins and profiles were replaced with Gradle equivalents, properties and tasks, and the dependency trees and jar contents of both builds were compared before removing the pom.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would start with gradle init to convert the pom.xml into a first build, then review it: apply the Spring Boot plugin and keep Boot's managed versions with io.spring.dependency-management or platform(...) on the Boot BOM, map each Maven scope to the right Gradle configuration, replace each Maven plugin with a Gradle equivalent, and turn profiles into properties or tasks. Finally I compare the jar contents and the dependency trees from mvn dependency:tree and gradle dependencies to prove the two builds are equivalent. What usually goes wrong is lost managed versions, annotation processors, resource filtering and things the parent POM did silently.
Why this question is asked
Migrating a small Spring Boot project from Maven to Gradle looks like a translation exercise, and the first version often compiles within an hour. The problems show up later: a missing annotation processor, a resource placeholder that is no longer replaced, a dependency on a different version than before. Interviewers ask this scenario to see whether we know what a Maven parent POM does behind the scenes, and whether we verify the result instead of trusting that it builds. In this answer, we will generate a starting build, restore Spring Boot's dependency management, map scopes, replace plugins and profiles, and then compare the outputs of both builds.
1Generate a Starting Point With gradle init
In a directory with a pom.xml, running gradle init offers to convert the Maven build. It reads the pom and produces settings.gradle.kts, a build.gradle.kts with the dependencies and repositories it understood, the Gradle wrapper and, in recent versions, a version catalog.
Notice that this is a starting point, not a result. The converter knows dependencies and basic metadata, but it cannot translate what plugins do, and it may copy versions that the parent POM managed, which hides where they came from. We keep the wrapper and settings and rewrite the build file by hand using what it found.
2Keep Spring Boot's Managed Versions
A Spring Boot Maven project usually inherits from spring-boot-starter-parent. That parent does a lot: it imports the Boot BOM so starters have no versions, sets the Java version and the -parameters compiler flag, configures resource filtering with @..@ placeholders, and configures plugins such as the Boot repackaging plugin. In Gradle, the Spring Boot plugin and a BOM take over these jobs.
Both options keep Boot's tested versions. The dependency management plugin behaves most like Maven, including overriding versions with properties such as extra["jackson-bom.version"], so it is the easiest choice for a migration. The platform approach is Gradle's native mechanism and is lighter. The Boot plugin itself adds the bootJar and bootRun tasks, configures -parameters for Java compilation, and replaces spring-boot-maven-plugin. A common mistake is converting without either option, which leaves dozens of hard-coded versions in the build that nobody upgrades together with Boot.
3Map Maven Scopes to Gradle Configurations
Each Maven dependency scope has a Gradle counterpart, but they are not identical, and annotation processors are the usual trap.
| Maven scope | Gradle configuration | Watch out for |
|---|---|---|
| compile | implementation (or api in a library) | api needs the java-library plugin |
| provided | compileOnly | Not on test classpath; add testImplementation if tests need it |
| runtime | runtimeOnly | |
| test | testImplementation, testRuntimeOnly | useJUnitPlatform() on the test task |
| processor on classpath | annotationProcessor | Silently skipped if missing |
Notice the two lines that have no Maven counterpart. Maven's compiler runs annotation processors found on the compile classpath automatically; Gradle runs only those on the annotationProcessor configuration, so Lombok, MapStruct or the Spring configuration processor silently stop working unless we add them there. And Gradle's test task must be told to use JUnit Platform. A library project would use api instead of implementation for dependencies that appear in its public API, which needs the java-library plugin.
4Replace Plugins and Profiles
Next we go through every plugin in the effective POM, which mvn help:effective-pom shows including what the parent adds, and find a Gradle equivalent. Many are built in or provided by well-known plugins: Surefire becomes the test task, the Boot Maven plugin becomes the Boot Gradle plugin, Jacoco and Checkstyle have core Gradle plugins, and resource filtering becomes processResources with expand or filter.
Resource filtering deserves a look, because the Boot parent sets it up quietly. If application.properties contains app.version=@project.version@, Maven replaces it. Gradle does not, unless we tell it to, for example with processResources { filesMatching("application.properties") { filter<ReplaceTokens>("tokens" to mapOf("project.version" to version.toString())) } }, and the version must then be declared as an input so the task reruns when it changes.
Maven profiles have no direct counterpart. A profile that switches configuration for an environment usually becomes a Gradle property read with providers.gradleProperty("env") and passed with -Penv=prod, while a profile that adds extra steps, such as integration tests, becomes a separate task or test suite that we run when we want it.
5Prove the Two Builds Are Equivalent
A green Gradle build is not proof. Before deleting the pom, we compare the outputs of both builds on the same commit.
- gradle inita first build to review
- Restore Boot managementBoot plugin plus dependency-management or platform
- Map scopesadd
annotationProcessor,useJUnitPlatform - Replace plugins and profilescheck the effective POM
- Compare deps and jar contentsexplain every difference
- Remove pom.xmlafter tests and a real start
6 steps in order. Play them, or step through them one at a time.
The two dependency outputs use different formats, so comparing them means extracting the group, name and version of each line, but the differences are what matter: a different version means management was lost, an extra library means a scope was mapped too broadly. The jar listing catches missing resources, missing generated files and plugins we forgot. Notice the example diff found a file produced by a Maven plugin that we never replaced. We also run the full test suite and start the application once with the Gradle-built jar. Only when the differences are explained do we remove pom.xml.
6Follow-up questions
Why does the Gradle jar sometimes have different dependency versions?
Maven resolves conflicts by nearest wins and Gradle by highest version, so a transitive library may resolve differently even with the same BOM. The dependency management plugin narrows the gap by applying managed versions Maven-style. Any remaining difference should be examined with dependencyInsight and fixed deliberately.
What about the parent POM's company settings?
If the company parent adds repositories, plugins or enforcer rules, they need a Gradle home too, ideally a shared convention plugin. Copying them into this one build file works for a single project but should be replaced once more projects migrate.
Should we keep both builds for a while?
For a single small project, a few days of both builds in CI is enough to compare outputs. Longer than that, the two drift and someone has to keep them in sync, so we switch once the comparison is clean.
7Conclusion
In this answer, we migrated a single-module Spring Boot project: gradle init gave a first build to review, the Spring Boot plugin with io.spring.dependency-management or platform(...) on the Boot BOM kept managed versions, Maven scopes were mapped to implementation or api, compileOnly, runtimeOnly and testImplementation, with annotationProcessor and useJUnitPlatform added, plugins and profiles were replaced with Gradle equivalents, properties and tasks, and the dependency trees and jar contents of both builds were compared before removing the pom.
Open with
I would start with gradle init in the project, which converts the pom into a first Gradle build with the wrapper, but I treat it as a draft.
Then, if they want more
Then I rebuild the important parts by hand. The Spring Boot parent does a lot silently, so I apply the Spring Boot Gradle plugin and either io.spring.dependency-management or platform on the Boot BOM, so starters stay versionless and managed, and set the Java toolchain from the java.version property.
Next I map scopes: compile becomes implementation, or api in a library, provided becomes compileOnly, runtime becomes runtimeOnly, and test becomes testImplementation. Two things trip people up here: annotation processors like Lombok or MapStruct must go on the annotationProcessor configuration, because Gradle does not find them on the classpath like Maven, and the test task needs useJUnitPlatform.
Then I go through the effective POM's plugins, replacing each with a Gradle equivalent, and handle the parent's resource filtering of at-sign placeholders, which Gradle does not do by default. Profiles become Gradle properties or separate tasks.
Finally I prove equivalence: compare mvn dependency:tree with gradle dependencies on the runtime classpath, diff the file listings of both jars, run the tests and start the app. When every difference is explained, I delete the pom.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Gradle user manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "You need to migrate a single-module Maven project with Spring Boot, a few plugins and a...": https://scrivio-interview-library.netlify.app/java/gradle/bff67c6c3e/