Adding main class and jar files to Class-Path in manifest through ANT script
The below ANT script will help us to add main class and jar files to Class-Path in manifest of the JAR file.<?xml version="1.0" encoding="iso-8859-1"?>
<project name="jar with libs" default="compile and build" basedir=".">
<target name="compile and build">
<delete dir="bin" />
<mkdir dir="bin"/>
<!-- copy the JARs that should be added to MANIFEST class-path to "bin" directory -->
<copy todir="bin">
<fileset dir="." includes="**/lib/*.jar" />
</copy>
<!-- creates your jar with the contents inside "bin" (now with your .class and .jar dependencies) -->
<jar destfile="SampleJar.jar" basedir="bin" duplicate="preserve">
<manifest>
<!-- Who is building this jar? -->
<attribute name="Built-By" value="Albin I" />
<!-- Information about the program itself -->
<attribute name="Implementation-Vendor" value="Company" />
<attribute name="Implementation-Title" value="Albin" />
<attribute name="Implementation-Version" value="1.0.0beta1" />
<attribute name="Class-Path" value="lib/bpm-services.jar lib/ldapjclnt11.jar lib/ojdbc14.jar lib/xmlparserv2.jar"/>
<!-- this tells which class should run when executing your jar -->
<attribute name="Main-class" value="com.import.ImportUtility" />
</manifest>
</jar>
</target>
</project>
No comments:
Post a Comment