bahtiyartan
bahtiyartan

Reputation: 1030

How to add only its own classes to a jar file without subpackages using ant script?

Let's say my package organization is like below:

net.sf.myparentpackage

net.sf.test.mysuppackage

The code below includes all classes and subpackages.

<jar destfile="myjar.jar" manifest="MANIFEST.MF">
  <fileset dir=".." includes="net/sf/myparentpackage/**"
</jar>

I want to include only requiredclass1.java and requiredclass2.java without listing all class names.

Upvotes: 4

Views: 244

Answers (1)

rdonuk
rdonuk

Reputation: 3956

You can do it by put ".java" or ".class" instead of "**"

<jar destfile="myjar.jar" manifest="MANIFEST.MF">
  <fileset dir=".." includes="net/sf/myparentpackage/*.java"
</jar>

https://ant.apache.org/manual/Types/fileset.html

Upvotes: 3

Related Questions