Jul 19

Know the feeling when you’re just about to release code to the public’s eye, and all you need to do is write that pesky build file? Even as I write it I feel it’s an understatement: the task of creating an ant build file can take a few good days out of anyone’s life, and even with copying the last project’s build file and changing a few parameters you can’t really minimise it to less than half a day’s work. 

But why should you, really? If you’re working with Eclipse you probably notice how your IDE knows about the relationships between all the projects in the workspace, which project requires which Jar files, and where to place all the binaries. After all, it is your workspace and integrated development environment. So why can’t that information be used to generate that damned file?

Well, one guy thought it should be, and implemented something better: a generic build system for Eclipse-managed projects called ebuild. In his blog Omry describes ebuild himself, but since his posts are in Hebrew I’ve decided to spread the word in English as well.

Ebuild is added to your workspace and, by adding a short file called build.properties, can be executed in order to build your project. After that, you get one build.xml file which can build any of your projects. All your projects need to have is the build.properties file in it, worth three lines of key-value pairs at most, and ebuild will do the magic of finding out the project’s dependencies and build order.

Omry is also the person behind JNotify, the library which brings you file system notifications in a nicely wrapped Java API.

For those of you who use IntelliJ: as far as I know, selecting “Generate Ant File” from the “Build” menu should be more than enough for you – it doesn’t create the magical build.xml file, but it does save a lot of work when lazying out on writing the build files.

Related Posts with Thumbnails

12 Responses to “Build.xml generator for Eclipse”

  1. Omry Says:

    Aviad,
    You slightly misunderstood:
    it’s not a build file generator – it’s a build file that can build (almost) any Eclipse Java project.

  2. Aviad Says:

    Just to show you how Java is more a native language for me than even Hebrew.

    I will soon correct the post and add a short explanation on how to use ebuild.

  3. Aviad Says:

    Done. Omry’s comment might seem silly now that the post is changed.. But the title is still there (don’t really want to change it.)

    Just know that at some point in time, I made a mistake and wrote that ebuild was a build file generator while its actually a generic build system. That’s all. :)

  4. Carsten Schlipf Says:

    Ever tried to use Maven? I admit that it takes some time to get used to it, but I really like how you can setup complete projects in some seconds and then let it generate the required project files for your favourite IDE.

  5. Sonia Pandit Says:

    My project is TemperatureConverterService,
    which has 1 file TempereatureConverter.java
    What should my build.properties look like.
    (How about when I edit it with the eclipse properties editor?) I executed ant -DTemperatureWebService and I get an error.

    Thanks,

    Sonia

  6. Omry Says:

    Sonia,
    see this : http://ebuild.firefang.net/wiki/build.properties

    sinece in your case you probably don’t need to include or exclude anything, you can leave the two include/exclude lines out, so your build properties would end up like:
    main.class=TempereatureConverter

    (Assuming it’s in the default package).

    you can edit with Eclipse properties editor, but it only useful to edit the include/exclude lines.

    since the code should build even without a build.properties, I am guessing that you just ran ant in the wrong place.
    you need to run ant in the ebuild directory, or tell it where the build.xml file is.
    a more convenient alternative is to create a minimal build.xml file inside your project, like this one here:
    http://ebuild.firefang.net/wiki/DriverBuildXML

  7. sam Says:

    Eclipse is capable of generating an ant build file for your project, you just have to know to access this feature 😉

    right-click project -> export
    select General -> Ant Buildfiles

    there it is, your perfect ant build file.

  8. M Chisty Says:

    Sam provided the best answer. Eclipse already has this feature. Completely agreed with Sam.

  9. Eyal Says:

    Hi,
    I have added the EBuild as a project in my eclipse’s workspace.
    After adding, the projects failed to build.
    All the imports of org.apache.tools.ant.*; does not work.
    How it can be fixed?
    Thanks,
    Eyal.

  10. Omry Yadan Says:

    What do you mean, just putting ebuild files in your workspace broke your eclipse build?

  11. Eyal Says:

    Sorry, I have solved the problem.
    My mistake.

  12. Vij Says:

    Awesome, I found exact classpath using this project and able write build.xml. Thanks very much…