Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import existing Ant build.xml into IntelliJ IDEA

I have an existing project that uses an Ant build.xml file to maintain the location of dependency jars.

In Eclipse it's very easy to import from an existing Ant file. I have searched online and looked through all of the "new project" options in IntelliJ but cannot figure out how to do this.

The closest thing I've done is File > New > Project from Existing Sources. But my whole project is full of errors because it didn't use the build.xml to include the jars.

like image 345
Mike S Avatar asked May 22 '15 17:05

Mike S


People also ask

How do I import an Ant project into IntelliJ?

In the Project tool window, right-click the generated build file and select Add as Ant Build File to open it in the Ant tool window. In the Select Path dialog, navigate to the desired build. xml file, and click OK. A build file should have at least a root element to be added to the Ant Build tool window.

How add xml to IntelliJ?

In the Project tool window, select the directory, where the build file should be created. Right-click the directory and from the context menu, select New | File ( Alt+Insert ). In the New File dialog, specify the name of the new file with the xml extension, for example, build. xml.

How do I load an existing project in IntelliJ?

Otherwise, from the main menu, select File | New | Project from Existing Sources. In the dialog that opens, select the directory in which your sources, libraries, and other assets are located and click Open. Gradle or Android Gradle: select the necessary build tool and click Finish.


Video Answer


4 Answers

Intellij supports Ant projects via built in Ant plugin which is included by default in IDE. To check if it is enabled go to Settings > Plugins > Ant

After enabling plugin, you can use build.xml from View > Tool Windows > Ant Build

You should then have option(+) of importing your build.xml file.

like image 179
hitz Avatar answered Sep 29 '22 02:09

hitz


Import the project "from existing sources" without choosing any build tool (ant is not on the list, only maven, sbt, etc...). Then after completing the import wizard, in the project files view, right click ant's build.xml file, and choose the option relating to ant which is hiding at the bottom of the menu.

like image 32
matanster Avatar answered Sep 29 '22 03:09

matanster


You should use File > New > Module instead of File > New > Project from Existing Sources for Ant project. You also need to set your Content root and Module file location to your current Ant project directory.

You may also need to set right path to project output in Project Structure > Use module compile output path and set proper content route in Project Structure > Sources

like image 22
Amir Razmjou Avatar answered Sep 29 '22 03:09

Amir Razmjou


Please, follow the steps below if you use the IntellIj:

  1. Check the Ant plugin for the project.

enter image description here

  1. select the build.xml file and add as the Ant build file

enter image description here

  1. Use the side button to deploy the project

enter image description here

like image 39
Heisenberg Avatar answered Sep 29 '22 02:09

Heisenberg