Ricket
Ricket

Reputation: 34067

Java, Eclipse, Ant, JUnit, Hudson, SVN, native libraries; can they all coexist?

What is the most proper way to accomplish all of the following:


I already have my project with some source files and an Ant file, but I've been having trouble integrating it with Eclipse in an organized manner, so I would really love to start from a fresh Eclipse project, set it up correctly, and then copy my Ant file and my source files piece-by-piece into the project in the most Eclipse-compatible way.

I will be continuing to play around with everything in an attempt to get it working as I like it. But if you have experience with this sort of thing, perhaps at your workplace, please give as much information as you can.

My main goal here is to learn this once and use it in my future projects. For now, I am developing a client-server application consisting of a JOGL applet frontend (using JNLP files) and an unattended server app. Up until now I've been doing it all by hand: writing and building in Eclipse, dragging the applet jar into my FTP client, SSHing the server jar and restarting it by hand, and all with no testing process. I'm hoping that by the end, the build process will be something like this: test locally on my machine with a copy of the native libraries; commit code changes to SVN; Hudson svn updates, uses the Ant buildfile to compile and run all JUnit tests; if all the tests pass, it proceeds to copy the server jar to my dedicated server and restart the running server instance, and then copy the client jar to my web server.

Upvotes: 2

Views: 2657

Answers (3)

rjohnston
rjohnston

Reputation: 7373

When I start a new project, I generally take the following steps:

  1. Create a new Java project in Eclipse, using the Java project wizard and opting to keep source and class files in separate directories ('src' and 'class')
  2. Set up the project in Eclipse with the package structure you want
  3. Create a new repository (or folder in your repository) for the project, with the normal /trunk/ /branches/ /tags/ set up
  4. Using your SVN client, import the contents of the project folder Eclipse made for the project (at the level where the 'src' and 'class' directories are) into the trunk of the repository
  5. Confirm everything is in Subversion correctly (check the trunk out to a new location)
  6. Using Eclipse, delete the project (and the files on disk)
  7. Create a new project using the 'Checkout projects from SVN' wizard, using the trunk of the repository
  8. Create your Ant script, ensure the project builds correctly, and add the Ant script to the repository

Now, from Hudson:

  1. Create a new job and set the Subversion URL to the root of the repository
  2. Add a build set that will use Ant (I've always had to install my own version of Ant and ensure it's configured correctly to have this work) and will call the Ant script you
  3. Use 'Build Now' to see if the job will build correctly

You can invoke your JUnit tests from Ant in the build script (first compile them with the javac task, then run them with the junit task). Hudson will track the test results if you ask it to.

You can use a shell script build step to copy your server jar to where it's needed, and restart the server instance. Like Mnementh said, it sounds like you've got the native libraries sorted...

Upvotes: 2

Mnementh
Mnementh

Reputation: 51311

At our company we actually use Eclipse, Java, Ant, SVN, Junit and Hudson. That is all you mentioned except the native libraries. If you said your ant-buildscript already works with the native libraries that problem seems solved too. To integrate it well into eclipse you could do it in two ways: Use Ant also from Eclipse (has downsides) or the developer has to install the native library for his machine properly, so that Eclipse can compile without a problem and for continuous integration it will be downloaded by Ant.

Upvotes: 1

Paul Wagland
Paul Wagland

Reputation: 29134

If you are not tied to using ant, and are prepared to use Maven, then it is simply a matter of setting up Maven with the Eclipse plugin which generates the Eclipse projects for you.

Hudson already knows how to build Maven projects, so that is taken care of.

So long as you can pull your projects into eclipse, then it will be able to run the unit tests, and hudson can use the previously mentioned maven support to run the unit tests as well.

If you use Maven, then you will want to follow it's guidelines on how to create a project, here is a good starting point.

Hope this helps.

Upvotes: 1

Related Questions