0

have following directory structure

src/com
src/META-INF/MANIFEST.MF
src/META-INF/spring
src/META-INF/spring/context.xml

now when i run the script, my menifest file is override, i don't want that, because i have to add custom enteries in it and i want that to be adding in generated .jar file. THing is all other files are copied, but this one is override.

my build.xml is as follows

<project name="TaskNodeBundle" default="all" basedir=".">
    <!-- Sets variables which can later be used. -->
    <!-- The value of a property is accessed via ${} -->
    <property name="bundlename" value="tasknodebundle" />
    <property name="src.dir" location="../src" />
    <property name="lib.dir" location="../lib" />
    <property name="build.dir" location="/buildoutput" />
    <property name="build.dest" location="../build/dest" />


    <!--
    Create a classpath container which can be later used in the ant task
  -->
    <path id="classpath">
        <fileset dir="${lib.dir}/">
            <include name="*.jar" />

        </fileset>
    </path>

    <target name="clean">
            <delete dir="${build.dir}" />
            <delete dir="${build.dest}" />
    </target>


    <!-- Deletes the existing build directory-->
    <target name="mkdir" depends="clean">
            <mkdir dir="${build.dest}"/>
    </target>


<!-- Compiles the java code -->
    <target name="compile" depends="mkdir">
        <javac srcdir="${src.dir}" destdir="${build.dest}" classpathref="classpath" />
    </target>

    <target name="package-bundle" depends="compile" description="Generates the bundle">
        <jar destfile="${build.dest}/${bundlename}.jar">
            <fileset dir="${src.dir}">
                <include name="**/**.class" />
                <include name="**/**.properties"/>
                <include name="/META-INF/**.*" />
                <include name="/META-INF/spring/**.*" />
            </fileset>

        </jar>
    </target>


    <target name="all" depends="package-bundle">
    </target>

</project>
vicky
  • 890
  • 4
  • 23
  • 54

1 Answers1

3

See http://ant.apache.org/manual/Tasks/jar.html.

If the manifest is omitted, a simple one will be supplied by Apache Ant.

Just add manifest attribute or use zip task.

Also ant path masks are used incorrectly. See http://en.wikibooks.org/wiki/Apache_Ant/Fileset.

Corrected version:

    <zip destfile="${build.dest}/${bundlename}.jar">
        <fileset dir="${src.dir}">
            <include name="META-INF/**" />
            <include name="**/*.class" />
            <include name="**/*.properties"/>
        </fileset>
    </zip>
Vadzim
  • 24,954
  • 11
  • 143
  • 151