关于build.xml和外部配置文件的使用

来源:互联网 发布:淘宝卖家的快递费 编辑:程序博客网 时间:2024/05/01 21:56

提供一个build.xml的文件的样本和一个很简单的配置文件

 

=============build.xml================================

<?xml version="1.0" ?>

<project default="main">
 <!--外部配置ファイルを引き込む-->
 <property file="./build-path.properties" />

 <!--パースを設定-->
 <property name="project_path" value=".//" />
 <property name="class_path" value="./classes" />
 <property name="jar_path" value="./lib" />

 <target name="main" depends="compile, compress,move" description="Main target">
  <echo>
            Building the jar file
        </echo>
 </target>

 <!--javaファイルをコンパイル-->
 <target name="compile" description="Compilation target">
  <echo>フォルダを削除</echo>
  <delete dir="${class_path}" />

  <echo>フォルダを生成</echo>
  <mkdir dir="${class_path}" />

  <echo>外部配置ファイルに設定のパースを使用し、クラスファイルを生成</echo>
  <javac srcdir="${properties_src_path}" destdir="${class_path}">
   <compilerarg value="-Xlint:unchecked" />
  </javac>
 </target>

 <!--jarファイル-->
 <target name="compress" description="Compression target">
  <echo>指定ファイルを指定フォルダに移動</echo>
  <copy todir="${class_path}">
   <fileset dir="${project_path}">
    <include name="*.txt" />
   </fileset>
  </copy>

  <echo>既存のjarファイルを削除</echo>
  <delete>
   <fileset file="${jar_path}/test.jar">
   </fileset>
  </delete>

  <echo>jarファイルを生成</echo>
  <jar destfile="${jar_path}/test.jar" includes="*.class">
   <fileset dir="${class_path}" />
  </jar>
 </target>

 <!--jarファイルを移動-->
 <target name="move" description="move">
  <!--
  <echo>libフォルダを削除</echo>
  <delete dir="${jar_path}" />
  
  <echo>libフォルダを生成</echo>
  <mkdir dir="${jar_path}" />

  <echo>jarファイルを移動</echo>
  <move file="${project_path}/test.jar" todir="${jar_path}"></move>
  <move file="${jar_path}/test.jar" todir="${project_path}"></move>
  <move  todir="${jar_path}">
   <fileset dir="${project_path}" >
    <include name="*.txt"/>
   </fileset>
  </move>
    
  <echo>jarファイルを複製</echo>
  <copy todir="${jar_path}" overwrite="yes">
   <fileset dir="${project_path}">
    <include name="*.jar" />
   </fileset>
  </copy>
  
  <delete file="${project_path}/test.jar" />
  -->
 </target>


</project>

 

 

=====build-path.properties========================

properties_pro_path=./
properties_src_path=${properties_pro_path}/src/test

原创粉丝点击