【问题标题】:MANIFEST.MF is override after running build.xml using antMANIFEST.MF 在使用 ant 运行 build.xml 后被覆盖
【发布时间】:2012-08-25 22:11:09
【问题描述】:

有以下目录结构

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>

【问题讨论】:

    标签: ant build manifest.mf


    【解决方案1】:

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

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

    只需添加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-10-13
    • 1970-01-01
    • 2015-01-15
    • 2016-11-22
    • 2011-03-04
    • 2015-01-16
    • 2015-12-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多