jar using ant question

M

Mike G.

I'm new to ant.

When I create my jar file, I would like to include my source dir, as well as
my build dir.

Here is how my directory structure is set up

Project
|
+- Build
| |
| +- project.class
|
+- Source
|
+- project.java
|
+- Doc
|


this is how I am performing my jar command in the build.xml file:

<target name="dist" depends="compile" description="generate the
distribution file (jar file)" >
<jar jarfile="rds_rev${version}.jar" basedir="${build}"/>
</target>

As you can see this is just creating a jar file of my "build" directory. I
guess I would like to be able to specify two directories to jar. The "build"
directory and the "source" directory.

Can someone help me with this?

Thanks in advance,

-Mike
 
W

Wayne Berke

Mike G. said:
I'm new to ant.

When I create my jar file, I would like to include my source dir, as well as
my build dir.

Here is how my directory structure is set up

Project
|
+- Build
| |
| +- project.class
|
+- Source
|
+- project.java
|
+- Doc
|

this is how I am performing my jar command in the build.xml file:

<target name="dist" depends="compile" description="generate the
distribution file (jar file)" >
<jar jarfile="rds_rev${version}.jar" basedir="${build}"/>
</target>

As you can see this is just creating a jar file of my "build" directory. I
guess I would like to be able to specify two directories to jar. The "build"
directory and the "source" directory.

Can someone help me with this?

Thanks in advance,

-Mike

Take a look at the documentation for the <fileset> tag.

Wayne
 
L

Lee Peterson

Hi Mike,

Mike G. wrote in message ...
I'm new to ant.

When I create my jar file, I would like to include my source dir, as well as
my build dir.

Here is how my directory structure is set up

Project
|
+- Build
| |
| +- project.class
|
+- Source
|
+- project.java
|
+- Doc
|


this is how I am performing my jar command in the build.xml file:

<target name="dist" depends="compile" description="generate the
distribution file (jar file)" >
<jar jarfile="rds_rev${version}.jar" basedir="${build}"/>
</target>

As you can see this is just creating a jar file of my "build" directory. I
guess I would like to be able to specify two directories to jar. The "build"
directory and the "source" directory.

Can someone help me with this?

Maybe something like the following:

<target name="dist" depends="compile" description="generate the
distribution file (jar file)" >
<fileset dir="build">
<include name="*.class"/>
</fileset>
<fileset dir="source">
<include name="*.java"/>
</fileset>
<jar jarfile="rds_rev${version}.jar"/>
</target>

Sorry, I don't have time to try this right now.

In the manual, <jar> is under :
Table of Contents -> Ant Tasks -> Core Tasks

and <dirset> and <fileset> are under :
Table of Contents -> Using Ant -> Writing a Simple Buildfile -> Path-like
Structures

The Ant manual notes that 'basedir' is not required in <jar>. It also notes
that "This task forms an implicit FileSet and supports all attributes of
<fileset>".

Lee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top