tags:

views:

40

answers:

2

I'm new to java/eclipse(coming from .NET), so I'm still unfamiliar how eclipse builds/runs my projects. After examining the .project and .classpath files i'm guessing that they have all the info needed for the eclipse to build the project. I like the kind of control nAnt gives for .NET projects, so I decided to switch Eclipse's Javabuilder for it. The only way I found to build using Ant is to right click the build file and tell eclipse to build it, then a window pops that allows me to select tasks and other options. That is not so bad, however I would be happier if I could still use Eclipse's views for invoking Ant tasks. Is there some way to tell eclipse to invoke ant tasks when I perform actions on the IDE? In the MonoDevelop IDE I can customize the various build-related actions(eg: calling a make or nant command on the project's directory). I really like the jUnit test view better than seeing the test result's on the console. If not, can I customize/integrate JavaBuilder to work alongside with nAnt?

+1  A: 

There is a view in Eclipse called Ant:

Window -> Show view -> Ant

You can add build files to it. Then run the target you want by clicking on it.

Is there some way to tell eclipse to invoke ant tasks when I perform actions on the IDE?

Could you please clarify what you mean here? Do you mean when you run a build in Eclipse you would like to invoke an Ant target?

EDIT: Instead of using the default Java builder you can define your own.

  1. Right click on the project -> properties -> Builders
  2. Uncheck Java builder
  3. Select New button -> Ant Builder
  4. In the launch configuration specify your build file, your base directory, etc
  5. Finish the wizard.
  6. To build your project select the Project menu -> Build project.
Ross
In the Monodevelop IDE if you press 'Clean' on the context menu in any project, it will execute the default clean action on that project, or run any user defined command(eg: nant clean). I was hoping for something like that. If I could just setup a shortcut to invoke ant tasks that would be fine
Thiado de Arruda
Yes if you create an Ant builder in eclipse and specify your build file whenever you build your project through the menu your default built target will be called. I will edit my answer for my detail
Ross
Do you think I can integrate the test task with the jUnit view? What about the clean task?
Thiado de Arruda
I don't know of a way to link the JUnit run configuration to your Ant test target, doesn't look like you can. For the Ant builder there are small customising you can doin the launch configuration mentioned in the answer. In the targets tab you can set targets that run for specific actions.
Ross
+1  A: 

Eclipse doesn't use Ant for any of its own internal tasks; you can happily compile classes, run tests, produce JAR files, etc, from within Eclipse without Ant. Ant build files are more for tasks done outside the IDE.

Because Eclipse keeps track of its own project state, you don't normally have to do project cleans - the classfiles are consistent.

If you prefer an IDE based around something like an Ant build script, then you may be interested in NetBeans - it is explicitly modelled around the Ant build script.

Robert Watkins
I haven't tried another java IDE, but I think eclipse is fantastic, even without Ant.
Thiado de Arruda
Yeah, Eclipse is my favourite IDE as well.
Robert Watkins