Ability to convert Gradle Project to Maven in IntelliJ and store both build files

I gladly used IntelliJ + Gradle, but I was recently asked to move to Maven as a build tool. Is there an easy way to convert a Gradle project in Maven to IntelliJ or maybe save both configuration files (build.gradle and pom.xml)? According to Gradle build.gradle for Maven pom.xml, I used the Gradle Maven plugin and generated the pom.xml file in build / poms, but I would like to keep both build.gradle and pom.xml at the same level, which makes it possible to build project using what is preferable. Is it possible?

Thanks,

+5
source share
1 answer

I can’t offer you a solution to keep all your Gradle project settings intact, but if you find the following useful, check it accordingly.

To move between the two build tools, you can do the following:

If you have a Maven project that you want to convert, you need to go to the project folder, and on the cmd line run "gradle init" (obviously, make sure Gradle is in your path). Close and reopen the project, and you will be prompted to enable Gradle in the project.

To your exact question, about converting Gradle back to Maven. You can simply delete the .idea folder, leaving all Gradle scripts in place. Then inside Intellij, select an open project. Go to your pom.xml and select this. Follow the screens below. When Intellij prompts you to include the project as Gradle, reduce it. The result is a new project in which your Gradle scripts will still be included, but now they are built with Maven. You will need to have a valid pom.xml that maven can use.

+7
source

Source: https://habr.com/ru/post/1246109/


All Articles