IntelliJ IDEA 2019.1 Help

Convert a regular project into a Maven project

You can open an existing non-Maven project and add a Maven support via IntelliJ IDEA UI.

  1. Open an existing project, for example, a Java project.

  2. In the Project tool window, right-click your project and select Add Framework Support.

  3. In the dialog that opens, select Maven from the options on the left and click OK.
    IntelliJ IDEA adds a default POM to the project and generates the standard Maven layout in Project tool window.

    maven support generated architecture
    IntelliJ IDEA also creates a corresponding structure with Lifecycle and Plugins in the Maven Projects tool window.

  4. Open the generated POM and specify a groupId. The artifactId and version are specified automatically.

    maven groupId
    Every time you change the POM, IntelliJ IDEA displays a popup suggesting to import your changes.
    maven popup

At this point you can further develop your project using Maven. We recommend making all your project changes in POM since IntelliJ IDEA considers pom.xml as a single source of truth.

You can conclude the following optional steps to create an executable JAR.

  1. Click build to build project. IntelliJ IDEA generates target folder. Note that IntelliJ IDEA only compiles sources and doesn't create either JAR file or Manifest file.

  2. Create a Manifest file in the resources directory.

    manifest file

  3. In your POM specify the Manifest file information, so you can use Maven to generate an executable jar file.

    pom manifest info

  4. In the Maven Projects tool window, in the Lifecycle list, double-click the install command to generate the jar file.
    IntelliJ IDEA generates an appropriate information in the target folder and an executable JAR in the Project tool window.

    maven jar file
    You can right-click the generated JAR and select Run to execute the file.

If your existing project is larger and contains more than one module, converting such project into a Maven project becomes quite challenging. Since IntelliJ IDEA recognizes project settings only from POM when you convert your project you need to check and adjust the following settings:

  • Annotation settings - they are changed for the modules.

  • Compiler output - it is changed for the modules.

  • Resources settings - they are ignored and overwritten by POM.

  • Module dependencies - they need to be checked.

  • Language and Encoding settings - they are changed for modules.

Also, there is no POM template generated. All dependencies (including module dependencies) need to be manually included into POM.

In this case we recommend that you create an external POM where you describe your project and import your POM as you would import a regular Maven project using File | New | Project from Existing Sources command.

IntelliJ IDEA adds POM to the project and a Maven layout for the existing elements.

maven project layout
IntelliJ IDEA also generates the corresponding structure in the Maven Projects tool window.
maven tool window structure

Last modified: 20 May 2019