How to import/create project from existing Ant build.xml file?


I can't seem to find a way to import an existing ant based project that already has the build.xml configured. I am expected the IDE to able to read the file and at least setup the source directory and classpath/External Libraries properly. Can this be done on IDEA 12?



I'm not sure this is the correct, best or easiest way, but it worked for me ;-)
- open your build configuration (e.g. Run - Edit Configurations)
- select the configuration you want to modify and find the "Before launch" area on the bittom right of the window
- Click the grenn "+" sign
- Click "Run external tool"
- Click the green "+" in the pop up window
- Under "Tool settings" enter the path to your ANT as "Program", e.g. "C:\apache-ant-1.9.3\bin\ant.bat"
- Under "Parameters" you can enter command line parameters (i.e the targets)
- and finally you can define the path to your build.xml as "Working directory"

Depending on what you check marked as "Show in" the "Name" you defined for this definitions will show up in the selected menus.
If you confirm your settings with "OK", you'll find the new "script" as the last item in the "Before launch" list as "External tool 'name' ".
And you then can select the position where/when your ANT should run.

Then the ant command file will run before every start of a build process or if called from the menues.In a menu you'll find it with the name you assigned.

Good luck!


Hi Hans,

Thanks for the help. It's not exactly what I was looking for. The problem I face is I have a large ant based project and want to browse the code quickly. I can run and build the app on command line already. But browsing the code in IDE needs the classpath setup correctly. Unfortunately the nature of Ant project is that they setup java source folder in a not so standard fashion, but they are configured and bulid fine with the ant config. Right now, I have to manually edit IDE settings of where the source folders and add jars manually, despite I have fully working ant build file. I am looking for a better way to browse the code without IDE setup work.


Please sign in to leave a comment.