• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Building JAR's for linked projects...

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys... How can I automate the process of building a new jar file for a project in eclipse ? Is there a way to do this without perturbing the entire build process ? I would rather not use ANT because eclipse appears to be so smart, that I dont want to replace whatever logic eclipse uses under the hood with my own, somewhat buggy (possibly) logic for rebuilding a jar.

Essentially, I have 5 projects, and I want changes to the source in those projects to automatically result in construction of new Jar files, so that the main project, which depends on those 5, can be exported as an executable jar file which is 100% concurrent with the sub projects.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Maven or Ant. I could probably find a way to make Eclipse do this, but I have a very firm rule that my builds should be assistable by IDEs, but not dependent on them.

I've got a long and sordid list of reasons why I'm so dogmatic about that, but I won't weary people by repeating it. If you're interested, look at some of my earlier messages in this forum.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe eclipse uses ant under the hood . How can I access the build process for eclipse projects ?
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eclipse does not use Ant under the hood (as far as I know). (NetBeans uses Ant, however.) But you can change your project to be built with Ant. Go to Project > Properties, than under Builders, click New, choose Ant Builder and fill in the information. Then you can use the Ant build from Eclipse or from the command line or a script.

Beware, however, that Eclipse tries to be "helpful" when running the Ant build, and that can cause problems. You need to be careful that your Ant script always runs properly from the command line.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by eclipse tries to be :helpful: ?
Ive been using to manage my complex java projects via eclipse for so long I'm not quite sure where to start moving into this brave new world of custom builds.
Where should I start ?
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I recall correctly, Eclipse adds several system properties to the Ant command, which can cause the build to work correctly while being used within Eclipse, but incorrectly when used from a command line.

The best place to start learning Ant is with a good book - I recommend Ant in Action - I have the previous version of that book and find it indispensable.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can actually tell Eclipse to create build files to be able to run as stand-alone or as Eclipse build files. If you tell Eclipse not to use the Eclipse builder but the Ant builder as default, it creates build.xml files that can be run under Eclipse.

However, if you export the project as external build, then it creates ant-task that is totally independent of Eclipse.

Also, it is really easy to call the Eclipse builder from Hudson of Cruise.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic