tags:

views:

37

answers:

1

My project structure has these base packages.

  • a.b.c.core
  • a.b.c.web
  • a.b.c.common

And core,web,common packages will have sub packages. I have compiled all the java files under src dir and copied the class files to a dir.

<javac srcdir="${src}" destdir="${build}/myapp" debug="true">
  <classpath refid="compile.classpath"/>
  <classpath refid="ant.classpath" />
</javac>

Now i want to build a jar say core.jar with class files belonging to a.b.c.core and its subpackages. Similarly a web.jar and common.jar. Can someone give a sample code for jar task to accompolish this?

Thanks

+2  A: 

Rather than excluding specific areas, I'd just include the ones you want:

<jar destfile="core.jar"
     basedir="${build}/myapp"
     includes="a/b/c/core/**"
/>
<jar destfile="common.jar"
     basedir="${build}/myapp"
     includes="a/b/c/common/**"
/>
<jar destfile="web.jar"
     basedir="${build}/myapp"
     includes="a/b/c/web/**"
/>

The jar task documentation is pretty good though... if the above doesn't do what you want, then that should help you.

Jon Skeet
Indeed, the jar task page has examples showing how to combine includes and excludes.
Stephen C