Ant JumpStart

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Installation:

1. Set the ANT_HOME environment variable to point to this location.

2. Set the JAVA_HOME environment variable to point to the JDK location.

3. Add ANT_HOME/bin to your system's PATH environment variable.

Build file :

1. ${build.dir} means referenced a var :build.dir

2. specify diretory :

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

<!-- Temporary build directories -->

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

3. make dir on specified diretory :

<target name="prepare">

<mkdir dir="${build.lib}"/>

</target>

4. clean dir

<target name="clean" description="Remove all generated files.">

<delete dir="${build.dir}"/>

</target>

5. compile java files

<target name="compile" depends="prepare"

description="Compiles all source code.">

<javac srcdir="${src.dir}"

destdir="${build.classes}"/>

</target>

6. jar java files

<target name="jar" depends="compile"

description="Generates oreilly.jar in the 'dist' directory.">

<!-- Exclude unit tests from the final JAR file -->

<jar jarfile="${build.lib}/oreilly.jar"

basedir="${build.classes}"

excludes="**/*Test.class"/>

</target>

7. target can be invoked single : eg.

command line : ant jar

8. specify classpath and compile :

<path id="mypath">

<pathelement location="${java.home}/jre/lib/rt.jar"/>

</path>

<target name="all">

<javac srcdir=".">

<classpath refid="mypath"/>

</javac>

</target>

or

<path id="classpath">

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

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

</fileset>

</path>

9. copy files

<copy todir="${weblogic.dir}/${weblogic.server.home}/public_html/jsp">

<fileset dir="${src.www.dir}/jsp"/>

</copy>

10.Javadoc

<target name = “javadoc” depends=”compile,jar”>

<mkdir dir = “${doc.dir}/api”/>

<javadoc packagenames = “ myproj.*”

sourchpath = “${src.dir}”

destdir = “${doc.dir}/api”

author = “true”

version = “true”

use = “true”>

<classpath refid = “classpath”/>

</javadoc>

</target>

all in a build.xml file:

<?xml version="1.0"?>

<!-- build.xml - a simple Ant buildfile -->

<project name="Simple Buildfile" default="compile" basedir=".">

<!-- The directory containing source code -->

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

<!-- Temporary build directories -->

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

<property name="build.classes" value="${build.dir}/classes"/>

<property name="build.lib" value="${build.dir}/lib"/>

<!-- Target to create the build directories prior to the -->

<!-- compile target. -->

<target name="prepare">

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

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

<mkdir dir="${build.lib}"/>

</target>

<target name="clean" description="Remove all generated files.">

<delete dir="${build.dir}"/>

</target>

<target name="compile" depends="prepare"

description="Compiles all source code.">

<javac srcdir="${src.dir}" destdir="${build.classes}"/>

</target>

<target name="jar" depends="compile"

description="Generates oreilly.jar in the 'dist' directory.">

<!-- Exclude unit tests from the final JAR file -->

<jar jarfile="${build.lib}/oreilly.jar"

basedir="${build.classes}"

excludes="**/*Test.class"/>

</target>

<target name="all" depends="clean,jar"

description="Cleans, compiles, then builds the JAR file."/>

</project>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航