在ant构建期间不会创建jar和清单文件

时间:2015-07-22 07:37:57

标签: java ant

我是Ant新手,只是按照如何执行此操作的教程。我的目标是用manifest创建一个.jar。但在构建期间,.jar不会在“lib”文件夹中创建。在构建期间没有错误,所以我有点失落。

这是build.xml中的内容:

    <?xml version="1.0"?>
<project name="converter" default="main" basedir=".">
   <property name="projectName" value="Converter" />
   <property name="src.dir" value="src"/>
   <property name="web.dir" value="war"/>
  <property name="lib.dir" location="lib"/>
   <property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
   <property name="name" value="converter"/>
   <property name="main-class" value="com.ouc.mv90.conversion.CSVtoMV90Converter" />

   <!-- external libraries classpath, we don't need sources and javadoc -->
    <path id="classpath">
        <fileset dir="${basedir}/">
            <include name="${lib.dir}/*.jar" />
            <exclude name="${lib.dir}/*sources.jar"/>
            <exclude name="${lib.dir}/*javadoc.jar"/>
        </fileset>
    </path>

   <path id="master-classpath">
      <fileset dir="${web.dir}/WEB-INF/lib">
         <include name="${lib.dir}/*.jar" />
         <include name="*.jar"/>
      </fileset>
      <pathelement path="${build.dir}"/>
   </path>

   <target name="build" description="Compile source tree java files">
      <mkdir dir="${build.dir}"/>
      <javac destdir="${build.dir}" source="1.5" target="1.5">          
         <src path="${src.dir}"/>
         <classpath refid="master-classpath"/>
      </javac>
   </target>

    <target name="init">
            <mkdir dir="${build.dir}" />
        </target>

    <target name="compile" depends="init" description="compile the source ">
            <javac includeantruntime="false" srcdir="${src.dir}" destdir="${build.dir}" classpathref="classpath" />
        </target>

   <target name="clean" description="Clean output directories">
      <delete>
         <fileset dir="${build.dir}">
            <include name="**/*.class"/>
         </fileset>
      </delete>
   </target>

    <path id="master-classpath">
       <fileset dir="${web.dir}/WEB-INF/lib">
          <include name="*.jar"/>
       </fileset>
       <pathelement path="${build.dir}"/>
    </path>

    <target name="jar" depends="compile" description="package, output to JAR">

          <jar jarfile="${lib.dir}/${projectName}.jar" basedir="${build.dir}">
            <manifest>
                <attribute name="Main-Class" value="${main-class}" />
                <attribute name="Class-Path" value="${classpath.name}" />
            </manifest>
        </jar>

    </target>
    <!-- Default, run this -->
        <target name="main" depends="clean, compile, jar" />
</project>

0 个答案:

没有答案