Notes on Software Development, Technology and Life.

Wednesday, June 15, 2005

Eclipse 3.1 ANT Build File Import/Export

What's New in Eclipse 3.1
— Since Eclipse's first release in 2001, it has become a popular environment for Java development. In the period between March 10 and May 11, 2005, users downloaded over 17,000 copies of one of the production SDK releases and over 3,500 copies of one of the stable (milestone) SDK builds on average every day. A vibrant eco-system of developers, plug-in providers, authors, and bloggers has grown up around it. Eclipse has also gained the backing of the key Java vendors including BEA, Borland, IBM, SAP, and Sybase. Developers like Eclipse because it provides a great platform for building Java applications, and companies like it because it unifies their software tools under one open source umbrella.

I was reading this article on JDJ about new features in Eclipse 3.1. One feature mentioned that caught my eye was the ability to set a project based on an existing ANT build file, and the ability to export a project settings to an ANT build file. Unfortunately the article didn't explain how to do this import/export. I searched Eclipse's help, to no avail. After some messing around with eclipse I found out how to do it.

To export your project settings to an ANT build file:
  1. Right click on any file in your project and click on "export" (thanks to Scott Stanchfield for clarifying that any file in the project will do).
  2. On the window that pops up, select "Ant Buildfiles" and click on "next".
  3. Select the appropriate project to use to generate the ANT buildfile.
  4. Click "finish".
You should now have two new build files on your project, "build.xml" and build-user.xml.

Any custom targets you create should go on build-user.xml, since build.xml will be overwritten every time a build file is generated.

To create a project from an existing ANT buildfile:
  1. Click on File->New->Project
  2. Select "Java Project from existing Ant Buildfile" and click "next".
  3. Enter a project name, and select the build file to use to create the project.
  4. Select the javac declaration to be used to define the project.
  5. Click "finish".
I hope these instructions are helpful to others out there.


  • Nice explanation, thanks.

    By Blogger Ed Burnette, At 11:31 PM  

  • You don't need to right-click on the .project file. Any file/folder (or the project itself) will do.

    By Anonymous Scott Stanchfield, At 10:06 AM  

  • Good to know, thanks.

    By Blogger David R. Heffelfinger, At 3:00 AM  

  • Do not you mind being referenced there

    By Anonymous Sam Mesh, At 6:20 PM  

  • Sam,

    I don't mind being referenced, please do.


    By Blogger David R. Heffelfinger, At 10:22 AM  

  • what if i have 2 different javac targets ?
    say one that builds project and other that builds the unit tests

    By Anonymous Anonymous, At 7:05 AM  

  • If your buildfile has multiple javac declarations, you are prompted to select the javac declaration that makes sense for building the project.

    By Anonymous Darin Swanson, At 5:55 PM  

  • after doing the export of the Ant Build files those two files, build.xml and build-user.xml show in the problems list with

    Severity Description Resource In Folder Location Creation Time Id
    2 3:2 The markup in the document following the root element must be well-formed. build-user.xml INVENTJobQ line 3 January 3, 2006 12:48:26 PM 11700

    Is there any way to eliminate that problem reporting so I don't see the little red X on ALL my projects?

    By Blogger Ollie, At 3:58 PM  

  • Shame the import doesn't work if the javac is inside a conditional statement in the build file.

    By Blogger BigMikeW, At 4:47 AM  

  • Very useful blog for software development export and import so thanks allot for shearing this suggestion.

    By Anonymous hire a php programmer, At 6:42 AM  

  • Was looking for this trick for several days. Thanks so much.

    By Blogger Mohammad Javad Dousti, At 1:46 AM  

  • I have a project which contain webroot folder like we have in dynamic web project. But I am not able to get the webroot folder in the hierarchy of the project. Can anyone tell me how to get the proper project?

    By Blogger Nimit Jain, At 7:49 AM  

  • I have been using ant for the first time. Please reply how to use build.xml with ant to get a proper hierarchy which must include webroot folder. Thanks in advance

    By Blogger Nimit Jain, At 7:51 AM  

  • nice, thanks

    By Anonymous Anonymous, At 10:04 AM  

  • This is one of the awesome and good application.I like your blog strategy.This is one of the perfect post.Good.

    By Anonymous Android app developers, At 4:43 AM  

  • Thanks dear this is pretty useful blog for Program Development Company
    export and import so thanks allot for shearing this suggestion.

    By Blogger Mike Quiney, At 7:17 AM  

  • We are a leading software development company delhi,India which works as per the client requirements and give provide software.

    By Blogger John Dudley, At 4:31 AM  

  • Hello !Thank you so much for this amazing article and please keep update like this excellent post.
    Digital Marketing In Delhi
    E-Commerce Solution in delhi

    By Blogger Hammad khan, At 3:29 AM  

Post a Comment

Subscribe to Post Comments [Atom]


Create a Link

<< Home