Home - Search - Site Map - Site Graph   |  Contact  
( Last Modified: 2008 October 20th 10:42 PM )

Eclipse How To Instructions

Automatically Jar java projects with an ant builder.

Create ant ant build file to Jar your source and binaries.

Here's an example. Assuming that your source is in the folder "/src".
And that you have the folder "built/classesAndSource" under you project folder.

This will create 3 jar files:
- A jar containing just the java source files
- A jar containing just the classes.
- A jar file containing both the classes and source files.

<?xml version="1.0" ?>
<project name="JavaProject"
default="main">

<target name="main">

<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd" />
</tstamp>

<!-- Source -->
<zip destfile="built/JavaProject_${TODAY}_source.zip"
basedir="src"/>

<!-- Classes -->
<jar destfile="built/JavaProject_${TODAY}.jar" basedir="bin"/>

<!-- Both -->
<delete includeemptydirs="true">
<fileset dir="built/classesAndSource" includes="**/*"/>
</delete>

<copy todir="built/classesAndSource">
<fileset dir="src"/>
<fileset dir="bin"/>
</copy>

<jar destfile="built/JavaProject_${TODAY}_withSource.jar" basedir="built/classesAndSource"/>

</target>

</project>

Next add an ant builder to your project:

Right-click the project in the package explorer view > Properties > Builders > New... > Ant Builder >

Under the main tab:

Add the buildfile you created above with > browse workspace > (add the ant build file you created)

Under the targets tab:

For "Manual Build:" select "Set Targets" > uncheck all targets so the builder does not run for "Manual build:"

Now when ever you want to jar you project for distribution, just select "Project > Clean" and the ant builder will run.

Set the value of the @author tag

Normally eclipse uses the USER system variable to fill in the @author tag.

This can be chaged by running eclipse with the -Duser.name="NEW_AUTHORNAME"

For example you could put the following in a short cut:

eclipse.exe -vmargs -Duser.name="NEW_AUTHORNAME"

Open Eclipse with a specific workspace

The workspace to use can be set at the command line with the argument "-data".

For example:

eclipse.exe -data workspace2

Would open eclipse and use workspace2, without changing the default workspace, so that when you run "eclipse.exe" without the -data argument it will still open the default workspace.

( Page Created: 2008 October 20th 01:22 PM )