0

具有以下目录结构

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

现在,当我运行脚本时,我的清单文件被覆盖,我不希望这样,因为我必须在其中添加自定义输入,并且我希望将其添加到生成的 .jar 文件中。事情是所有其他文件都被复制了,但是这个被覆盖了。

我的 build.xml 如下

<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>
4

1 回答 1

3

请参阅http://ant.apache.org/manual/Tasks/jar.html

如果manifest省略,Apache Ant 将提供一个简单的。

只需添加manifest属性或使用zip任务。

蚂蚁路径掩码也使用不正确。请参阅http://en.wikibooks.org/wiki/Apache_Ant/Fileset

修正版:

    <zip destfile="${build.dest}/${bundlename}.jar">
        <fileset dir="${src.dir}">
            <include name="META-INF/**" />
            <include name="**/*.class" />
            <include name="**/*.properties"/>
        </fileset>
    </zip>
于 2012-08-31T05:41:11.903 回答