【问题标题】:Including a database file in an Jar using Ant使用 Ant 在 Jar 中包含数据库文件
【发布时间】:2012-10-15 21:06:15
【问题描述】:

我正在尝试使用 ant 和 eclipse 制作一罐简单的库存程序。我已经构建了 xml 文件,但是我需要向 buildjar 目标添加一些内容,这将导致 ant 将 itemdatabase 文件(当前位于基本目录中)包含在 jar 中。到目前为止我所拥有的。

<target name="buildjar" depends="clean">
    <jar jarfile="${build.dir}/StudioCat.jar">
        <fileset dir="${basedir}">
            <include name="config/*"/>
            </fileset>
            <fileset dir="${bin.dir}">
                <include name="**/*.class"/>
            </fileset>
            <manifest>
                <attribute name="Main-Class" value="presentation.CreateInventoryUI"/>
            </manifest>
    </jar>

    <copy todir="${build.dir}">
    <fileset dir="${basedir}">
        <include name="config*/**/*"/>
        </fileset>
        </copy>

        </target>

【问题讨论】:

    标签: xml ant


    【解决方案1】:

    类似于您如何包含“config”目录及其内容。

    <fileset dir="${basedir}">
      <include name="config/*"/>
      <include name="itemdatabase"/> <!-- To include itemdatabase -->
    </fileset>
    

    【讨论】:

      【解决方案2】:

      1) 您使用 .jar 任务(正如您已经在做的那样):

      2) 您的项目中的“src/”下通常有几个子文件夹:

      src/
          css/
          java/
          html/
          images/
          config/
      

      3) 您的 XML 将存在于 src/config 中(例如)。你的

      <target name="buildjar" depends="clean">
        <jar jarfile="${build.dir}/StudioCat.jar">
          <fileset dir="${basedir}"
               includes="config.xml"
               fullpath="config/config.xml"/>
          </fileset>
      ...
      

      几个链接:

      问:您使用的是 Eclipse 之类的 IDE 吗?

      【讨论】:

        猜你喜欢
        • 2011-02-20
        • 2012-03-10
        • 2011-04-15
        • 2014-12-08
        • 2013-01-06
        • 2010-09-26
        • 2010-11-15
        • 2016-12-30
        • 1970-01-01
        相关资源
        最近更新 更多