Reputation: 723
i have an ant task
<target name="create_jar" depends="compile">
<jar destfile="build/temp/MyClassJar.jar" basedir="build/classes/com/company/utils">
<manifest>
<attribute name="Main-Class" value="com.company.utils.MyClass"/>
</manifest>
</jar>
</target>
the folder build/classes has multiple packages and class files but in my jar i only want to include only two files MyClass.class and MyClass$1.class which are in com/company/utils folder.
if i have base-dir as com/company/utils when i run the task the jar does not have the package folders in like com/company/utils is not created inside the jar file but if i change my base-dir to build/classes then all the files are getting included. what do to fix this.
Upvotes: 0
Views: 1905
Reputation: 2115
The Jar task takes a nested fileset, so you can do this:
<jar destfile="build/temp/MyClassJar.jar">
<fileset dir="build/classes" includes="**/MyClass*.class" />
<manifest>
<attribute name="Main-Class" value="com.company.utils.MyClass"/>
</manifest>
</jar>
Upvotes: 3