日期:2014-05-20  浏览次数:20897 次

ant 编译时 配置文件编译不到class路径下
如题

<?xml version="1.0" encoding="utf-8"?>
<project name="PNMSCommon" basedir="." default="pack">

<!-- properies -->
  <property name="jarname" value="PNMSCommon"/>

  <property name="src.dir" value="src" />

  <property name="report.dir" value="report" />

  <property name="classes.dir" value="bin" />

  <property name="lib.dir" value="lib" />
   
  <property name="snmp.dir" value="snmp" />

  <property name="dist.dir" value="dist" />
   
  <property name="doc.dir" value="doc"/>

   
  <path id="master-classpath">

  <fileset file="${lib.dir}/*.jar" />
   
  <fileset file="${snmp.dir}/*.jar" />

  <pathelement path="${classes.dir}"/>

  </path>



  <target name="init">

  </target>



  <target name="compile" depends="init" description="compile the source files">
 
  <delete dir="${classes.dir}"/>

  <mkdir dir="${classes.dir}"/>

  <javac srcdir="${src.dir}" destdir="${classes.dir}" target="1.5" defaultexcludes ="false">
   
  <classpath refid="master-classpath"/>
 
   
  </javac>

  </target>



  <target name="test" depends="compile" description="run junit test">

  <mkdir dir="${report.dir}"/>

  <junit printsummary="on"

  haltonfailure="false"

  failureproperty="tests.failed"

  showoutput="true">

  <classpath refid="master-classpath" />

  <formatter type="plain"/>

  <batchtest todir="${report.dir}">

  <fileset dir="${classes.dir}">

  <include name="**/*Test.*"/>

  </fileset>

  </batchtest>

  </junit>

  <fail if="tests.failed">

  ***********************************************************

  **** One or more tests failed! Check the output ... ****

  ***********************************************************

  </fail>

  </target>



  <target name="pack" depends="compile" description="make jar file">

  <mkdir dir="${dist.dir}" />

  <jar destfile="${dist.dir}/${jarname}.jar" basedir="${classes.dir}">

  <exclude name="**/*Test.*" />

  <exclude name="**/Test*.*" />

  </jar>

  </target>



  <!--target name="doc" depends="pack" description="create api doc">

  <mkdir dir="${doc.dir}" />

  <javadoc destdir="${doc.dir}"

  author="true"

  version="true"

  use="true"

  windowtitle="Test API">

  <packageset dir="${src.dir}" defaultexcludes="yes">

  <include name="example/**" />

  </packageset>

  <doctitle><![CDATA[<h1>Hello, test</h1>]]></doctitle>

  <bottom><![CDATA[<i>All Rights Reserved.</i>]]></bottom>

  <tag name="todo" scope="all" description="To do:" />

  </javadoc>

  </target-->

</project>



------解决方案--------------------
使用
XML code
<copy todir="...">
<fileset dir="..." includes="..."/>
</copy>