Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Java Project to Gradle Project in Intellij

Tags:

I have a very basic java project.

In Eclipse there is an option to convert a project to a maven project all you have to do is right click on the java project and click "Convert to Maven Project". So basically it creates a pom.xml file for you.

Does IntelliJ have a similar command to convert to Gradle? Searched around but it did not seem like it does.

like image 977
otc Avatar asked Jul 03 '17 19:07

otc


People also ask

How do I change a project from Maven to Gradle in IntelliJ?

Open your Maven project in Intellij IDEA and then open "Terminal" tab. Write gradle init . Wait until the building process ends and then save & close your project. Reopen your project and click Auto-import, and wait while Gradle is running.

How do I sync a project with Gradle files in IntelliJ?

There is a useful shortcut Ctrl + Shift + A , after which a window appears and you can type some command that you would like IntelliJ to run. Just type "sync" in there and it will find that command Sync Project with Gradle Files, even if it's not visible in the menu.

How do I create a Gradle project in IntelliJ?

Convert a regular project into a Gradle project Open your project in IntelliJ IDEA. In the Project tool window, right-click the name of your project and select New | File. In the dialog that opens enter build.gradle and click OK.

What is Gradle JVM in IntelliJ?

Gradle JVM: when IntelliJ IDEA opens the Gradle project, it checks the gradle.properties file for the appropriate JVM version specified in org.gradle.java.home and uses it for the project. If it is not specified, then the project SDK is used.

Why is the Gradle tool window disabled in IntelliJ IDEA?

When you open a Gradle project, the link of the project is established automatically and the Gradle tool window is enabled. If an IntelliJ IDEA project is not linked to a Gradle project, then the Gradle tool window is disabled.

How do I import a Maven project into IntelliJ IDEA?

Add Path to System Enviroments (like in Gradle instructions) Open your Maven project in Intellij IDEA and then open "Terminal" tab. Write gradle init. Wait until the building process ends and then save & close your project. Reopen your project and click Auto-import, and wait while Gradle is running.


2 Answers

The simple way to migrate from Maven to Gradle via Intellij IDEA is:

  1. Install Gradle Build Tool from https://gradle.org/
  2. Add Path to System Enviroments (like in Gradle instructions)
  3. Open your Maven project in Intellij IDEA and then open "Terminal" tab.
  4. Write gradle init. Wait until the building process ends and then save & close your project.
  5. Reopen your project and click Auto-import, and wait while Gradle is running. Approximate time - 5 mins.
like image 198
Orkhan Hasanli Avatar answered Sep 19 '22 09:09

Orkhan Hasanli


  • Close your project (you may want to commit first)

  • Select "New Project"

  • Select Gradle (and any other frameworks you need)

  • Enter the directory where the Idea project to be converted is and click "Finish"

Idea should handle the rest, you may need to move your files into main/java (etc)

I don't think there's a simple way to do this in place.

like image 32
Rich Avatar answered Sep 20 '22 09:09

Rich