A best approach of migrating an Ant project to a Gradle project

I am reworking on a Java web application with Ant as the build tool. All dependencies are in a directory. I would like to convert the build tool to Gradle. What will be a best approach in the regards? I am new to Groovy too. I have the first few pages of the document and have tried the ant.importBuild ‘build.xml’.

For best results, I recommend not to use ‘ant.importBuild’ and to write an idiomatic Gradle build leveraging Gradle plugins such as ‘java’, ‘war’, etc. First get code to compile, then unit tests to run, then War built, etc. If you are in for it, you can write some code to compare the artifacts produced by the old and new builds. It’s OK to reuse Ant task types in cases where you can’t find a good Gradle equivalent.