Jonah
Jonah

Reputation: 10091

Ant: Split Source Directory into Two Jars

How does one go about creating two Jars from one project source folder? Is that possible, or must I create another project? My project uses Ant right now to generate one Jar. For example, say I want to split up the class files like this:

Jar 1:
    com.myproject.Foo
    com.myproject.Bar
Jar 2:
    com.myproject.FooBar
    com.myproject.BarFoo
    com.myproject.FooBarFoo
    ...

Upvotes: 1

Views: 592

Answers (1)

JB Nizet
JB Nizet

Reputation: 691655

See http://ant.apache.org/manual/Tasks/jar.html. You just have to use filesets or includes/excludes inside your jar task to include only the files you want in each jar:

<target name="makeJars">
    <jar destfile="jar1.jar" 
         basedir="classes" 
         includes="com/myproject/Foo.class, com/myproject/Bar.class"/>

    <jar destfile="jar2.jar" 
         basedir="classes" 
         includes="com/myproject/FooBar.class, com/myproject/BarFoo.class, com/myproject/FooBarFoo.class" />
</target>

Upvotes: 1

Related Questions