Problem with Ant jars

A

apattin

When using Eclipse, I can create a jar for a package ("com.foo.bar") ;
the package directory structure is replicated within the jar. How can I
do the same using the Ant jar task (running Ant from within Eclipse)?
It seems all the jars ant builds contain just the class files with no
structure.

Thanks!
 
A

apattin

Thanks to all who responded. I found the solution; here it is for
others:

I was having trouble creating the jar from Eclipse, where the project
structure is like this:


my_project/com/my_name/package1
/package2

The .class files are under package1 and package2

What I found out is you have to specify the basedir for the fileset in
the jar task as the parent dir to "com". So:

<project name="Test Build" default="main" basedir="C:\my_project">
<property name="package_root" value="com/my_name/"/>
<property name="package1_dir" value="${package_root}package1/"/>

<jar destfile="${package1_dir}package1.jar" >
<fileset dir="${basedir}"
includes="${package1_dir}**/*.class"></fileset>
</jar>

worked for me.

Thanks!
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top